changeset 270:7640a3feddf5

catch xmpp.muc.NotConnected in Bridge._say_on_xmpp Signed-off-by: Charly COSTE <changaco@changaco.net>
author Charly COSTE <changaco@changaco.net>
date Tue, 23 Mar 2010 18:38:59 +0100
parents abef394fded5
children 18c9e8b823bc
files bridge.py
diffstat 1 files changed, 10 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/bridge.py
+++ b/bridge.py
@@ -389,7 +389,16 @@ class Bridge:
 	
 	
 	def _say_on_xmpp(self, message):
-		self.xmpp_room.say(message)
+		try:
+			self.xmpp_room.say(message)
+		except xmpp.muc.NotConnected:
+			# TODO: implement a message queue to improve this
+			if self.xmpp_room.state <= xmpp.muc.LEAVING:
+				self.bot.error(say_levels.debug, 'Ignoring xmpp.muc.NotConnected exception because we are leaving ('+str(self)+')', send_to_admins=True)
+			elif self.xmpp_room.state >= xmpp.muc.JOINING:
+				self.bot.error(say_levels.debug, 'Dropping a message because we are not in the XMPP room yet ('+str(self)+')', send_to_admins=True)
+			else:
+				self.bot.restart(message='Lost bot XMPP connection')
 	
 	
 	def show_participants_list_on(self, protocols=[]):