summaryrefslogtreecommitdiff
path: root/lib/rbot
diff options
context:
space:
mode:
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2008-08-11 09:00:18 +0200
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2008-08-11 09:05:23 +0200
commitdaec89e4c32c683674720ab458902654528a5f47 (patch)
tree9e95481f60c6fa3c039c073dbdb0694837832fb6 /lib/rbot
parent0bcb22bf7f4574a9697dddbacc0a23dae618b5a0 (diff)
rfc2812: handle ERR_NOSUCHNICK and ERR_NOSUCHCHANNEL
Delete the corresponding user/channel from the server list (if present), and notify the client about the error.
Diffstat (limited to 'lib/rbot')
-rw-r--r--lib/rbot/rfc2812.rb13
1 files changed, 12 insertions, 1 deletions
diff --git a/lib/rbot/rfc2812.rb b/lib/rbot/rfc2812.rb
index 38ce64ca..42b8daf7 100644
--- a/lib/rbot/rfc2812.rb
+++ b/lib/rbot/rfc2812.rb
@@ -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)