summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2011-05-03 19:22:51 +0200
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2011-05-03 19:22:51 +0200
commit88590b85a4dcd20a91b9844dfff353996bc81119 (patch)
tree74ab949cebdcc6b0f21c8f37537c4538dee435f9 /lib
parent5079554263a9a2c8c661c1c8728b4ce1a0bbd05a (diff)
Preliminary support for the LIST command
Diffstat (limited to 'lib')
-rw-r--r--lib/rbot/ircbot.rb5
-rw-r--r--lib/rbot/message.rb15
-rw-r--r--lib/rbot/rfc2812.rb15
3 files changed, 35 insertions, 0 deletions
diff --git a/lib/rbot/ircbot.rb b/lib/rbot/ircbot.rb
index 76541882..a48251c2 100644
--- a/lib/rbot/ircbot.rb
+++ b/lib/rbot/ircbot.rb
@@ -732,6 +732,11 @@ class Bot
m = WhoisMessage.new(self, server, source, target, data[:whois])
@plugins.delegate "whois", m
}
+ @client[:list] = proc {|data|
+ source = data[:source]
+ m = ListMessage.new(self, server, source, source, data[:list])
+ @plugins.delegate "irclist", m
+ }
@client[:join] = proc {|data|
m = JoinMessage.new(self, server, data[:source], data[:channel], data[:message])
sendq("MODE #{data[:channel]}", nil, 0) if m.address?
diff --git a/lib/rbot/message.rb b/lib/rbot/message.rb
index 31508879..ed533e9b 100644
--- a/lib/rbot/message.rb
+++ b/lib/rbot/message.rb
@@ -612,6 +612,21 @@ module Irc
end
end
+ # class to manage LIST replies
+ class ListMessage < BasicUserMessage
+ attr_accessor :list
+ def initialize(bot, server, source, target, list=Hash.new)
+ super(bot, server, source, target, "")
+ @list = []
+ end
+
+ def inspect
+ fields = ' list=' << list.inspect
+ super(fields)
+ end
+ end
+
+
# class to manage NAME replies
class NamesMessage < BasicUserMessage
attr_accessor :users
diff --git a/lib/rbot/rfc2812.rb b/lib/rbot/rfc2812.rb
index fb70619c..cd32135a 100644
--- a/lib/rbot/rfc2812.rb
+++ b/lib/rbot/rfc2812.rb
@@ -946,6 +946,9 @@ module Irc
ERR_NOSERVICEHOST=492
RPL_DATASTR=290
+ # A structure to hold LIST data, in the Irc namespace
+ ListData = Struct.new :channel, :users, :topic
+
# Implements RFC 2812 and prior IRC RFCs.
#
# Clients should register Proc{}s to handle the various server events, and
@@ -1344,6 +1347,18 @@ module Irc
@whois[:channels] << [chan, modes]
end
+ when RPL_LISTSTART
+ # ignore
+ when RPL_LIST
+ @list ||= Hash.new
+ chan = argv[1]
+ users = argv[2]
+ topic = argv[3]
+ @list[chan] = ListData.new(chan, users, topic)
+ when RPL_LISTEND
+ @list ||= Hash.new
+ data[:list] = @list
+ handle(:list, data)
when RPL_CHANNELMODEIS
parse_mode(serverstring, argv[1..-1], data)
handle(:mode, data)