changeset 26:1691ab4d131f

Fixed participant's "say" functions. Signed-off-by: Charly COSTE <changaco@changaco.net>
author Charly COSTE <changaco@changaco.net>
date Fri, 21 Aug 2009 00:25:42 +0200
parents a9066c416533
children 9b7a628ca612
files participant.py
diffstat 1 files changed, 19 insertions(+), 25 deletions(-) [+]
line wrap: on
line diff
--- a/participant.py
+++ b/participant.py
@@ -120,53 +120,47 @@ class participant:
 	
 	
 	def sayOnIRC(self, message):
-		if self.protocol == 'irc':
-			raise Exception('[Internal Error] "'+self.nickname+'" comes from IRC')
-		
 		try:
-			if self.irc_connection == None:
+			if self.irc_connection != None:
+				self.irc_connection.privmsg(self.bridge.irc_room, message)
+			elif self.xmpp_c == None:
 				self.bridge.irc_connection.privmsg(self.bridge.irc_room, '<'+self.nickname+'> '+message)
-			else:
-				self.irc_connection.privmsg(self.bridge.irc_room, message)
 		except EncodingException:
 			self.bridge.say('[Warning] "'+self.nickname+'" is sending messages using an unknown encoding')
 	
 	
 	def sayOnIRCTo(self, to, message):
-		if self.protocol == 'irc':
-			raise Exception('[Internal Error] "'+self.nickname+'" comes from IRC')
-		
-		if self.irc_connection == None:
-			if self.bridge.mode != 'normal':
-				self.bridge.getParticipant(to).sayOnXMPPTo(self.nickname, 'Sorry but cross-protocol private messages are disabled in limited mode.')
-			else:
-				self.bridge.getParticipant(to).sayOnXMPPTo(self.nickname, 'Sorry but you cannot send cross-protocol private messages because I don\'t have an IRC duplicate with your nickname.')
-		else:
+		if self.irc_connection != None:
 			try:
 				self.irc_connection.privmsg(to, message)
 			except EncodingException:
 				self.bridge.say('[Warning] "'+self.nickname+'" is sending messages using an unknown encoding')
+		elif self.xmpp_c == None:
+			if self.bridge.mode != 'normal':
+				self.bridge.getParticipant(to).sayOnXMPPTo(self.nickname, 'Sorry but cross-protocol private messages are disabled in '+self.bridge.mode+' mode.')
+			else:
+				self.bridge.getParticipant(to).sayOnXMPPTo(self.nickname, 'Sorry but you cannot send cross-protocol private messages because I don\'t have an IRC duplicate with your nickname.')
 	
 	
 	def sayOnXMPP(self, message):
-		if self.protocol == 'xmpp':
-			raise Exception('[Internal Error] "'+self.nickname+'" comes from XMPP')
-		
 		try:
-			if self.xmpp_c == None:
+			if self.xmpp_c != None:
+				self.muc.say(auto_decode(message))
+			elif self.irc_connection == None:
 				self.bridge.xmpp_room.say('<'+self.nickname+'> '+auto_decode(message))
-			else:
-				self.muc.say(auto_decode(message))
 		except EncodingException:
 			self.bridge.say('[Warning] "'+self.nickname+'" is sending messages using an unknown encoding')
 	
 	
 	def sayOnXMPPTo(self, to, message):
-		if self.protocol == 'xmpp':
-			raise Exception('[Internal Error] "'+self.nickname+'" comes from XMPP')
-		
 		try:
-			self.muc.sayTo(to, auto_decode(message))
+			if self.xmpp_c != None:
+				self.muc.sayTo(to, auto_decode(message))
+			elif self.irc_connection == None:
+				if self.bridge.mode != 'normal':
+					self.bridge.getParticipant(to).sayOnXMPPTo(self.nickname, 'Sorry but cross-protocol private messages are disabled in '+self.bridge.mode+' mode.')
+				else:
+					self.bridge.getParticipant(to).sayOnXMPPTo(self.nickname, 'Sorry but you cannot send cross-protocol private messages because I don\'t have an XMPP duplicate with your nickname.')
 		except EncodingException:
 			self.bridge.say('[Warning] "'+self.nickname+'" is sending messages using an unknown encoding')