summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/rbot/core/basics.rb18
-rw-r--r--lib/rbot/message.rb7
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