comparison bot.py @ 199:dcabe54deeba

improved an XMPP error handling, created Participant.say_on_XMPP_through_bridge() Signed-off-by: Charly COSTE <changaco@changaco.net>
author Charly COSTE <changaco@changaco.net>
date Thu, 25 Feb 2010 18:41:55 +0100
parents 66ed2dcdc4d1
children 740effa74c18
comparison
equal deleted inserted replaced
198:66ed2dcdc4d1 199:dcabe54deeba
406 for c in message.getChildren(): 406 for c in message.getChildren():
407 if c.getName() == 'error': 407 if c.getName() == 'error':
408 for cc in c.getChildren(): 408 for cc in c.getChildren():
409 if cc.getNamespace() == 'urn:ietf:params:xml:ns:xmpp-stanzas' and cc.getName() != 'text': 409 if cc.getNamespace() == 'urn:ietf:params:xml:ns:xmpp-stanzas' and cc.getName() != 'text':
410 err = cc.getName() 410 err = cc.getName()
411 if err == 'not-acceptable': 411 if err in ['not-acceptable', 'not-allowed']:
412 # we sent a message to a room we are not in 412 # we sent a message to a room we are not in
413 # probable cause is a MUC server restart 413 # can be due to a MUC server restart
414 # let's restart the bot 414 # can be a concurrency bug
415 self.restart() 415 if xmpp_c.nickname == self.nickname:
416 b.restart(message='Automatic restart of bridge')
417 else:
418 try:
419 p = b.getParticipant(xmpp_c.nickname)
420 p.say_on_XMPP_through_bridge(message.getBody())
421 except Bridge.NoSuchParticipantException:
422 b.restart(message='Automatic restart of bridge')
423
416 elif err == 'forbidden': 424 elif err == 'forbidden':
417 # we don't have the permission to speak 425 # we don't have the permission to speak
418 # let's remove the bridge and tell admins 426 # let's remove the bridge and tell admins
419 self.error(say_levels.error, 'Not allowed to speak on the XMPP MUC of bridge '+str(b)+', stopping it', send_to_admins=True) 427 self.error(say_levels.error, 'Not allowed to speak on the XMPP MUC of bridge '+str(b)+', stopping it', send_to_admins=True)
420 b.stop(message='Not allowed to speak on the XMPP MUC, stopping the bridge') 428 b.stop(message='Not allowed to speak on the XMPP MUC, stopping the bridge')