Mercurial > xib
comparison bot.py @ 5:cb0daec4b778
Added support for IRC "nick" event, fixed participant.changeNickname(), fixed handling of IRC "namreply" event, removed muc._check() because waiting does not solve the problem if it is blocking incoming messages handling
Signed-off-by: Charly COSTE <changaco@changaco.net>
author | Charly COSTE <changaco@changaco.net> |
---|---|
date | Sun, 16 Aug 2009 17:59:00 +0200 |
parents | 3f651f4fdb4f |
children | 7cb790f5f243 |
comparison
equal
deleted
inserted
replaced
4:012593ed4e12 | 5:cb0daec4b778 |
---|---|
223 if event.eventtype() == 'disconnect': | 223 if event.eventtype() == 'disconnect': |
224 if connection.get_nickname() == connection.bridge.irc_connection.get_nickname(): | 224 if connection.get_nickname() == connection.bridge.irc_connection.get_nickname(): |
225 # Lost bridge IRC connection, we must reconnect if we want the bridge to work | 225 # Lost bridge IRC connection, we must reconnect if we want the bridge to work |
226 self.recreate_bridge(connection.bridge) | 226 self.recreate_bridge(connection.bridge) |
227 return | 227 return |
228 if connection.bridge.mode == 'normal' and event.arguments()[0] != 'Closing object': | 228 if connection.bridge.mode == 'normal' and connection.closing == False: |
229 connection.bridge.switchToLimitedMode() | 229 connection.bridge.switchToLimitedMode() |
230 if connection.closing == True: | |
231 connection.close() | |
232 return | |
230 elif event.eventtype() == 'nicknameinuse': | 233 elif event.eventtype() == 'nicknameinuse': |
231 if connection.nick_callback: | 234 if connection.nick_callback: |
232 connection.nick_callback('nicknameinuse') | 235 connection.nick_callback('nicknameinuse') |
233 else: | 236 else: |
234 self.error('=> Debug: no nick callback for "'+str(event.target())+'"', debug=True) | 237 self.error('=> Debug: no nick callback for "'+str(event.target())+'"', debug=True) |
245 else: | 248 else: |
246 self.error('=> Debug: no nick callback for "'+str(event.target())+'"', debug=True) | 249 self.error('=> Debug: no nick callback for "'+str(event.target())+'"', debug=True) |
247 self.error('connection.nick_callback='+str(connection.nick_callback), debug=True) | 250 self.error('connection.nick_callback='+str(connection.nick_callback), debug=True) |
248 return | 251 return |
249 elif event.eventtype() == 'namreply': | 252 elif event.eventtype() == 'namreply': |
250 for nickname in re.split(' [@\+]?', event.arguments()[2].strip()): | 253 for nickname in re.split('(?:^[@\+]?|(?: [@\+]?)*)', event.arguments()[2].strip()): |
254 if nickname == '': | |
255 continue | |
251 try: | 256 try: |
252 connection.bridge.addParticipant('irc', nickname) | 257 connection.bridge.addParticipant('irc', nickname) |
253 except: | 258 except: |
254 pass | 259 pass |
255 return | 260 return |
260 else: | 265 else: |
261 try: | 266 try: |
262 connection.bridge.getParticipant(nickname) | 267 connection.bridge.getParticipant(nickname) |
263 except NoSuchParticipantException: | 268 except NoSuchParticipantException: |
264 connection.bridge.addParticipant('irc', nickname) | 269 connection.bridge.addParticipant('irc', nickname) |
270 return | |
265 try: | 271 try: |
266 from_ = connection.bridge.getParticipant(event.source().split('!')[0]) | 272 from_ = connection.bridge.getParticipant(event.source().split('!')[0]) |
267 if event.eventtype() == 'quit' or event.eventtype() == 'part' and event.target() == connection.bridge.irc_room: | 273 if event.eventtype() == 'quit' or event.eventtype() == 'part' and event.target() == connection.bridge.irc_room: |
268 if from_.protocol in ['irc', 'both']: | 274 if from_.protocol in ['irc', 'both']: |
269 connection.bridge.removeParticipant('irc', from_.nickname, event.arguments()[0]) | 275 connection.bridge.removeParticipant('irc', from_.nickname, event.arguments()[0]) |
270 return | 276 return |
277 if event.eventtype() == 'nick' and from_.protocol == 'irc': | |
278 from_.changeNickname(event.target(), 'xmpp') | |
271 except NoSuchParticipantException: | 279 except NoSuchParticipantException: |
272 return | 280 return |
273 except AttributeError: | 281 except AttributeError: |
274 pass | 282 pass |
275 if event.eventtype() == 'pubmsg': | 283 if event.eventtype() == 'pubmsg': |