# HG changeset patch # User Charly COSTE # Date 1268068337 -3600 # Node ID 60645c505f112dd93a2cd72307205fce1137c729 # Parent 9c039594435d9ae07f219ac47b21aa0215a31319 ignore IRC server-wide events not received on bot connection Signed-off-by: Charly COSTE diff --git a/bot.py b/bot.py --- 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']: