comparison bridge.py @ 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
comparison
equal deleted inserted replaced
191:ac89a4a72a62 192:12fa9bb73b1d
82 self.say(say_levels.notice, 'bridge "'+str(self)+'" is running in '+self.mode+' mode', on_xmpp=False) 82 self.say(say_levels.notice, 'bridge "'+str(self)+'" is running in '+self.mode+' mode', on_xmpp=False)
83 if self.mode not in ['normal', 'bypass']: 83 if self.mode not in ['normal', 'bypass']:
84 self.show_participants_list_on(protocols=['irc']) 84 self.show_participants_list_on(protocols=['irc'])
85 else: 85 else:
86 self.mode = None 86 self.mode = None
87 if self.xmpp_room.connected == True: 87 self.say(say_levels.error, 'failed to connect to the IRC chan, leaving ...', on_irc=False)
88 self.say(say_levels.error, 'failed to connect to the IRC chan, leaving ...', on_irc=False)
89 try: 88 try:
90 if error == 'nicknameinuse': 89 if error == 'nicknameinuse':
91 raise Exception('[Error] "'+self.bot.nickname+'" is already used in the IRC chan or reserved on the IRC server of bridge "'+str(self)+'"') 90 raise Exception('[Error] "'+self.bot.nickname+'" is already used in the IRC chan or reserved on the IRC server of bridge "'+str(self)+'"')
92 elif error == 'nickcollision': 91 elif error == 'nickcollision':
93 raise Exception('[Error] "'+self.bot.nickname+'" is already used or reserved on the IRC server of bridge "'+str(self)+'"') 92 raise Exception('[Error] "'+self.bot.nickname+'" is already used or reserved on the IRC server of bridge "'+str(self)+'"')
118 return 117 return
119 self.bot.error(3, 'succesfully connected on XMPP side of bridge "'+str(self)+'"', debug=True) 118 self.bot.error(3, 'succesfully connected on XMPP side of bridge "'+str(self)+'"', debug=True)
120 self.say(say_levels.notice, 'bridge "'+str(self)+'" is running in '+self.mode+' mode', on_irc=False) 119 self.say(say_levels.notice, 'bridge "'+str(self)+'" is running in '+self.mode+' mode', on_irc=False)
121 else: 120 else:
122 self.mode = None 121 self.mode = None
123 if self.irc_connection.really_connected == True: 122 self.say(say_levels.error, 'failed to connect to the XMPP room, leaving ...', on_xmpp=False)
124 self.say(say_levels.error, 'failed to connect to the XMPP room, leaving ...', on_xmpp=False)
125 for error in errors: 123 for error in errors:
126 try: 124 try:
127 raise error 125 raise error
128 except xmpp.muc.RemoteServerNotFound: 126 except xmpp.muc.RemoteServerNotFound:
129 self._RemoteServerNotFound_handler() 127 self._RemoteServerNotFound_handler()
360 if log or send_to_admins: 358 if log or send_to_admins:
361 self.bot.error(importance, message+' ('+str(self)+')', send_to_admins=send_to_admins) 359 self.bot.error(importance, message+' ('+str(self)+')', send_to_admins=send_to_admins)
362 message = self.bot.format_message(importance, message) 360 message = self.bot.format_message(importance, message)
363 if importance < self.say_level: 361 if importance < self.say_level:
364 return 362 return
365 if on_xmpp == True: 363 if on_xmpp and isinstance(self.xmpp_room, xmpp.muc) and self.xmpp_room.connected:
366 self.xmpp_room.say(message) 364 self.xmpp_room.say(message)
367 if on_irc == True: 365 if on_irc and isinstance(self.irc_connection, ServerConnection) and self.irc_connection.really_connected:
368 self.irc_connection.privmsg(self.irc_room, message) 366 self.irc_connection.privmsg(self.irc_room, message)
369 367
370 368
371 def show_participants_list_on(self, protocols=[]): 369 def show_participants_list_on(self, protocols=[]):
372 if 'irc' in protocols and self.irc_connection.really_connected: 370 if 'irc' in protocols and self.irc_connection.really_connected: