changeset 247:303e571bc104

catch ServerNotConnectedError in Participant.say_on_irc_to Signed-off-by: Charly COSTE <changaco@changaco.net>
author Charly COSTE <changaco@changaco.net>
date Mon, 08 Mar 2010 18:47:07 +0100
parents 5e65f52be453
children 234e8ca6a10c
files participant.py
diffstat 1 files changed, 9 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/participant.py
+++ b/participant.py
@@ -305,9 +305,17 @@ class Participant:
 	
 	
 	def say_on_irc_to(self, to, message):
+		error = False
 		if isinstance(self.irc_connection, ServerConnection):
-			self.irc_connection.privmsg(to, message)
+			try:
+				self.irc_connection.privmsg(to, message)
+			except ServerNotConnectedError:
+				self.irc_connection.connect()
+				error = True
 		elif not isinstance(self.xmpp_c, xmpp.client.Client):
+			error = True
+		
+		if error:
 			if self.bridge.mode not in ['normal', 'bypass']:
 				self.bridge.get_participant(to).say_on_xmpp_to(self.nickname, 'XIB error: Sorry but cross-protocol private messages are disabled in '+self.bridge.mode+' mode.')
 			else: