# HG changeset patch # User Charly COSTE # Date 1263418020 -3600 # Node ID 75a03f10a86376e9c3ed75a4db2938c175b056f6 # Parent 9e90e15913a70364b8851c478bab3f346751ac53 Code refactoring (new method participant.set_both_sides()) Signed-off-by: Charly COSTE diff --git a/bridge.py b/bridge.py --- a/bridge.py +++ b/bridge.py @@ -145,17 +145,7 @@ class bridge: if irc_id: p.irc_connection.irc_id = irc_id return p - self.bot.error('===> Debug: "'+nickname+'" is on both sides of bridge "'+str(self)+'"', debug=True) - self.say('[Warning] The nickname "'+nickname+'" is used on both sides of the bridge, please avoid that if possible') - if isinstance(p.irc_connection, ServerConnection): - p.irc_connection.close('') - if p.irc_connection != 'both': - p.irc_connection = 'both' - if isinstance(p.muc, xmpp.muc): - p.muc.leave('') - self.bot.close_xmpp_connection(p.nickname) - if p.xmpp_c != 'both': - p.xmpp_c = 'both' + p.set_both_sides() return p except NoSuchParticipantException: pass diff --git a/participant.py b/participant.py --- a/participant.py +++ b/participant.py @@ -170,6 +170,20 @@ class participant: self.irc_connection = error + def set_both_sides(self): + self.bridge.bot.error('===> Debug: "'+self.nickname+'" is on both sides of bridge "'+str(self.bridge)+'"', debug=True) + self.bridge.say('[Warning] The nickname "'+self.nickname+'" is used on both sides of the bridge, please avoid that if possible') + if isinstance(self.irc_connection, ServerConnection): + self.irc_connection.close('') + if self.irc_connection != 'both': + self.irc_connection = 'both' + if isinstance(self.muc, xmpp.muc): + self.muc.leave('') + self.bridge.bot.close_xmpp_connection(self.nickname) + if self.xmpp_c != 'both': + self.xmpp_c = 'both' + + def changeNickname(self, newnick, on_protocol): """Change participant's nickname."""