# HG changeset patch # User Charly COSTE # Date 1251550331 -7200 # Node ID 61491895c607b0ed7287b30cb04e89965dbd2371 # Parent 624c086b0a02307c5eb570051241510ab83bef4b Added bridge.hasParticipant() and fixed participant.changeNickname() Signed-off-by: Charly COSTE diff --git a/bridge.py b/bridge.py --- a/bridge.py +++ b/bridge.py @@ -161,6 +161,14 @@ class bridge: return participants_nicknames + def hasParticipant(self, nickname): + try: + self.getParticipant(nickname) + return True + except NoSuchParticipantException: + return False + + def removeParticipant(self, left_protocol, nickname, leave_message): """Remove the participant using nickname from the bridge. Raises a NoSuchParticipantException if nickname is not used in the bridge.""" diff --git a/participant.py b/participant.py --- 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()