]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/blobdiff - lib/rbot/rfc2812.rb
Ahem. I should remember to test things ''before'' committing, not after. Fix COREDIR...
[user/henk/code/ruby/rbot.git] / lib / rbot / rfc2812.rb
index dee2920f3db9d6f3699b4b9dca4e05235ebb13c8..8a83ec889155bc5a5a8c334ddf7781fda2c3b6de 100644 (file)
@@ -888,7 +888,7 @@ module Irc
       if prefix != nil
         data[:source] = prefix
         if prefix =~ /^(\S+)!(\S+)$/
-          data[:source] = @server.user($1)
+          data[:source] = @server.user(prefix)
         else
           if @server.hostname && @server.hostname != data[:source]
             warning "Unknown origin #{data[:source]} for message\n#{serverstring.inspect}"
@@ -922,6 +922,7 @@ module Irc
             data[:nick] = $2
             data[:address] = $3
             @client = @server.user(data[:netmask])
+            set = true
           when /Welcome to the Internet Relay Network\s(\S+)/
             data[:nick] = $1
           when /Welcome.*\s+(\S+)$/
@@ -929,7 +930,7 @@ module Irc
           when /^(\S+)$/
             data[:nick] = $1
           end
-          @user ||= @server.user(data[:nick])
+          @client = @server.user(data[:nick]) unless set
           handle(:welcome, data)
         when RPL_YOURHOST
           # "Your host is <servername>, running version <ver>"
@@ -954,7 +955,7 @@ module Irc
           # PREFIX=(ov)@+ CASEMAPPING=ascii CAPAB IRCD=dancer :are available
           # on this server"
           #
-          @server.parse_isupport(params.split(' ', 2).last)
+          @server.parse_isupport(argv[1..-2].join(' '))
           handle(:isupport, data)
         when ERR_NICKNAMEINUSE
           # "* <nick> :Nickname is already in use"
@@ -1016,9 +1017,9 @@ module Irc
 
           users.each { |ar|
             u = @server.user(ar[0])
-            chan.users << u
+            chan.users << u unless chan.users.include?(u)
             if ar[1]
-              m = @server.supports[:prefix][:prefixes].index(ar[1])
+              m = @server.supports[:prefix][:prefixes].index(ar[1].to_sym)
               m = @server.supports[:prefix][:modes][m]
               chan.mode[m.to_sym].set(u)
             end
@@ -1098,7 +1099,7 @@ module Irc
         handle(:privmsg, data)
 
         # Now we split it
-        if(data[:target].class <= Channel)
+        if data[:target].kind_of?(Channel)
           handle(:public, data)
         else
           handle(:msg, data)
@@ -1151,7 +1152,7 @@ module Irc
       when 'TOPIC'
         data[:channel] = @server.channel(argv[0])
         data[:topic] = ChannelTopic.new(argv[1], data[:source], Time.new)
-        data[:channel].topic = data[:topic]
+        data[:channel].topic.replace(data[:topic])
 
         handle(:changetopic, data)
       when 'INVITE'
@@ -1166,7 +1167,9 @@ module Irc
 
         data[:newnick] = argv[0]
         data[:oldnick] = data[:source].nick.dup
-        data[:source].nick = data[:nick]
+        data[:source].nick = data[:newnick]
+
+        debug "#{data[:oldnick]} (now #{data[:newnick]}) was on #{data[:is_on].join(', ')}"
 
         handle(:nick, data)
       when 'MODE'
@@ -1189,12 +1192,13 @@ module Irc
           data[:modes] = []
           # array of indices in data[:modes] where parameters
           # are needed
-          who_want_params = []
+          who_wants_params = []
 
           argv[1..-1].each { |arg|
             setting = arg[0].chr
             if "+-".include?(setting)
-              arg[1..-1].each_byte { |m|
+              arg[1..-1].each_byte { |b|
+                m = b.chr
                 case m.to_sym
                 when *@server.supports[:chanmodes][:typea]
                   data[:modes] << [setting + m]