Mercurial > xib
changeset 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 |
files | bot.py bridge.py muc.py |
diffstat | 3 files changed, 35 insertions(+), 0 deletions(-) [+] |
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'):
--- a/bridge.py +++ b/bridge.py @@ -114,6 +114,8 @@ class bridge: def _xmpp_join_callback(self, errors): """Called by muc._xmpp_presence_handler""" if len(errors) == 0: + if hasattr(self, reconnecting): + del self.reconnecting if self.mode == None: return self.bot.error('===> Debug: succesfully connected on XMPP side of bridge "'+str(self)+'"', debug=True)
--- a/muc.py +++ b/muc.py @@ -29,6 +29,7 @@ class muc: class RoomIsLocked(Exception): pass class ForgotNickname(Exception): pass class UnknownError(Exception): pass + class RemoteServerNotFound(Exception): pass def __init__(self, room_jid): self.room_jid = room_jid @@ -89,6 +90,9 @@ class muc: elif err == 'modify jid-malformed': # forgot to give a nickname errors.append(self.__class__.ForgotNickname(self.jid)) + elif err == 'cancel remote-server-not-found': + # MUC server is down or doesn't exist + errors.append(self.__class__.RemoteServerNotFound(self.jid)) else: errors.append(self.__class__.UnknownError(presence.__str__(fancy=1).encode('utf-8'))) break