comparison 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
comparison
equal deleted inserted replaced
110:ec4fbec1f160 111:59401ac0f47a
255 else: 255 else:
256 # participant left 256 # participant left
257 if p != None: 257 if p != None:
258 bridge.removeParticipant('xmpp', resource, presence.getStatus()) 258 bridge.removeParticipant('xmpp', resource, presence.getStatus())
259 259
260 elif presence.getType() == 'error':
261 error = presence.getTag('error')
262 if error:
263 for c in error.getChildren():
264 if c.getNamespace() == 'urn:ietf:params:xml:ns:xmpp-stanzas' and c.getName() != 'text':
265 err = error.getAttr('type')+' '+c.getName()
266 if err == 'cancel remote-server-not-found':
267 # Remote server not found
268 error_message = '[Error] XMPP Remote server not found: '+from_.getDomain()
269
270 # Stop bridges that depend on this server
271 bridges = self.findBridges([from_.getDomain()])
272 if len(bridges) > 0:
273 error_message += '\nThese bridges will be stopped:'
274 for b in bridges:
275 error_message += '\n'+str(b)
276 if hasattr(b, 'reconnecting'):
277 leave_message = 'MUC server seems to be down'
278 else:
279 leave_message = 'MUC server seems to be down, will try to recreate the bridge in 1 minute'
280 self.reconnecting = True
281 self.irc.execute_delayed(60, b.init2)
282 b.stop(message=leave_message)
283
284 self.error(error_message, send_to_admins=True)
285 self.error(presence.__str__(fancy=1).encode('utf-8'), debug=True)
286 else:
287 raise Exception(presence.__str__(fancy=1).encode('utf-8'))
288
260 elif resource != bridge.bot.nickname: 289 elif resource != bridge.bot.nickname:
261 real_jid = None 290 real_jid = None
262 if item and item.has_attr('jid'): 291 if item and item.has_attr('jid'):
263 real_jid = item.getAttr('jid') 292 real_jid = item.getAttr('jid')
264 293