Mercurial > xib
comparison bot.py @ 88:8b071629558e
Handle IRC "kill" event
Signed-off-by: Charly COSTE <changaco@changaco.net>
author | Charly COSTE <changaco@changaco.net> |
---|---|
date | Mon, 07 Sep 2009 18:33:59 +0200 |
parents | bfa32b017fc9 |
children | 965dd6f5fcc3 |
comparison
equal
deleted
inserted
replaced
87:500d47b1d8cd | 88:8b071629558e |
---|---|
473 | 473 |
474 # From here the event is shown | 474 # From here the event is shown |
475 self.error(event_str, debug=True) | 475 self.error(event_str, debug=True) |
476 | 476 |
477 | 477 |
478 if event.eventtype() == 'disconnect': | 478 if event.eventtype() in ['disconnect', 'kill']: |
479 if len(event.arguments()) > 0 and event.arguments()[0] == 'Connection reset by peer': | 479 if len(event.arguments()) > 0 and event.arguments()[0] == 'Connection reset by peer': |
480 return | 480 return |
481 | 481 |
482 # TODO: lock self.bridges for thread safety | 482 # TODO: lock self.bridges for thread safety |
483 for bridge in self.bridges: | 483 for bridge in self.bridges: |
484 if connection.server != bridge.irc_server: | 484 if connection.server != bridge.irc_server: |
485 continue | 485 continue |
486 try: | 486 try: |
487 bridge.getParticipant(connection.get_nickname()) | 487 p = bridge.getParticipant(connection.get_nickname()) |
488 if bridge.mode == 'normal': | 488 if bridge.mode == 'normal': |
489 bridge.switchFromNormalToLimitedMode() | 489 bridge.switchFromNormalToLimitedMode() |
490 else: | |
491 if p.irc_connection.really_connected == True: | |
492 p.irc_connection.part(bridge.irc_room, message=message) | |
493 p.irc_connection.used_by -= 1 | |
494 if p.irc_connection.used_by < 1: | |
495 p.irc_connection.close(message) | |
496 p.irc_connection = None | |
490 except NoSuchParticipantException: | 497 except NoSuchParticipantException: |
491 pass | 498 pass |
492 return | 499 return |
493 | 500 |
494 | 501 |