diff options
author | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2007-09-02 07:16:22 +0000 |
---|---|---|
committer | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2007-09-02 07:16:22 +0000 |
commit | a38462074a633a315cbf0ebc169ed1a9a9f86854 (patch) | |
tree | 283d03084ce3ac7e0c77cdae233e2e859b887b72 /lib | |
parent | 414734f9872b1d60d2c92951965c0aba0cdf5884 (diff) |
* CTCP replies always use the same CTCP command. Use the new syntax to reply to CTCP PING and TIME commands in basics
Diffstat (limited to 'lib')
-rw-r--r-- | lib/rbot/core/basics.rb | 18 | ||||
-rw-r--r-- | lib/rbot/message.rb | 7 |
2 files changed, 13 insertions, 12 deletions
diff --git a/lib/rbot/core/basics.rb b/lib/rbot/core/basics.rb index 44b800f5..2fbafaf7 100644 --- a/lib/rbot/core/basics.rb +++ b/lib/rbot/core/basics.rb @@ -9,15 +9,15 @@ class BasicsModule < CoreBotModule
- def listen(m)
- return unless m.kind_of?(PrivMessage)
- if m.ctcp == 'PING'
- m.ctcp_reply m.ctcp, m.message
- if m.private?
- @bot.irclog "@ #{m.source} pinged me"
- else
- @bot.irclog "@ #{m.source} pinged #{m.target}"
- end
+ def ctcp_listen(m)
+ who = m.private? ? "me" : m.target
+ case m.ctcp.intern
+ when :PING
+ m.ctcp_reply m.message
+ @bot.irclog "@ #{m.source} pinged #{who}"
+ when :TIME
+ m.ctcp_reply Time.now.to_s
+ @bot.irclog "@ #{m.source} asked #{who} what time it is"
end
end
diff --git a/lib/rbot/message.rb b/lib/rbot/message.rb index a1265532..41658c6b 100644 --- a/lib/rbot/message.rb +++ b/lib/rbot/message.rb @@ -331,9 +331,10 @@ module Irc @replied = true end - # send a CTCP response, i.e. a private notice to the sender - def ctcp_reply(command, string, options={}) - @bot.ctcp_notice @source, command, string, options + # send a CTCP response, i.e. a private NOTICE to the sender + # with the same CTCP command and the reply as a parameter + def ctcp_reply(string, options={}) + @bot.ctcp_notice @source, @ctcp, string, options end # convenience method to reply "okay" in the current language to the |