comparison bot.py @ 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 c2a8586e64b5
children 66ed2dcdc4d1
comparison
equal deleted inserted replaced
194:5af6c828c606 195:e4ceefab8ba5
863 self.error(-1, 'Bot restarted.', send_to_admins=True) 863 self.error(-1, 'Bot restarted.', send_to_admins=True)
864 864
865 865
866 def restart_bridges_delayed(self, bridges, delay, error, protocol='xmpp'): 866 def restart_bridges_delayed(self, bridges, delay, error, protocol='xmpp'):
867 if len(bridges) > 0: 867 if len(bridges) > 0:
868 found = False
868 error[1] += '\nThese bridges will be stopped:' 869 error[1] += '\nThese bridges will be stopped:'
869 for b in bridges: 870 for b in bridges:
870 error[1] += '\n'+str(b)
871
872 if protocol == 'xmpp': 871 if protocol == 'xmpp':
873 leave_message = 'Could not connect to the MUC server ('+b.xmpp_room_jid+')' 872 leave_message = 'Could not connect to the MUC server ('+b.xmpp_room_jid+')'
874 else: 873 else:
875 leave_message = 'Could not connect to the IRC server ('+b.irc_connection._server_str()+')' 874 leave_message = 'Could not connect to the IRC server ('+b.irc_connection._server_str()+')'
876 875
877 if not hasattr(b, 'reconnecting'): 876 if not b.reconnecting:
877 found = True
878 error[1] += '\n'+str(b)
878 leave_message += 'will try to recreate the bridge in '+str(delay)+' seconds' 879 leave_message += 'will try to recreate the bridge in '+str(delay)+' seconds'
879 b.reconnecting = True 880 b.reconnecting = True
880 self.irc.execute_delayed(delay, b.init2) 881 self.irc.execute_delayed(delay, b.init2)
881 882
882 b.stop(message=leave_message, log=False) 883 b.stop(message=leave_message, log=False)
883 884
884 self.error(error[0], error[1], send_to_admins=True) 885 if found:
886 self.error(error[0], error[1], send_to_admins=True)
885 887
886 888
887 def stop(self, message='Stopping bot'): 889 def stop(self, message='Stopping bot'):
888 self.error(-1, message, send_to_admins=True) 890 self.error(-1, message, send_to_admins=True)
889 for bridge in self.bridges: 891 for bridge in self.bridges: