Mercurial > xib
changeset 242:60645c505f11
ignore IRC server-wide events not received on bot connection
Signed-off-by: Charly COSTE <changaco@changaco.net>
author | Charly COSTE <changaco@changaco.net> |
---|---|
date | Mon, 08 Mar 2010 18:12:17 +0100 |
parents | 9c039594435d |
children | c9652650d5b5 |
files | bot.py |
diffstat | 1 files changed, 29 insertions(+), 29 deletions(-) [+] |
line wrap: on
line diff
--- a/bot.py +++ b/bot.py @@ -514,35 +514,6 @@ class Bot(threading.Thread): connection.privmsg(source_nickname, 'XIB error: you cannot send a private message to an XMPP user if you are not in one of the chans he is in') - # Server events - if event.eventtype() in ['quit', 'nick']: - for bridge in self.iter_bridges(irc_server=connection.server): - - try: - from_ = bridge.get_participant(source_nickname) - except Bridge.NoSuchParticipantException: - continue - - handled = True - - # Quit event - if event.eventtype() == 'quit': - if len(event.arguments()) > 0: - leave_message = event.arguments()[0] - else: - leave_message = 'Left server.' - bridge.remove_participant('irc', from_.nickname, leave_message) - continue - - # Nickname change - if event.eventtype() == 'nick': - from_.change_nickname(event.target(), 'xmpp') - continue - - if handled: - return - - # Connection errors if event.eventtype() in ['disconnect', 'kill', 'error']: if len(event.arguments()) > 0 and event.arguments()[0] == 'Connection reset by peer': @@ -582,6 +553,35 @@ class Bot(threading.Thread): return + # Server events + if event.eventtype() in ['quit', 'nick']: + for bridge in self.iter_bridges(irc_server=connection.server): + + try: + from_ = bridge.get_participant(source_nickname) + except Bridge.NoSuchParticipantException: + continue + + handled = True + + # Quit event + if event.eventtype() == 'quit': + if len(event.arguments()) > 0: + leave_message = event.arguments()[0] + else: + leave_message = 'Left server.' + bridge.remove_participant('irc', from_.nickname, leave_message) + continue + + # Nickname change + if event.eventtype() == 'nick': + from_.change_nickname(event.target(), 'xmpp') + continue + + if handled: + return + + # Chan events if event.eventtype() in ['pubmsg', 'action', 'part', 'kick', 'mode', 'join']: