diff participant.py @ 62:61491895c607

Added bridge.hasParticipant() and fixed participant.changeNickname() Signed-off-by: Charly COSTE <changaco@changaco.net>
author Charly COSTE <changaco@changaco.net>
date Sat, 29 Aug 2009 14:52:11 +0200
parents 624c086b0a02
children 71508f22edb4
line wrap: on
line diff
--- a/participant.py
+++ b/participant.py
@@ -123,8 +123,18 @@ class participant:
 			else:
 				self.nickname = newnick
 				if self.muc != None:
-					self.bridge.bot.xmpp_connections[newnick] = self.xmpp_c
-					self.bridge.bot.xmpp_connections.pop(oldnick)
+					for b in self.bridge.bot.bridges:
+						if b.hasParticipant(oldnick) and b.irc_server != self.bridge.irc_server:
+							self.muc.leave(message='Nickname change')
+							self.xmpp_c = None
+							self.bridge.bot.close_xmpp_connection(oldnick)
+							self.createDuplicateOnXMPP()
+							return
+					
+					if not self.bridge.bot.xmpp_connections.has_key(newnick):
+						self.bridge.bot.xmpp_connections.pop(oldnick)
+						self.bridge.bot.xmpp_connections[newnick] = self.xmpp_c
+					
 					self.muc.change_nick(newnick, status='From IRC', callback=self._xmpp_join_callback)
 				else:
 					self.createDuplicateOnXMPP()