summaryrefslogtreecommitdiff
path: root/lib/rbot
diff options
context:
space:
mode:
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2008-04-13 00:53:56 +0200
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2008-04-13 00:53:56 +0200
commit1239f5f80ecae2353d78491dbbf873b801bdab7d (patch)
tree5a5bf7876345456df1e5bad7248884b7a718d574 /lib/rbot
parent1f7b45bcfa05821884ba47d4e42608c8f9b5a6b1 (diff)
+ ModeChangeMessage class
Diffstat (limited to 'lib/rbot')
-rw-r--r--lib/rbot/ircbot.rb3
-rw-r--r--lib/rbot/message.rb10
-rw-r--r--lib/rbot/plugins.rb2
3 files changed, 15 insertions, 0 deletions
diff --git a/lib/rbot/ircbot.rb b/lib/rbot/ircbot.rb
index 3d20b71d..0286ed1b 100644
--- a/lib/rbot/ircbot.rb
+++ b/lib/rbot/ircbot.rb
@@ -638,7 +638,10 @@ class Bot
@plugins.irc_delegate("quit", m)
}
@client[:mode] = proc {|data|
+ m = ModeChangeMessage.new(self, server, data[:source], data[:channel], data[:modestring])
+ m.modes = data[:modes]
irclog "@ Mode #{data[:modestring]} by #{data[:source]}", data[:channel]
+ @plugins.delegate "modechange", m
}
@client[:join] = proc {|data|
m = JoinMessage.new(self, server, data[:source], data[:channel], data[:message])
diff --git a/lib/rbot/message.rb b/lib/rbot/message.rb
index 616bef28..b3a8eb3b 100644
--- a/lib/rbot/message.rb
+++ b/lib/rbot/message.rb
@@ -462,6 +462,16 @@ module Irc
end
end
+ # class to manage mode changes
+ class ModeChangeMessage < BasicUserMessage
+ attr_accessor :modes
+ def initialize(bot, server, source, channel, message="")
+ super(bot, server, source, channel, message)
+ @address = (source == @bot.myself)
+ @modes = []
+ end
+ end
+
class QuitMessage < BasicUserMessage
def initialize(bot, server, source, target, message="")
super(bot, server, source, target, message)
diff --git a/lib/rbot/plugins.rb b/lib/rbot/plugins.rb
index 631984c1..7f6db9bd 100644
--- a/lib/rbot/plugins.rb
+++ b/lib/rbot/plugins.rb
@@ -118,6 +118,8 @@ module Plugins
nick(NickMessage)::
Called when a user (or the bot) changes Nick
+ modechange(ModeChangeMessage)::
+ Called when a User or Channel mode is changed
topic(TopicMessage)::
Called when a user (or the bot) changes a channel
topic