From a38462074a633a315cbf0ebc169ed1a9a9f86854 Mon Sep 17 00:00:00 2001 From: Giuseppe Bilotta Date: Sun, 2 Sep 2007 07:16:22 +0000 Subject: * CTCP replies always use the same CTCP command. Use the new syntax to reply to CTCP PING and TIME commands in basics --- lib/rbot/core/basics.rb | 18 +++++++++--------- 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 -- cgit v1.2.3