comparison bridge.py @ 85:dfa030c141f1

Fixed callbacks in bridge.py Signed-off-by: Charly COSTE <changaco@changaco.net>
author Charly COSTE <changaco@changaco.net>
date Sat, 05 Sep 2009 21:57:46 +0200
parents 844ccdcf66be
children bfa32b017fc9
comparison
equal deleted inserted replaced
84:844ccdcf66be 85:dfa030c141f1
77 self.bot.error('[Notice] bridge "'+str(self)+'" is running in '+self.mode+' mode and a say_level of "'+say_level+'"') 77 self.bot.error('[Notice] bridge "'+str(self)+'" is running in '+self.mode+' mode and a say_level of "'+say_level+'"')
78 78
79 79
80 def _irc_nick_callback(self, error, arguments=[]): 80 def _irc_nick_callback(self, error, arguments=[]):
81 if error == None: 81 if error == None:
82 if self.mode == None:
83 return
82 self.irc_connection.join(self.irc_room) 84 self.irc_connection.join(self.irc_room)
83 self.bot.error('===> Debug: successfully connected on IRC side of bridge "'+str(self)+'"', debug=True) 85 self.bot.error('===> Debug: successfully connected on IRC side of bridge "'+str(self)+'"', debug=True)
84 self.say('[Notice] bridge "'+str(self)+'" is running in '+self.mode+' mode', on_xmpp=False) 86 self.say('[Notice] bridge "'+str(self)+'" is running in '+self.mode+' mode', on_xmpp=False)
85 else: 87 else:
88 self.mode = None
86 if self.muc.connected == True: 89 if self.muc.connected == True:
87 self.say('[Error] failed to connect to the IRC chan, leaving ...', on_irc=False) 90 self.say('[Error] failed to connect to the IRC chan, leaving ...', on_irc=False)
88 try: 91 try:
89 if error == 'nicknameinuse': 92 if error == 'nicknameinuse':
90 raise Exception('[Error] "'+self.bot.nickname+'" is already used in the IRC chan or reserved on the IRC server of bridge "'+str(self)+'"') 93 raise Exception('[Error] "'+self.bot.nickname+'" is already used in the IRC chan or reserved on the IRC server of bridge "'+str(self)+'"')
103 106
104 107
105 def _xmpp_join_callback(self, errors): 108 def _xmpp_join_callback(self, errors):
106 """Called by muc._xmpp_presence_handler""" 109 """Called by muc._xmpp_presence_handler"""
107 if len(errors) == 0: 110 if len(errors) == 0:
111 if self.mode == None:
112 return
108 self.bot.error('===> Debug: succesfully connected on XMPP side of bridge "'+str(self)+'"', debug=True) 113 self.bot.error('===> Debug: succesfully connected on XMPP side of bridge "'+str(self)+'"', debug=True)
109 self.say('[Notice] bridge "'+str(self)+'" is running in '+self.mode+' mode', on_irc=False) 114 self.say('[Notice] bridge "'+str(self)+'" is running in '+self.mode+' mode', on_irc=False)
110 else: 115 else:
116 self.mode = None
111 if self.irc_connection.really_connected == True: 117 if self.irc_connection.really_connected == True:
112 self.say('[Error] failed to connect to the XMPP room, leaving ...', on_xmpp=False) 118 self.say('[Error] failed to connect to the XMPP room, leaving ...', on_xmpp=False)
113 for error in errors: 119 for error in errors:
114 try: 120 try:
115 raise error 121 raise error