Mercurial > xib
comparison bot.py @ 72:6c4b841144f6
Better handling of participants
Signed-off-by: Charly COSTE <changaco@changaco.net>
author | Charly COSTE <changaco@changaco.net> |
---|---|
date | Wed, 02 Sep 2009 14:57:57 +0200 |
parents | 01f1c6cb7447 |
children | 6034087b1d10 |
comparison
equal
deleted
inserted
replaced
71:c5e4bf95f52a | 72:6c4b841144f6 |
---|---|
83 c.Process(0.01) | 83 c.Process(0.01) |
84 c.lock.release() | 84 c.lock.release() |
85 except RuntimeError: | 85 except RuntimeError: |
86 pass | 86 pass |
87 except (xml.parsers.expat.ExpatError, xmpp.protocol.XMLNotWellFormed): | 87 except (xml.parsers.expat.ExpatError, xmpp.protocol.XMLNotWellFormed): |
88 self.error('=> Debug: received invalid stanza', debug=True) | 88 self.error('=> Debug: invalid stanza', debug=True) |
89 continue | 89 continue |
90 except: | 90 except: |
91 self.error('[Error] Unkonwn exception on XMPP thread:') | 91 self.error('[Error] Unkonwn exception on XMPP thread:') |
92 traceback.print_exc() | 92 traceback.print_exc() |
93 | 93 |
293 return | 293 return |
294 if nickname == self.nickname: | 294 if nickname == self.nickname: |
295 self.error('=> Debug: ignoring IRC '+event.eventtype()+' sent by self', debug=True) | 295 self.error('=> Debug: ignoring IRC '+event.eventtype()+' sent by self', debug=True) |
296 return | 296 return |
297 | 297 |
298 if event.eventtype() == 'quit' and connection in self.irc.connections: | |
299 return | |
300 | |
298 # TODO: lock self.bridges for thread safety | 301 # TODO: lock self.bridges for thread safety |
299 for bridge in self.bridges: | 302 for bridge in self.bridges: |
300 if connection.server != bridge.irc_server: | 303 if connection.server != bridge.irc_server: |
301 continue | 304 continue |
302 | 305 |
331 # Rejoin on kick | 334 # Rejoin on kick |
332 if event.eventtype() == 'kick': | 335 if event.eventtype() == 'kick': |
333 if event.target().lower() == bridge.irc_room: | 336 if event.target().lower() == bridge.irc_room: |
334 try: | 337 try: |
335 kicked = bridge.getParticipant(event.arguments()[0]) | 338 kicked = bridge.getParticipant(event.arguments()[0]) |
336 if kicked.irc_connection != None: | 339 if isinstance(kicked.irc_connection, irclib.ServerConnection): |
337 kicked.irc_connection.join(bridge.irc_room) | 340 kicked.irc_connection.join(bridge.irc_room) |
338 return | 341 return |
339 except NoSuchParticipantException: | 342 except NoSuchParticipantException: |
340 self.error('=> Debug: a participant that was not here has been kicked ? WTF ?') | 343 self.error('=> Debug: a participant that was not here has been kicked ? WTF ?') |
341 return | 344 return |
398 self.error('[Error] the nickname "'+event.target()+'" is banned from the IRC chan of bridge "'+str(bridge)+'"') | 401 self.error('[Error] the nickname "'+event.target()+'" is banned from the IRC chan of bridge "'+str(bridge)+'"') |
399 raise Exception('[Error] the nickname "'+event.target()+'" is banned from the IRC chan of bridge "'+str(bridge)+'"') | 402 raise Exception('[Error] the nickname "'+event.target()+'" is banned from the IRC chan of bridge "'+str(bridge)+'"') |
400 else: | 403 else: |
401 try: | 404 try: |
402 banned = bridge.getParticipant(event.target()) | 405 banned = bridge.getParticipant(event.target()) |
403 if banned.irc_connection != None: | 406 if banned.irc_connection != 'bannedfromchan': |
404 banned.irc_connection = None | 407 banned.irc_connection = 'bannedfromchan' |
405 self.error(event_str, debug=True) | 408 self.error(event_str, debug=True) |
406 self.error('[Notice] the nickname "'+event.target()+'" is banned from the IRC chan of bridge "'+str(bridge)+'"') | 409 self.error('[Notice] the nickname "'+event.target()+'" is banned from the IRC chan of bridge "'+str(bridge)+'"') |
407 bridge.say('[Warning] the nickname "'+event.target()+'" is banned from the IRC chan') | 410 bridge.say('[Warning] the nickname "'+event.target()+'" is banned from the IRC chan') |
408 else: | 411 else: |
409 self.error('=> Debug: ignoring '+event.eventtype(), debug=True) | 412 self.error('=> Debug: ignoring '+event.eventtype(), debug=True) |