]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/commitdiff
* handle invites properly -- forgot more than half the files :/
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Thu, 27 Mar 2008 20:50:50 +0000 (21:50 +0100)
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Thu, 27 Mar 2008 20:50:50 +0000 (21:50 +0100)
lib/rbot/ircbot.rb
lib/rbot/message.rb
lib/rbot/plugins.rb

index 9a6685da5472909b4dbe5c2f16a42a6d4edd475f..f994875002d4fcf7f1d39a5a9eab0b25eb72e9ae 100644 (file)
@@ -668,9 +668,10 @@ class Bot
       @plugins.delegate("kick", m)
     }
     @client[:invite] = proc {|data|
-      if data[:target] == myself
-        join data[:channel] if @auth.allow?("join", data[:source], data[:source].nick)
-      end
+      m = InviteMessage.new(self, server, data[:source], data[:target], data[:channel])
+
+      @plugins.delegate("listen", m)
+      @plugins.delegate("invite", m)
     }
     @client[:changetopic] = proc {|data|
       m = TopicMessage.new(self, server, data[:source], data[:channel], data[:topic])
index 35100802b8d640db409b90d876fc54a2ed147900..aa825e135ba31585348c2825d6fa19e94f4d1538 100644 (file)
@@ -419,6 +419,19 @@ module Irc
     end
   end
 
+  # class to manage IRC INVITEs
+  # +address?+ can be used as a shortcut to see if the bot was invited,
+  # which should be true except for server bugs
+  class InviteMessage < BasicUserMessage
+    # channel user was invited to
+    attr_reader :channel
+
+    def initialize(bot, server, source, target, channel, message="")
+      super(bot, server, source, target, message)
+      @channel = channel
+    end
+  end
+
   # class to pass IRC Nick changes in. @message contains the old nickame,
   # @sourcenick contains the new one.
   class NickMessage < BasicUserMessage
index 6f308609f55d1adb60eac2060504399d07af71ee..9d633c1b838c9bb4365a1dc1d904aeb5cdb8c443 100644 (file)
@@ -95,6 +95,9 @@ module Plugins
                          Called when a user (or the bot) is kicked from a
                          channel the bot is in.
 
+  invite(InviteMessage)::
+                         Called when the bot is invited to a channel.
+
   join(JoinMessage)::
                          Called when a user (or the bot) joins a channel