changeset 236:8acbfda313b9

use ServerConnection.nickname instead of .real_nickname in most cases, make sure we put a string in .real_nickname Signed-off-by: Charly COSTE <changaco@changaco.net>
author Charly COSTE <changaco@changaco.net>
date Mon, 08 Mar 2010 10:32:50 +0100
parents 533a5db79389
children 71c23e30cd6c
files bot.py irclib.py
diffstat 2 files changed, 8 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/bot.py
+++ b/bot.py
@@ -559,25 +559,25 @@ class Bot(threading.Thread):
 			bridge = self.get_bridge(irc_room=event.arguments()[0], irc_server=connection.server)
 			
 			if event.eventtype() == 'cannotsendtochan':
-				if connection.real_nickname == self.nickname:
+				if connection.nickname == self.nickname:
 					bridge._join_irc_failed(event.eventtype())
 				else:
-					p = bridge.get_participant(connection.real_nickname)
+					p = bridge.get_participant(connection.nickname)
 					p._close_irc_connection(event.eventtype())
 					p.irc_connection = event.eventtype()
 			
 			elif event.eventtype() == 'notonchannel':
-				if connection.real_nickname == self.nickname:
+				if connection.nickname == self.nickname:
 					bridge.restart(message='Restarting bridge because we received the IRC event '+event.eventtype())
 				else:
-					p = bridge.get_participant(connection.real_nickname)
+					p = bridge.get_participant(connection.nickname)
 					p.irc_connection.join(bridge.irc_room)
 			
 			return
 		
 		
 		# Ignore events not received on bot connection
-		if connection.real_nickname != self.nickname:
+		if connection.nickname != self.nickname:
 			self.error(1, 'ignoring IRC '+event.eventtype()+' not received on bridge connection', debug=True)
 			return
 		
--- a/irclib.py
+++ b/irclib.py
@@ -298,7 +298,7 @@ class IRC:
                 else:
                     self.bot.error(say_levels.error, 'Unkonwn exception on IRC thread:\n'+str(e.args))
                     continue
-                if c.real_nickname == self.bot.nickname:
+                if c.nickname == self.bot.nickname:
                     self.bot.restart(message='Lost bot IRC connection')
                 else:
                     c.disconnect(volontary=True)
@@ -780,8 +780,8 @@ class ServerConnection(Connection):
 
                 if command in ["nick", "welcome"]:
                     self.logged_in = True
-                    self.real_nickname = target
-                    if self.new_nickname:
+                    if self.new_nickname and isinstance(target, basestring):
+                        self.real_nickname = target
                         if self.new_nickname != target:
                             if len(self.new_nickname) > len(target):
                                 self._handle_event(Event('nicknametoolong', None, None, None))