comparison participant.py @ 226:0d85049ac68d

switch to IRC join callbacks in bridge.py and participant.py Signed-off-by: Charly COSTE <changaco@changaco.net>
author Charly COSTE <changaco@changaco.net>
date Sun, 07 Mar 2010 18:52:48 +0100
parents 63289aa1dea7
children a434b73bde51
comparison
equal deleted inserted replaced
225:da8fbaf69242 226:0d85049ac68d
113 self.irc_connection = self.bridge.bot.irc.open_connection(self.bridge.irc_server, self.bridge.irc_port, self.duplicate_nickname) 113 self.irc_connection = self.bridge.bot.irc.open_connection(self.bridge.irc_server, self.bridge.irc_port, self.duplicate_nickname)
114 self.irc_connection.connect(nick_callback=self._irc_nick_callback) 114 self.irc_connection.connect(nick_callback=self._irc_nick_callback)
115 115
116 116
117 def _irc_nick_callback(self, error): 117 def _irc_nick_callback(self, error):
118 if error == None: 118 if not error:
119 self.irc_connection.join(self.bridge.irc_room) 119 self.irc_connection.join(self.bridge.irc_room, callback=self._irc_join_callback)
120 m = '"'+self.nickname+'" duplicate succesfully created on IRC side of bridge "'+str(self.bridge)+'"'
121 if self.nickname != self.duplicate_nickname:
122 m += ' using nickname "'+self.duplicate_nickname+'"'
123 self.bridge.say(say_levels.info, '"'+self.nickname+'" will appear as "'+self.duplicate_nickname+'" on IRC because its real nickname is reserved or contains unauthorized characters')
124 self.bridge.bot.error(3, m, debug=True)
125 120
126 elif self.irc_connection != 'both': 121 elif self.irc_connection != 'both':
127 122
128 if error in ['nicknameinuse', 'nickcollision']: 123 if error in ['nicknameinuse', 'nickcollision']:
129 if arguments[0].arguments()[0] != self.duplicate_nickname: 124 if arguments[0].arguments()[0] != self.duplicate_nickname:
163 self.bridge.say(say_levels.warning, 'unknown error while adding "'+self.nickname+'" to IRC side of bridge', log=True) 158 self.bridge.say(say_levels.warning, 'unknown error while adding "'+self.nickname+'" to IRC side of bridge', log=True)
164 159
165 if isinstance(self.irc_connection, ServerConnection): 160 if isinstance(self.irc_connection, ServerConnection):
166 self.irc_connection.close('') 161 self.irc_connection.close('')
167 self.irc_connection = error 162 self.irc_connection = error
163
164
165 def _irc_join_callback(self, channel, error):
166 if not error:
167 m = '"'+self.nickname+'" duplicate succesfully joined IRC side of bridge "'+str(self.bridge)+'"'
168 if self.nickname != self.duplicate_nickname:
169 m += ' using nickname "'+self.duplicate_nickname+'"'
170 self.bridge.say(say_levels.info, '"'+self.nickname+'" will appear as "'+self.duplicate_nickname+'" on IRC because its real nickname is reserved or contains unauthorized characters')
171 self.bridge.bot.error(3, m, debug=True)
172
173 elif self.irc_connection != 'both':
174 self._close_irc_connection('')
175 self.irc_connection = error
168 176
169 177
170 def set_both_sides(self): 178 def set_both_sides(self):
171 self.bridge.say(say_levels.warning, 'The nickname "'+self.nickname+'" is used on both sides of the bridge', log=True) 179 self.bridge.say(say_levels.warning, 'The nickname "'+self.nickname+'" is used on both sides of the bridge', log=True)
172 if isinstance(self.irc_connection, ServerConnection): 180 if isinstance(self.irc_connection, ServerConnection):