Mercurial > xib
comparison participant.py @ 29:a694ffe6a973
Fixed nickname change.
Signed-off-by: Charly COSTE <changaco@changaco.net>
author | Charly COSTE <changaco@changaco.net> |
---|---|
date | Fri, 21 Aug 2009 01:27:41 +0200 |
parents | 1691ab4d131f |
children | 5afa22125334 |
comparison
equal
deleted
inserted
replaced
28:6481b9bb95aa | 29:a694ffe6a973 |
---|---|
56 try: | 56 try: |
57 raise error | 57 raise error |
58 except xmpp.muc.NicknameConflict: | 58 except xmpp.muc.NicknameConflict: |
59 self.bridge.bot.error('===> Debug: "'+self.nickname+'" is already used in the XMPP MUC or reserved on the XMPP server of bridge "'+str(self.bridge)+'"', debug=True) | 59 self.bridge.bot.error('===> Debug: "'+self.nickname+'" is already used in the XMPP MUC or reserved on the XMPP server of bridge "'+str(self.bridge)+'"', debug=True) |
60 self.bridge.say('[Warning] The nickname "'+self.nickname+'" is used on both rooms or reserved on the XMPP server, please avoid that if possible') | 60 self.bridge.say('[Warning] The nickname "'+self.nickname+'" is used on both rooms or reserved on the XMPP server, please avoid that if possible') |
61 self.muc.leave('Nickname change') | |
61 self.bridge.bot.close_xmpp_connection(self.nickname) | 62 self.bridge.bot.close_xmpp_connection(self.nickname) |
62 self.xmpp_c = None | 63 self.xmpp_c = None |
63 | 64 |
64 | 65 |
65 def createDuplicateOnIRC(self): | 66 def createDuplicateOnIRC(self): |
92 self.irc_connection.close('') | 93 self.irc_connection.close('') |
93 self.irc_connection = None | 94 self.irc_connection = None |
94 | 95 |
95 | 96 |
96 def changeNickname(self, newnick, on_protocol): | 97 def changeNickname(self, newnick, on_protocol): |
98 """Change participant's nickname.""" | |
99 | |
100 oldnick = self.nickname | |
101 | |
97 if self.protocol == 'xmpp': | 102 if self.protocol == 'xmpp': |
98 if on_protocol == 'xmpp': | 103 if on_protocol == 'xmpp': |
99 self.bridge.removeParticipant('irc', self.nickname, '') | 104 self.bridge.removeParticipant('irc', self.nickname, '') |
100 self.bridge.addParticipant('irc', newnick) | 105 self.bridge.addParticipant('irc', newnick) |
101 | 106 |
112 self.bridge.addParticipant('xmpp', newnick) | 117 self.bridge.addParticipant('xmpp', newnick) |
113 | 118 |
114 else: | 119 else: |
115 self.nickname = newnick | 120 self.nickname = newnick |
116 if self.muc != None: | 121 if self.muc != None: |
122 self.bridge.bot.xmpp_connections[newnick] = self.xmpp_c | |
123 self.bridge.bot.close_xmpp_connection(oldnick) | |
117 self.muc.change_nick(newnick, status='From IRC', callback=self._xmpp_join_callback) | 124 self.muc.change_nick(newnick, status='From IRC', callback=self._xmpp_join_callback) |
118 else: | 125 else: |
119 self.createDuplicateOnXMPP() | 126 self.createDuplicateOnXMPP() |
120 | 127 |
121 | 128 |