]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/blobdiff - lib/rbot/rfc2812.rb
Utils.safe_save does a 'safe' saving (save to tempfile, move tempfile to new location)
[user/henk/code/ruby/rbot.git] / lib / rbot / rfc2812.rb
index af88d4be77d792d0062a260de727bca4f716f0b8..26549539ef5dd3eee903edda46ad3ebdebe6a8ff 100644 (file)
@@ -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
@@ -1140,6 +1156,7 @@ module Irc
         data[:message] = argv[0]
         data[:was_on] = @server.channels.inject(ChannelList.new) { |list, ch|
           list << ch if ch.users.include?(data[:source])
+         list
         }
 
         @server.delete_user(data[:source])
@@ -1152,7 +1169,7 @@ module Irc
         handle(:join, data)
       when 'TOPIC'
         data[:channel] = @server.channel(argv[0])
-        data[:topic] = ChannelTopic.new(argv[1], data[:source], Time.new)
+        data[:topic] = Channel::Topic.new(argv[1], data[:source], Time.new)
         data[:channel].topic.replace(data[:topic])
 
         handle(:changetopic, data)