Mercurial > xib
changeset 195:e4ceefab8ba5
fixed Bot.restart_bridges_delayed(), don't send the message to admins more than once
Signed-off-by: Charly COSTE <changaco@changaco.net>
author | Charly COSTE <changaco@changaco.net> |
---|---|
date | Sun, 21 Feb 2010 16:19:25 +0100 |
parents | 5af6c828c606 |
children | 4011838e098e |
files | bot.py bridge.py |
diffstat | 2 files changed, 9 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- 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'):
--- 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)