changeset 229:a434b73bde51

added optional "action" argument to Participant.say_on_xmpp_to and muc.say_to Signed-off-by: Charly COSTE <changaco@changaco.net>
author Charly COSTE <changaco@changaco.net>
date Sun, 07 Mar 2010 22:12:25 +0100
parents 3c493741e53a
children d5a126cf119c
files muc.py participant.py
diffstat 2 files changed, 11 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/muc.py
+++ b/muc.py
@@ -130,9 +130,11 @@ class muc:
 		self.xmpp_c.lock.release()
 	
 	
-	def say_to(self, to, message):
+	def say_to(self, to, message, action=False):
 		"""Send a private message"""
 		self.xmpp_c.lock.acquire()
+		if action:
+			message = '/me '+message
 		s = xmpp.protocol.Message(to=self.room_jid+'/'+to, typ='chat', body=message)
 		self._send(s)
 		self.xmpp_c.lock.release()
--- a/participant.py
+++ b/participant.py
@@ -308,10 +308,10 @@ class Participant:
 		if isinstance(self.irc_connection, ServerConnection):
 			self.irc_connection.privmsg(to, message)
 		elif not isinstance(self.xmpp_c, xmpp.client.Client):
-			if self.bridge.mode != 'normal':
-				self.bridge.get_participant(to).say_on_xmpp_to(self.nickname, 'Sorry but cross-protocol private messages are disabled in '+self.bridge.mode+' mode.')
+			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:
-				self.bridge.get_participant(to).say_on_xmpp_to(self.nickname, 'Sorry but you cannot send cross-protocol private messages because I don\'t have an IRC duplicate with your nickname.')
+				self.bridge.get_participant(to).say_on_xmpp_to(self.nickname, 'XIB error: Sorry but you cannot send cross-protocol private messages because I don\'t have an IRC duplicate with your nickname.')
 	
 	
 	def say_on_xmpp(self, message, action=False):
@@ -321,14 +321,14 @@ class Participant:
 			self.bridge.say_on_behalf(self.nickname, message, 'xmpp', action=action)
 	
 	
-	def say_on_xmpp_to(self, to, message):
+	def say_on_xmpp_to(self, to, message, action=False):
 		if isinstance(self.xmpp_c, xmpp.client.Client):
-			self.muc.say_to(to, message)
+			self.muc.say_to(to, message, action=action)
 		elif not isinstance(self.irc_connection, ServerConnection):
-			if self.bridge.mode != 'normal':
-				self.bridge.get_participant(to).say_on_xmpp_to(self.nickname, 'Sorry but cross-protocol private messages are disabled in '+self.bridge.mode+' mode.')
+			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:
-				self.bridge.get_participant(to).say_on_xmpp_to(self.nickname, 'Sorry but you cannot send cross-protocol private messages because I don\'t have an XMPP duplicate with your nickname.')
+				self.bridge.get_participant(to).say_on_xmpp_to(self.nickname, 'XIB error: Sorry but you cannot send cross-protocol private messages because I don\'t have an XMPP duplicate with your nickname.')
 	
 	
 	def leave(self, message):