Mercurial > xib
diff bot.py @ 3:3f651f4fdb4f
Added IRC "part" event handling
Signed-off-by: Charly COSTE <changaco@changaco.net>
author | Charly COSTE <changaco@changaco.net> |
---|---|
date | Sun, 16 Aug 2009 17:10:12 +0200 |
parents | f2d0a8b448db |
children | cb0daec4b778 |
line wrap: on
line diff
--- a/bot.py +++ b/bot.py @@ -106,7 +106,7 @@ class bot(Thread): # presence comes from a participant of the muc try: p = bridge.getParticipant(resource) - if p.protocol == 'xmpp': + if p.protocol in ['xmpp', 'both']: if presence.getType() == 'unavailable': x = presence.getTag('x', namespace='http://jabber.org/protocol/muc#user') if x and x.getTag('status', attrs={'code': '303'}): @@ -124,10 +124,11 @@ class bot(Thread): # participant left bridge.removeParticipant('xmpp', resource, presence.getStatus()) except NoSuchParticipantException: - try: - bridge.addParticipant('xmpp', resource) - except Exception: - pass + if presence.getType() != 'unavailable': + try: + bridge.addParticipant('xmpp', resource) + except Exception: + pass return @@ -263,8 +264,8 @@ class bot(Thread): connection.bridge.addParticipant('irc', nickname) try: from_ = connection.bridge.getParticipant(event.source().split('!')[0]) - if event.eventtype() == 'quit': - if from_.protocol == 'irc': + if event.eventtype() == 'quit' or event.eventtype() == 'part' and event.target() == connection.bridge.irc_room: + if from_.protocol in ['irc', 'both']: connection.bridge.removeParticipant('irc', from_.nickname, event.arguments()[0]) return except NoSuchParticipantException: