summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/rbot/ircbot.rb4
-rw-r--r--lib/rbot/message.rb12
-rw-r--r--lib/rbot/rfc2812.rb14
3 files changed, 24 insertions, 6 deletions
diff --git a/lib/rbot/ircbot.rb b/lib/rbot/ircbot.rb
index 6f7bed7d..1e1106de 100644
--- a/lib/rbot/ircbot.rb
+++ b/lib/rbot/ircbot.rb
@@ -757,6 +757,10 @@ class Bot
m.users = data[:users]
@plugins.delegate "names", m
}
+ @client[:nosuchtarget] = proc { |data|
+ m = NoSuchTargetMessage.new(self, server, server, data[:target], data[:message])
+ @plugins.delegate "nosuchtarget", m
+ }
@client[:error] = proc { |data|
raise ServerError, data[:message]
}
diff --git a/lib/rbot/message.rb b/lib/rbot/message.rb
index 64c4b6bb..e0cb753c 100644
--- a/lib/rbot/message.rb
+++ b/lib/rbot/message.rb
@@ -661,6 +661,18 @@ module Irc
class PartMessage < JoinMessage
end
+ # class to handle ERR_NOSUCHNICK and ERR_NOSUCHCHANNEL
+ class NoSuchTargetMessage < BasicUserMessage
+ # the channel or nick that was not found
+ attr_reader :target
+
+ def initialize(bot, server, source, target, message='')
+ super(bot, server, source, target, message)
+
+ @target = target
+ end
+ end
+
class UnknownMessage < BasicUserMessage
end
end
diff --git a/lib/rbot/rfc2812.rb b/lib/rbot/rfc2812.rb
index ee0d08d6..0b7e0786 100644
--- a/lib/rbot/rfc2812.rb
+++ b/lib/rbot/rfc2812.rb
@@ -1344,17 +1344,19 @@ module Irc
data[:channel].url=data[:url].dup
handle(:channel_url, data)
when ERR_NOSUCHNICK
- data[:nick] = argv[1]
- if user = @server.get_user(data[:nick])
+ data[:target] = argv[1]
+ data[:message] = argv[2]
+ handle(:nosuchtarget, data)
+ if user = @server.get_user(data[:target])
@server.delete_user(user)
end
- handle(:nosuchnick, data)
when ERR_NOSUCHCHANNEL
- data[:channel] = argv[1]
- if channel = @server.get_channel(data[:channel])
+ data[:target] = argv[1]
+ data[:message] = argv[2]
+ handle(:nosuchtarget, data)
+ if channel = @server.get_channel(data[:target])
@server.delete_channel(channel)
end
- handle(:nosuchchannel, data)
else
warning "Unknown message #{serverstring.inspect}"
handle(:unknown, data)