X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=lib%2Frbot%2Frfc2812.rb;h=0839d1d52593db514d4458a92c19b57c4c6c7b1a;hb=2e73cfeec6c9f549f216009570a29b12b927a99e;hp=bbc91bdf67cb19efb5e653565d0822d21f3c22bd;hpb=a1db6671fb3819b58bcc1f0494b86d3a32df747f;p=user%2Fhenk%2Fcode%2Fruby%2Frbot.git diff --git a/lib/rbot/rfc2812.rb b/lib/rbot/rfc2812.rb index bbc91bdf..0839d1d5 100644 --- a/lib/rbot/rfc2812.rb +++ b/lib/rbot/rfc2812.rb @@ -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)