diff options
author | Alex Legler <a3li@gentoo.org> | 2009-11-27 13:35:36 +0100 |
---|---|---|
committer | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2009-12-21 11:05:30 +0100 |
commit | a1db6671fb3819b58bcc1f0494b86d3a32df747f (patch) | |
tree | e0dca8f4d670c744b210b62fc7c81c460b397ea2 /lib/rbot | |
parent | 9b28df160e736561547440f985c35056d044276e (diff) |
ircbot/rfc2812/message: Add banlist message handling
Diffstat (limited to 'lib/rbot')
-rw-r--r-- | lib/rbot/ircbot.rb | 5 | ||||
-rw-r--r-- | lib/rbot/message.rb | 16 | ||||
-rw-r--r-- | lib/rbot/rfc2812.rb | 14 |
3 files changed, 35 insertions, 0 deletions
diff --git a/lib/rbot/ircbot.rb b/lib/rbot/ircbot.rb index 1e1106de..3313fe86 100644 --- a/lib/rbot/ircbot.rb +++ b/lib/rbot/ircbot.rb @@ -757,6 +757,11 @@ class Bot m.users = data[:users] @plugins.delegate "names", m } + @client[:banlist] = proc { |data| + m = BanlistMessage.new(self, server, server, data[:channel]) + m.bans = data[:bans] + @plugins.delegate "banlist", m + } @client[:nosuchtarget] = proc { |data| m = NoSuchTargetMessage.new(self, server, server, data[:target], data[:message]) @plugins.delegate "nosuchtarget", m diff --git a/lib/rbot/message.rb b/lib/rbot/message.rb index e0cb753c..c13e59c1 100644 --- a/lib/rbot/message.rb +++ b/lib/rbot/message.rb @@ -605,6 +605,22 @@ module Irc end end + # class to manager Ban list replies + class BanlistMessage < BasicUserMessage + # the bans + attr_accessor :bans + + def initialize(bot, server, source, target, message="") + super(bot, server, source, target, message) + @bans = [] + end + + def inspect + fields = ' bans=' << bans.inspect + super(fields) + end + end + class QuitMessage < BasicUserMessage attr_accessor :was_on def initialize(bot, server, source, target, message="") diff --git a/lib/rbot/rfc2812.rb b/lib/rbot/rfc2812.rb index 0b7e0786..bbc91bdf 100644 --- a/lib/rbot/rfc2812.rb +++ b/lib/rbot/rfc2812.rb @@ -967,6 +967,9 @@ module Irc # This is used by some messages to build lists of users that # will be delegated when the ENDOF... message is received @tmpusers = [] + + # Same as above, just for bans + @tmpbans = [] end # Clear the server and reset the user @@ -1180,6 +1183,17 @@ module Irc data[:users] = @tmpusers handle(:names, data) @tmpusers = Array.new + when RPL_BANLIST + data[:channel] = @server.channel(argv[1]) + data[:mask] = argv[2] + data[:by] = argv[3] + data[:at] = argv[4] + @tmpbans << data + when RPL_ENDOFBANLIST + data[:channel] = @server.channel(argv[1]) + data[:bans] = @tmpbans + handle(:banlist, data) + @tmpbans = Array.new when RPL_LUSERCLIENT # ":There are <integer> users and <integer> # services on <integer> servers" |