changeset 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 bca516d04bdb
children 891195c47350
files bot.py
diffstat 1 files changed, 10 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/bot.py
+++ b/bot.py
@@ -813,17 +813,22 @@ class Bot(threading.Thread):
 		self.error('Bot restarted.', send_to_admins=True)
 	
 	
-	def restart_bridges_delayed(self, bridges, delay, error_message):
+	def restart_bridges_delayed(self, bridges, delay, error_message, protocol='xmpp'):
 		if len(bridges) > 0:
 			error_message += '\nThese bridges will be stopped:'
 			for b in bridges:
 				error_message += '\n'+str(b)
-				if hasattr(b, 'reconnecting'):
-					leave_message = 'MUC server seems to be down'
+				
+				if protocol == 'xmpp':
+					leave_message = 'Could not connect to the MUC server ('+b.xmpp_room_jid+')'
 				else:
-					leave_message = 'MUC server seems to be down, will try to recreate the bridge in '+str(delay)+' seconds'
-					self.reconnecting = True
+					leave_message = 'Could not connect to the IRC server ('+b.irc_connection._server_str()+')'
+				
+				if not hasattr(b, 'reconnecting'):
+					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)
 		
 		self.error(error_message, send_to_admins=True)