Mercurial > xib
diff bot.py @ 111:59401ac0f47a
handle XMPP remote-server-not-found
Signed-off-by: Charly COSTE <changaco@changaco.net>
author | Charly COSTE <changaco@changaco.net> |
---|---|
date | Fri, 27 Nov 2009 22:47:27 +0100 |
parents | ec4fbec1f160 |
children | a817ad05dd1d |
line wrap: on
line diff
--- a/bot.py +++ b/bot.py @@ -257,6 +257,35 @@ class bot(Thread): if p != None: bridge.removeParticipant('xmpp', resource, presence.getStatus()) + elif presence.getType() == 'error': + error = presence.getTag('error') + if error: + for c in error.getChildren(): + if c.getNamespace() == 'urn:ietf:params:xml:ns:xmpp-stanzas' and c.getName() != 'text': + err = error.getAttr('type')+' '+c.getName() + if err == 'cancel remote-server-not-found': + # Remote server not found + error_message = '[Error] XMPP Remote server not found: '+from_.getDomain() + + # Stop bridges that depend on this server + bridges = self.findBridges([from_.getDomain()]) + if len(bridges) > 0: + error_message += '\nThese bridges will be stopped:' + for b in bridges: + error_message += '\n'+str(b) + if hasattr(b, 'reconnecting'): + leave_message = 'MUC server seems to be down' + else: + leave_message = 'MUC server seems to be down, will try to recreate the bridge in 1 minute' + self.reconnecting = True + self.irc.execute_delayed(60, b.init2) + b.stop(message=leave_message) + + self.error(error_message, send_to_admins=True) + self.error(presence.__str__(fancy=1).encode('utf-8'), debug=True) + else: + raise Exception(presence.__str__(fancy=1).encode('utf-8')) + elif resource != bridge.bot.nickname: real_jid = None if item and item.has_attr('jid'):