comparison bridge.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 ba5ecd71065f
children b900585bdbbb
comparison
equal deleted inserted replaced
212:aa03c7ca53cb 213:fbe40b397f67
352 self.bot.error(importance, message+' ('+str(self)+')', send_to_admins=send_to_admins) 352 self.bot.error(importance, message+' ('+str(self)+')', send_to_admins=send_to_admins)
353 if importance != -1: 353 if importance != -1:
354 message = self.bot.format_message(importance, message) 354 message = self.bot.format_message(importance, message)
355 if importance < self.say_level: 355 if importance < self.say_level:
356 return 356 return
357 if on_xmpp and isinstance(self.xmpp_room, xmpp.muc) and self.xmpp_room.connected: 357 if on_xmpp:
358 self.xmpp_room.say(message) 358 self._say_on_xmpp(message)
359 if on_irc and isinstance(self.irc_connection, ServerConnection) and self.irc_connection.really_connected: 359 if on_irc:
360 self.irc_connection.privmsg(self.irc_room, message) 360 self._say_on_irc(message)
361
362
363 def say_on_behalf(self, nickname, message, on_protocol, action=False):
364 if action:
365 message = '* '+nickname+' '+message
366 else:
367 message = '<'+nickname+'> '+message
368
369 if on_protocol == 'xmpp':
370 self._say_on_xmpp(message)
371 elif on_protocol == 'irc':
372 self._say_on_irc(message)
373
374
375 def _say_on_irc(self, message):
376 self.irc_connection.privmsg(self.irc_room, message)
377
378
379 def _say_on_xmpp(self, message):
380 self.xmpp_room.say(message)
361 381
362 382
363 def show_participants_list_on(self, protocols=[]): 383 def show_participants_list_on(self, protocols=[]):
364 if 'irc' in protocols and self.irc_connection.really_connected: 384 if 'irc' in protocols and self.irc_connection.really_connected:
365 xmpp_participants_nicknames = self.get_participants_nicknames_list(protocols=['xmpp']) 385 xmpp_participants_nicknames = self.get_participants_nicknames_list(protocols=['xmpp'])