# HG changeset patch # User Charly COSTE # Date 1266765565 -3600 # Node ID e4ceefab8ba5f288c19c19b002860343453207ec # Parent 5af6c828c606df73b86eef783f3c402c610a5068 fixed Bot.restart_bridges_delayed(), don't send the message to admins more than once Signed-off-by: Charly COSTE diff --git a/bot.py b/bot.py --- a/bot.py +++ b/bot.py @@ -865,23 +865,25 @@ class Bot(threading.Thread): def restart_bridges_delayed(self, bridges, delay, error, protocol='xmpp'): if len(bridges) > 0: + found = False error[1] += '\nThese bridges will be stopped:' for b in bridges: - error[1] += '\n'+str(b) - if protocol == 'xmpp': leave_message = 'Could not connect to the MUC server ('+b.xmpp_room_jid+')' else: leave_message = 'Could not connect to the IRC server ('+b.irc_connection._server_str()+')' - if not hasattr(b, 'reconnecting'): + if not b.reconnecting: + found = True + error[1] += '\n'+str(b) leave_message += 'will try to recreate the bridge in '+str(delay)+' seconds' b.reconnecting = True self.irc.execute_delayed(delay, b.init2) b.stop(message=leave_message, log=False) - self.error(error[0], error[1], send_to_admins=True) + if found: + self.error(error[0], error[1], send_to_admins=True) def stop(self, message='Stopping bot'): diff --git a/bridge.py b/bridge.py --- a/bridge.py +++ b/bridge.py @@ -47,6 +47,7 @@ class Bridge: self.xmpp_room_jid = xmpp_room_jid self.say_level = say_level self.participants = [] + self.reconnecting = False if mode not in self.__class__.modes: raise Exception('[Error] "'+mode+'" is not a correct value for a bridge\'s "mode" attribute') self.mode = mode @@ -57,6 +58,8 @@ class Bridge: def init2(self): + self.reconnecting = False + # Join XMPP room self.xmpp_room = xmpp.muc(self.xmpp_room_jid) self.xmpp_room.join(self.bot.xmpp_c, self.bot.nickname, callback=self._xmpp_join_callback)