diff 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
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'):