]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/commitdiff
rfc2812: handle ERR_NOSUCHNICK and ERR_NOSUCHCHANNEL
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Mon, 11 Aug 2008 07:00:18 +0000 (09:00 +0200)
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Mon, 11 Aug 2008 07:05:23 +0000 (09:05 +0200)
Delete the corresponding user/channel from the server list (if present),
and notify the client about the error.

lib/rbot/rfc2812.rb

index 38ce64ca47ad60da53358fce1822bd25fa85aea8..42b8daf7a0e979e37b9c2d75b1515bdda026779a 100644 (file)
@@ -981,7 +981,6 @@ module Irc
     #
     # ==server events currently supported:
     #
-    # TODO handle errors ERR_NOSUCHNICK, ERR_NOSUCHCHANNEL
     # TODO handle errors ERR_CHANOPRIVSNEEDED, ERR_CANNOTSENDTOCHAN
     #
     # welcome::     server welcome message on connect
@@ -1351,6 +1350,18 @@ module Irc
           data[:url] = argv[2]
           @server.channel(data[:channel]).url=data[:url].dup
           handle(:channel_url, data)
+        when ERR_NOSUCHNICK
+          data[:nick] = argv[1]
+          if user = @server.get_user(data[:nick])
+            @server.delete_user(user)
+          end
+          handle(:nosuchnick, data)
+        when ERR_NOSUCHCHANNEL
+          data[:channel] = argv[1]
+          if channel = @server.get_channel(data[:channel])
+            @server.delete_channel(channel)
+          end
+          handle(:nosuchchannel, data)
         else
           warning "Unknown message #{serverstring.inspect}"
           handle(:unknown, data)