changeset 135:922858915907

handle xmpp.muc.RemoteServerNotFound Signed-off-by: Charly COSTE <changaco@changaco.net>
author Charly COSTE <changaco@changaco.net>
date Sat, 16 Jan 2010 12:36:37 +0100
parents 931a5edc7971
children 7dc6a1764c4f
files bridge.py participant.py
diffstat 2 files changed, 11 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/bridge.py
+++ b/bridge.py
@@ -113,6 +113,13 @@ class Bridge:
 			self.stop(message='failed to connect to the IRC chan')
 	
 	
+	def _RemoteServerNotFound_handler(self):
+		server = xmpp.protocol.JID(self.xmpp_room_jid).getDomain()
+		bridges = self.bot.findBridges([server])
+		error_message = '[Warning] The MUC server '+server+' seems to be down, the bot will try to recreate all bridges related to this server in 5 minutes'
+		self.bot.restart_bridges_delayed(bridges, 300, error_message)
+	
+	
 	def _xmpp_join_callback(self, errors):
 		"""Called by muc._xmpp_presence_handler"""
 		if len(errors) == 0:
@@ -129,6 +136,8 @@ class Bridge:
 			for error in errors:
 				try:
 					raise error
+				except xmpp.muc.RemoteServerNotFound:
+					self._RemoteServerNotFound_handler()
 				except:
 					traceback.print_exc()
 			self.bot.error('[Error] failed to connect to the XMPP room of bridge "'+str(self)+'", stopping bridge', send_to_admins=True)
--- a/participant.py
+++ b/participant.py
@@ -99,6 +99,8 @@ class Participant:
 				except xmpp.muc.RoomIsFull:
 					self.bridge.bot.error('[Warning] XMPP MUC of bridge "'+str(self.bridge)+'" is full', send_to_admins=True)
 					self.bridge.say('[Warning] XMPP room is full')
+				except xmpp.muc.RemoteServerNotFound:
+					self.bridge._RemoteServerNotFound_handler()
 				
 				if isinstance(self.xmpp_c, xmpp.client.Client):
 					self.bridge.bot.close_xmpp_connection(self.nickname)