Mercurial > xib
diff bot.py @ 5:cb0daec4b778
Added support for IRC "nick" event, fixed participant.changeNickname(), fixed handling of IRC "namreply" event, removed muc._check() because waiting does not solve the problem if it is blocking incoming messages handling
Signed-off-by: Charly COSTE <changaco@changaco.net>
author | Charly COSTE <changaco@changaco.net> |
---|---|
date | Sun, 16 Aug 2009 17:59:00 +0200 |
parents | 3f651f4fdb4f |
children | 7cb790f5f243 |
line wrap: on
line diff
--- a/bot.py +++ b/bot.py @@ -225,8 +225,11 @@ class bot(Thread): # Lost bridge IRC connection, we must reconnect if we want the bridge to work self.recreate_bridge(connection.bridge) return - if connection.bridge.mode == 'normal' and event.arguments()[0] != 'Closing object': + if connection.bridge.mode == 'normal' and connection.closing == False: connection.bridge.switchToLimitedMode() + if connection.closing == True: + connection.close() + return elif event.eventtype() == 'nicknameinuse': if connection.nick_callback: connection.nick_callback('nicknameinuse') @@ -247,7 +250,9 @@ class bot(Thread): self.error('connection.nick_callback='+str(connection.nick_callback), debug=True) return elif event.eventtype() == 'namreply': - for nickname in re.split(' [@\+]?', event.arguments()[2].strip()): + for nickname in re.split('(?:^[@\+]?|(?: [@\+]?)*)', event.arguments()[2].strip()): + if nickname == '': + continue try: connection.bridge.addParticipant('irc', nickname) except: @@ -262,12 +267,15 @@ class bot(Thread): connection.bridge.getParticipant(nickname) except NoSuchParticipantException: connection.bridge.addParticipant('irc', nickname) + return try: from_ = connection.bridge.getParticipant(event.source().split('!')[0]) 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 + if event.eventtype() == 'nick' and from_.protocol == 'irc': + from_.changeNickname(event.target(), 'xmpp') except NoSuchParticipantException: return except AttributeError: