comparison bridge.py @ 249:430eb5052e4d

minor changes in Bridge Signed-off-by: Charly COSTE <changaco@changaco.net>
author Charly COSTE <changaco@changaco.net>
date Mon, 08 Mar 2010 21:35:31 +0100
parents ebd67e3e4866
children 49c57daff4d7
comparison
equal deleted inserted replaced
248:234e8ca6a10c 249:430eb5052e4d
57 57
58 58
59 def init2(self): 59 def init2(self):
60 self.reconnecting = False 60 self.reconnecting = False
61 61
62 self.bot.error(say_levels.notice, 'starting bridge "'+str(self)+'" with mode="'+self.mode+'" and say_level="'+str(self.say_level)+'"')
63
62 # Join XMPP room 64 # Join XMPP room
63 self.xmpp_room = xmpp.muc(self.xmpp_room_jid) 65 self.xmpp_room = xmpp.muc(self.xmpp_room_jid)
64 self.xmpp_room.join(self.bot.xmpp_c, self.bot.nickname, callback=self._xmpp_join_callback) 66 self.xmpp_room.join(self.bot.xmpp_c, self.bot.nickname, callback=self._xmpp_join_callback)
65 67
66 # Join IRC room 68 # Join IRC room
67 self.irc_connection = self.bot.irc.open_connection(self.irc_server, self.irc_port, self.bot.nickname, delay=self.irc_connection_interval) 69 self.irc_connection = self.bot.irc.open_connection(self.irc_server, self.irc_port, self.bot.nickname, delay=self.irc_connection_interval)
68 self.irc_connection.connect(nick_callback=self._irc_nick_callback, charsets=self.irc_charsets) 70 self.irc_connection.connect(nick_callback=self._irc_nick_callback, charsets=self.irc_charsets)
69
70 self.bot.error(say_levels.notice, 'bridge "'+str(self)+'" is running in '+self.mode+' mode and a say_level of "'+str(self.say_level)+'"')
71 71
72 72
73 def _join_irc_failed(self, reason): 73 def _join_irc_failed(self, reason):
74 self.bot.error(say_levels.error, 'failed to connect to the IRC chan of bridge '+str(self)+'\nreason: '+reason, send_to_admins=True) 74 self.bot.error(say_levels.error, 'failed to connect to the IRC chan of bridge '+str(self)+'\nreason: '+reason, send_to_admins=True)
75 self.stop(message='Failed to connect to the IRC chan, stopping bridge', log=False) 75 self.stop(message='Failed to connect to the IRC chan, stopping bridge', log=False)
115 115
116 def _xmpp_join_callback(self, errors): 116 def _xmpp_join_callback(self, errors):
117 """Called by muc._xmpp_presence_handler""" 117 """Called by muc._xmpp_presence_handler"""
118 if len(errors) == 0: 118 if len(errors) == 0:
119 self.reconnecting = False 119 self.reconnecting = False
120 if self.mode == None: 120 if not self.mode:
121 return 121 return
122 self.bot.error(3, 'succesfully connected on XMPP side of bridge "'+str(self)+'"', debug=True) 122 self.bot.error(3, 'succesfully connected on XMPP side of bridge "'+str(self)+'"', debug=True)
123 self.say(say_levels.notice, 'bridge "'+str(self)+'" is running in '+self.mode+' mode', on_irc=False) 123 self.say(say_levels.notice, 'bridge "'+str(self)+'" is running in '+self.mode+' mode', on_irc=False)
124 else: 124 else:
125 self.mode = None 125 self.mode = None