Mercurial > xib
changeset 192:12fa9bb73b1d
check connection in Bridge.say(), use Bridge.say() in Participant.sayOn{IRC,XMPP}()
Signed-off-by: Charly COSTE <changaco@changaco.net>
author | Charly COSTE <changaco@changaco.net> |
---|---|
date | Sun, 21 Feb 2010 14:51:14 +0100 |
parents | ac89a4a72a62 |
children | c2a8586e64b5 |
files | bridge.py participant.py |
diffstat | 2 files changed, 8 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/bridge.py +++ b/bridge.py @@ -84,8 +84,7 @@ class Bridge: self.show_participants_list_on(protocols=['irc']) else: self.mode = None - if self.xmpp_room.connected == True: - self.say(say_levels.error, 'failed to connect to the IRC chan, leaving ...', on_irc=False) + self.say(say_levels.error, 'failed to connect to the IRC chan, leaving ...', on_irc=False) try: if error == 'nicknameinuse': raise Exception('[Error] "'+self.bot.nickname+'" is already used in the IRC chan or reserved on the IRC server of bridge "'+str(self)+'"') @@ -120,8 +119,7 @@ class Bridge: self.say(say_levels.notice, 'bridge "'+str(self)+'" is running in '+self.mode+' mode', on_irc=False) else: self.mode = None - if self.irc_connection.really_connected == True: - self.say(say_levels.error, 'failed to connect to the XMPP room, leaving ...', on_xmpp=False) + self.say(say_levels.error, 'failed to connect to the XMPP room, leaving ...', on_xmpp=False) for error in errors: try: raise error @@ -362,9 +360,9 @@ class Bridge: message = self.bot.format_message(importance, message) if importance < self.say_level: return - if on_xmpp == True: + if on_xmpp and isinstance(self.xmpp_room, xmpp.muc) and self.xmpp_room.connected: self.xmpp_room.say(message) - if on_irc == True: + if on_irc and isinstance(self.irc_connection, ServerConnection) and self.irc_connection.really_connected: self.irc_connection.privmsg(self.irc_room, message)
--- a/participant.py +++ b/participant.py @@ -294,9 +294,9 @@ class Participant: bot_say = True if bot_say: if action: - self.bridge.irc_connection.privmsg(self.bridge.irc_room, '* '+self.nickname+' '+message) + self.bridge.say('* '+self.nickname+' '+message, on_xmpp=False) else: - self.bridge.irc_connection.privmsg(self.bridge.irc_room, '<'+self.nickname+'> '+message) + self.bridge.say('<'+self.nickname+'> '+message, on_xmpp=False) def sayOnIRCTo(self, to, message): @@ -314,9 +314,9 @@ class Participant: self.muc.say(message) elif not isinstance(self.irc_connection, ServerConnection): if message[:4] == '/me ': - self.bridge.xmpp_room.say('* '+self.nickname+' '+message[4:]) + self.bridge.say('* '+self.nickname+' '+message[4:], on_irc=False) else: - self.bridge.xmpp_room.say('<'+self.nickname+'> '+message) + self.bridge.say('<'+self.nickname+'> '+message, on_irc=False) def sayOnXMPPTo(self, to, message):