]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/blobdiff - lib/rbot/message.rb
geoip plugin: thread command
[user/henk/code/ruby/rbot.git] / lib / rbot / message.rb
index 901626ec7e6eaf232858c6a3cdbe2a02692dbb87..f6e38e80a73d8f2359f38508466807b51b30c7b4 100644 (file)
@@ -155,7 +155,7 @@ module Irc
       ret << ' plainmessage=' << plainmessage.inspect
       ret << fields if fields
       ret << ' (identified)' if identified?
-      ret << ' (addressed to me)' if identified?
+      ret << ' (addressed to me)' if address?
       ret << ' (replied)' if replied?
       ret << ' (ignored)' if ignored?
       ret << ' (in thread)' if in_thread?
@@ -195,9 +195,7 @@ module Irc
       @plainmessage = BasicUserMessage.strip_formatting(@message)
       @message = BasicUserMessage.strip_initial_formatting(@message)
 
-      if target && target == @bot.myself
-        @address = true
-      end
+      @address = true if source == @bot.myself
 
     end
 
@@ -233,11 +231,6 @@ module Irc
       return @address
     end
 
-    # has this message been replied to by a plugin?
-    def replied?
-      return @replied
-    end
-
     # strip mIRC colour escapes from a string
     def BasicUserMessage.stripcolour(string)
       return "" unless string
@@ -328,9 +321,8 @@ module Irc
       @ctcp = false
       @action = false
 
-      if target == @bot.myself
+      if @address = (target == @bot.myself)
         @private = true
-        @address = true
         @channel = nil
         @replyto = source
       else
@@ -362,6 +354,8 @@ module Irc
         @action = @ctcp == 'ACTION'
         debug "Received CTCP command #{@ctcp} with options #{@message} (action? #{@action})"
         @logmessage = @message.dup
+        @plainmessage = BasicUserMessage.strip_formatting(@message)
+        @message = BasicUserMessage.strip_initial_formatting(@message)
       end
 
       # free splitting for plugins
@@ -467,17 +461,17 @@ module Irc
 
   # class to manage IRC PRIVMSGs
   class PrivMessage < UserMessage
-    def initialize(bot, server, source, target, message)
-      @msg_wants_id = true
-      super
+    def initialize(bot, server, source, target, message, opts={})
+      @msg_wants_id = opts[:handle_id]
+      super(bot, server, source, target, message)
     end
   end
 
   # class to manage IRC NOTICEs
   class NoticeMessage < UserMessage
-    def initialize(bot, server, source, target, message)
-      @msg_wants_id = true
-      super
+    def initialize(bot, server, source, target, message, opts={})
+      @msg_wants_id = opts[:handle_id]
+      super(bot, server, source, target, message)
     end
   end
 
@@ -546,7 +540,6 @@ module Irc
     attr_accessor :modes
     def initialize(bot, server, source, target, message="")
       super(bot, server, source, target, message)
-      @address = (source == @bot.myself)
       @modes = []
     end
 
@@ -556,6 +549,20 @@ module Irc
     end
   end
 
+  # class to manage WHOIS replies
+  class WhoisMessage < BasicUserMessage
+    attr_reader :whois
+    def initialize(bot, server, source, target, whois)
+      super(bot, server, source, target, "")
+      @whois = whois
+    end
+
+    def inspect
+      fields = ' whois=' << whois.inspect
+      super(fields)
+    end
+  end
+
   # class to manage NAME replies
   class NamesMessage < BasicUserMessage
     attr_accessor :users
@@ -617,7 +624,6 @@ module Irc
       super(bot, server, source, channel, message)
       @channel = channel
       # in this case sourcenick is the nick that could be the bot
-      @address = (source == @bot.myself)
     end
   end