]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/blobdiff - lib/rbot/rfc2812.rb
test: fix shadowed test method
[user/henk/code/ruby/rbot.git] / lib / rbot / rfc2812.rb
index bbc91bdf67cb19efb5e653565d0822d21f3c22bd..0839d1d52593db514d4458a92c19b57c4c6c7b1a 100644 (file)
@@ -6,6 +6,9 @@
 # This module defines the Irc::Client class, a class that can handle and
 # dispatch messages based on RFC 2821 (Internet Relay Chat: Client Protocol)
 
+class ServerMessageParseError < ServerError
+end
+
 module Irc
   # - The server sends Replies 001 to 004 to a user upon
   #   successful registration.
@@ -946,6 +949,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
@@ -1030,7 +1036,7 @@ module Irc
       data[:serverstring] = serverstring
 
       unless serverstring.chomp =~ /^(:(\S+)\s)?(\S+)(\s(.*))?$/
-        raise "Unparseable Server Message!!!: #{serverstring.inspect}"
+        raise ServerMessageParseError, (serverstring.chomp rescue serverstring)
       end
 
       prefix, command, params = $2, $3, $5
@@ -1331,7 +1337,7 @@ module Irc
         when RPL_WHOISCHANNELS
           @whois ||= Hash.new
           @whois[:nick] = argv[1]
-          @whois[:channels] = []
+          @whois[:channels] ||= []
           user = @server.user(@whois[:nick])
           argv[-1].split.each do |prechan|
             pfx = prechan.scan(/[#{@server.supports[:prefix][:prefixes].join}]/)
@@ -1344,6 +1350,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)