summaryrefslogtreecommitdiff
path: root/lib/rbot
diff options
context:
space:
mode:
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2006-08-20 21:53:02 +0000
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2006-08-20 21:53:02 +0000
commita0ab9e6d8022db22dd66412bb7a9087098e2faa2 (patch)
tree4573a576eb949a101277cc825280884779143201 /lib/rbot
parent0118b777ea7eeef59d4210ed7b32016517f5a9e0 (diff)
Improve NOTICE and PRIVMSG robustness when target is not a simple channel or user
Diffstat (limited to 'lib/rbot')
-rw-r--r--lib/rbot/rfc2812.rb20
1 files changed, 18 insertions, 2 deletions
diff --git a/lib/rbot/rfc2812.rb b/lib/rbot/rfc2812.rb
index e56c76bc..26549539 100644
--- a/lib/rbot/rfc2812.rb
+++ b/lib/rbot/rfc2812.rb
@@ -1095,7 +1095,15 @@ module Irc
# parse it yourself, or you can bind to 'MSG', 'PUBLIC',
# etc and get it all nicely split up for you.
- data[:target] = @server.user_or_channel(argv[0])
+ begin
+ data[:target] = @server.user_or_channel(argv[0])
+ rescue
+ # The previous may fail e.g. when the target is a server or something
+ # like that (e.g. $<mask>). In any of these cases, we just use the
+ # String as a target
+ # FIXME we probably want to explicitly check for the #<mask> $<mask>
+ data[:target] = argv[0]
+ end
data[:message] = argv[1]
handle(:privmsg, data)
@@ -1106,7 +1114,15 @@ module Irc
handle(:msg, data)
end
when 'NOTICE'
- data[:target] = @server.user_or_channel(argv[0])
+ begin
+ data[:target] = @server.user_or_channel(argv[0])
+ rescue
+ # The previous may fail e.g. when the target is a server or something
+ # like that (e.g. $<mask>). In any of these cases, we just use the
+ # String as a target
+ # FIXME we probably want to explicitly check for the #<mask> $<mask>
+ data[:target] = argv[0]
+ end
data[:message] = argv[1]
case data[:source]
when User