comparison participant.py @ 213:fbe40b397f67

created Bridge.say_on_behalf in order to avoid code repetition in participant.py Signed-off-by: Charly COSTE <changaco@changaco.net>
author Charly COSTE <changaco@changaco.net>
date Sat, 06 Mar 2010 19:05:07 +0100
parents 2a81c480439a
children 63289aa1dea7
comparison
equal deleted inserted replaced
212:aa03c7ca53cb 213:fbe40b397f67
291 self.irc_connection.connect() 291 self.irc_connection.connect()
292 bot_say = True 292 bot_say = True
293 elif not isinstance(self.xmpp_c, xmpp.client.Client): 293 elif not isinstance(self.xmpp_c, xmpp.client.Client):
294 bot_say = True 294 bot_say = True
295 if bot_say: 295 if bot_say:
296 if action: 296 self.bridge.say_on_behalf(self.nickname, message, 'irc', action=action)
297 self.bridge.say(-1, '* '+self.nickname+' '+message, on_xmpp=False)
298 else:
299 self.bridge.say(-1, '<'+self.nickname+'> '+message, on_xmpp=False)
300 297
301 298
302 def say_on_irc_to(self, to, message): 299 def say_on_irc_to(self, to, message):
303 if isinstance(self.irc_connection, ServerConnection): 300 if isinstance(self.irc_connection, ServerConnection):
304 self.irc_connection.privmsg(to, message) 301 self.irc_connection.privmsg(to, message)
307 self.bridge.get_participant(to).say_on_xmpp_to(self.nickname, 'Sorry but cross-protocol private messages are disabled in '+self.bridge.mode+' mode.') 304 self.bridge.get_participant(to).say_on_xmpp_to(self.nickname, 'Sorry but cross-protocol private messages are disabled in '+self.bridge.mode+' mode.')
308 else: 305 else:
309 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.') 306 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.')
310 307
311 308
312 def say_on_xmpp(self, message): 309 def say_on_xmpp(self, message, action=False):
313 if isinstance(self.xmpp_c, xmpp.client.Client): 310 if isinstance(self.xmpp_c, xmpp.client.Client):
314 self.muc.say(message) 311 self.muc.say(message, action=action)
315 elif not isinstance(self.irc_connection, ServerConnection): 312 elif not isinstance(self.irc_connection, ServerConnection):
316 self.say_on_XMPP_through_bridge(message) 313 self.bridge.say_on_behalf(self.nickname, message, 'xmpp', action=action)
317
318
319 def say_on_XMPP_through_bridge(self, message):
320 if message[:4] == '/me ':
321 self.bridge.say(-1, '* '+self.nickname+' '+message[4:], on_irc=False)
322 else:
323 self.bridge.say(-1, '<'+self.nickname+'> '+message, on_irc=False)
324 314
325 315
326 def say_on_xmpp_to(self, to, message): 316 def say_on_xmpp_to(self, to, message):
327 if isinstance(self.xmpp_c, xmpp.client.Client): 317 if isinstance(self.xmpp_c, xmpp.client.Client):
328 self.muc.say_to(to, message) 318 self.muc.say_to(to, message)