summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2008-03-27 21:50:50 +0100
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2008-03-27 21:50:50 +0100
commit4b3c33ad04cb47eeed3b360ac0743415de0d9ad9 (patch)
tree42327c6dadf876e1dd94fac62ff868eceadb99f9
parent445b4b7f144edb862f7744eae4eeddb5f4b27038 (diff)
* handle invites properly -- forgot more than half the files :/
-rw-r--r--lib/rbot/ircbot.rb7
-rw-r--r--lib/rbot/message.rb13
-rw-r--r--lib/rbot/plugins.rb3
3 files changed, 20 insertions, 3 deletions
diff --git a/lib/rbot/ircbot.rb b/lib/rbot/ircbot.rb
index 9a6685da..f9948750 100644
--- a/lib/rbot/ircbot.rb
+++ b/lib/rbot/ircbot.rb
@@ -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])
diff --git a/lib/rbot/message.rb b/lib/rbot/message.rb
index 35100802..aa825e13 100644
--- a/lib/rbot/message.rb
+++ b/lib/rbot/message.rb
@@ -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
diff --git a/lib/rbot/plugins.rb b/lib/rbot/plugins.rb
index 6f308609..9d633c1b 100644
--- a/lib/rbot/plugins.rb
+++ b/lib/rbot/plugins.rb
@@ -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