From 1239f5f80ecae2353d78491dbbf873b801bdab7d Mon Sep 17 00:00:00 2001 From: Giuseppe Bilotta Date: Sun, 13 Apr 2008 00:53:56 +0200 Subject: + ModeChangeMessage class --- lib/rbot/ircbot.rb | 3 +++ lib/rbot/message.rb | 10 ++++++++++ lib/rbot/plugins.rb | 2 ++ 3 files changed, 15 insertions(+) (limited to 'lib/rbot') 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 -- cgit v1.2.3