Mercurial > xib
diff start_bots_from_xml_config.py @ 155:63db565438bd
fixed the halt command
Signed-off-by: Charly COSTE <changaco@changaco.net>
author | Charly COSTE <changaco@changaco.net> |
---|---|
date | Sun, 17 Jan 2010 23:24:00 +0100 |
parents | e0eea72ea493 |
children | c021656e4c54 |
line wrap: on
line diff
--- a/start_bots_from_xml_config.py +++ b/start_bots_from_xml_config.py @@ -58,26 +58,45 @@ try: for bridge_el in bot_el.getElementsByTagName('bridge'): xmpp_room = bridge_el.getElementsByTagName('xmpp-room')[0] irc = bridge_el.getElementsByTagName('irc')[0] + irc_connection_interval = 1 if irc.hasAttribute('connection_interval'): try: irc_connection_interval = float(irc.getAttribute('connection_interval')) except ValueError: print '[Error] the value of connection_interval must be a number' - say_level = 'all' + if bridge_el.hasAttribute('say_level'): say_level = bridge_el.getAttribute('say_level') + else: + say_level = 'all' + if bridge_el.hasAttribute('mode'): mode = bridge_el.getAttribute('mode') else: mode = 'normal' + bot.new_bridge(xmpp_room.getAttribute('jid'), irc.getAttribute('chan'), irc.getAttribute('server'), mode, say_level, irc_connection_interval=irc_connection_interval) + if len(bots) == 0: + print 'No bots in the configuration file, exiting ...' + exit(0) + while True: - sleep(1) + for bot in bots: + if len(bot.xmpp_connections) == 0: + bots.remove(bot) + if len(bots) == 0: + raise Exception() + sleep(10) except: + if len(bots) == 0: + print 'All bots have been shut down, exiting ...' + exit(0) + for bot in bots: + bots.remove(bot) del bot traceback.print_exc() quit(3) \ No newline at end of file