Mercurial > xib
changeset 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 | 012593ed4e12 |
files | bot.py bridge.py participant.py |
diffstat | 3 files changed, 13 insertions(+), 10 deletions(-) [+] |
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:
--- a/bridge.py +++ b/bridge.py @@ -103,9 +103,11 @@ class bridge: if p.protocol == 'both': self.bot.error('===> Debug: "'+nickname+'" was on both sides of bridge "'+str(self)+'" but left '+protocol, debug=True) if protocol == 'xmpp': - p.createDuplicateOnIRC() + p.protocol = 'irc' + p.createDuplicateOnXMPP() elif protocol == 'irc': - p.createDuplicateOnXMPP() + p.protocol = 'xmpp' + p.createDuplicateOnIRC() else: raise Exception('Internal Error: bad protocol') else:
--- a/participant.py +++ b/participant.py @@ -74,7 +74,7 @@ class participant: elif self.protocol != 'both': if error == 'nicknameinuse': self.bridge.bot.error('===> Debug: "'+self.nickname+'" is already used in the IRC chan of bridge "'+str(self.bridge)+'"', debug=True) - self.bridge.say('[Warning] The nickname "'+self.nickname+'" is used on both rooms, please avoid that if possible') + self.bridge.say('[Warning] The nickname "'+self.nickname+'" is used on both rooms or reserved on the IRC server, please avoid that if possible') self.protocol = 'both' self.irc_connection.close() self.irc_connection = None