]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/commitdiff
More fixes for nickname handling on connection
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Sun, 18 Feb 2007 10:10:17 +0000 (10:10 +0000)
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Sun, 18 Feb 2007 10:10:17 +0000 (10:10 +0000)
lib/rbot/irc.rb
lib/rbot/ircbot.rb
lib/rbot/rfc2812.rb

index 3febc82a8c354b908401055b0e7ab4d0296f6cc0..a0ffbd912f297de554e66936139dadf5eeda20db 100644 (file)
@@ -1370,6 +1370,7 @@ module Irc
     def clear\r
       reset_lists\r
       reset_capabilities\r
+      @hostname = @version = @usermodes = @chanmodes = nil\r
     end\r
 \r
     # This method is used to parse a 004 RPL_MY_INFO line\r
index c87b909b92326e86cd79f4ab053543f5227f6dc4..a95301dd8aaf712b8c1ff042a2af9d6ea12ac9a2 100644 (file)
@@ -513,11 +513,19 @@ class IrcBot
       }
     }
     @client[:nicktaken] = proc { |data|
-      nickchg "#{data[:nick]}_"
+      new = "#{data[:nick]}_" 
+      nickchg new
+      # If we're setting our nick at connection because our choice was taken,
+      # we have to fix our nick manually, because there will be no NICK message
+      # yo inform us that our nick has been changed.
+      if data[:target] == '*'
+        debug "setting my connection nick to #{new}"
+        nick = new
+      end
       @plugins.delegate "nicktaken", data[:nick]
     }
     @client[:badnick] = proc {|data|
-      warning "bad nick (#{data[:nick]})"
+      arning "bad nick (#{data[:nick]})"
     }
     @client[:ping] = proc {|data|
       sendq "PONG #{data[:pingid]}"
index 1888f75f8dd9a13e8d80102576c98551cf085f9d..cc7fd7e797e24589faa6e0068723605fd59851a7 100644 (file)
@@ -917,12 +917,12 @@ module Irc
       params.scan(/(?!:)(\S+)|:(.*)/) { argv << ($1 || $2) } if params
 
       if command =~ /^(\d+)$/ # Numeric replies
-       data[:nick] = argv[0]
+       data[:target] = argv[0]
         # A numeric reply /should/ be directed at the client, except when we're connecting with a used nick, in which case
         # it's directed at '*'
-        not_us = !([@client.nick, '*'].include?(data[:nick]))
+        not_us = !([@client.nick, '*'].include?(data[:target]))
         if not_us
-          warning "Server reply #{serverstring.inspect} directed at #{data[:nick]} instead of client (#{@client.nick})"
+          warning "Server reply #{serverstring.inspect} directed at #{data[:target]} instead of client (#{@client.nick})"
         end
 
         num=command.to_i
@@ -932,13 +932,13 @@ module Irc
           # <nick>!<user>@<host>"
           if not_us
             warning "Server thinks client (#{@client.inspect}) has a different nick"
-            @client.nick = data[:nick]
+            @client.nick = data[:target]
           end
           if argv[1] =~ /(\S+)(?:!(\S+?))?@(\S+)/
             nick = $1
             user = $2
             host = $2
-            warning "Welcome message nick mismatch (#{nick} vs #{data[:nick]})" if nick != data[:nick]
+            warning "Welcome message nick mismatch (#{nick} vs #{data[:target]})" if nick != data[:target]
             @client.user = user if user
             @client.host = host if host
           end