comparison bot.py @ 177:d1686164b9e3

improved Bot.restart_bridges_delayed(), it can now be used when the IRC server is the problem Signed-off-by: Charly COSTE <changaco@changaco.net>
author Charly COSTE <changaco@changaco.net>
date Mon, 08 Feb 2010 18:53:21 +0100
parents 64a0e9636ae6
children f6c6708c6c0e
comparison
equal deleted inserted replaced
176:bca516d04bdb 177:d1686164b9e3
811 b.init2() 811 b.init2()
812 812
813 self.error('Bot restarted.', send_to_admins=True) 813 self.error('Bot restarted.', send_to_admins=True)
814 814
815 815
816 def restart_bridges_delayed(self, bridges, delay, error_message): 816 def restart_bridges_delayed(self, bridges, delay, error_message, protocol='xmpp'):
817 if len(bridges) > 0: 817 if len(bridges) > 0:
818 error_message += '\nThese bridges will be stopped:' 818 error_message += '\nThese bridges will be stopped:'
819 for b in bridges: 819 for b in bridges:
820 error_message += '\n'+str(b) 820 error_message += '\n'+str(b)
821 if hasattr(b, 'reconnecting'): 821
822 leave_message = 'MUC server seems to be down' 822 if protocol == 'xmpp':
823 leave_message = 'Could not connect to the MUC server ('+b.xmpp_room_jid+')'
823 else: 824 else:
824 leave_message = 'MUC server seems to be down, will try to recreate the bridge in '+str(delay)+' seconds' 825 leave_message = 'Could not connect to the IRC server ('+b.irc_connection._server_str()+')'
825 self.reconnecting = True 826
827 if not hasattr(b, 'reconnecting'):
828 leave_message += 'will try to recreate the bridge in '+str(delay)+' seconds'
829 b.reconnecting = True
826 self.irc.execute_delayed(delay, b.init2) 830 self.irc.execute_delayed(delay, b.init2)
831
827 b.stop(message=leave_message) 832 b.stop(message=leave_message)
828 833
829 self.error(error_message, send_to_admins=True) 834 self.error(error_message, send_to_admins=True)
830 835
831 836