Mercurial > xib
comparison start_bots_from_xml_config.py @ 124:99f3dee1fad7
code cleaning
Signed-off-by: Charly COSTE <changaco@changaco.net>
author | Charly COSTE <changaco@changaco.net> |
---|---|
date | Wed, 13 Jan 2010 23:08:44 +0100 |
parents | bfa32b017fc9 |
children | e0eea72ea493 |
comparison
equal
deleted
inserted
replaced
123:75a03f10a863 | 124:99f3dee1fad7 |
---|---|
15 # | 15 # |
16 # You should have received a copy of the GNU General Public License | 16 # You should have received a copy of the GNU General Public License |
17 # along with this program. If not, see <http://www.gnu.org/licenses/>. | 17 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
18 | 18 |
19 | 19 |
20 from bot import bot | 20 from xml.dom.minidom import parse |
21 from time import sleep | 21 from time import sleep |
22 from xml.dom.minidom import parse | |
23 import sys | 22 import sys |
24 import traceback | 23 import traceback |
25 | 24 |
25 from bot import Bot | |
26 | 26 |
27 | 27 |
28 try: | 28 try: |
29 if len(sys.argv) > 1: | 29 if len(sys.argv) > 1: |
30 config = parse(sys.argv[1]) | 30 config = parse(sys.argv[1]) |
51 debug = True | 51 debug = True |
52 admins_jid = [] | 52 admins_jid = [] |
53 for admin_el in bot_el.getElementsByTagName('admin'): | 53 for admin_el in bot_el.getElementsByTagName('admin'): |
54 if admin_el.hasAttribute('jid'): | 54 if admin_el.hasAttribute('jid'): |
55 admins_jid.append(admin_el.getAttribute('jid')) | 55 admins_jid.append(admin_el.getAttribute('jid')) |
56 bot_ = bot(bot_el.getAttribute('jid'), bot_el.getAttribute('password'), bot_el.getAttribute('nickname'), admins_jid=admins_jid, debug=debug) | 56 bot = Bot(bot_el.getAttribute('jid'), bot_el.getAttribute('password'), bot_el.getAttribute('nickname'), admins_jid=admins_jid, debug=debug) |
57 bots.append(bot_) | 57 bots.append(bot) |
58 for bridge_el in bot_el.getElementsByTagName('bridge'): | 58 for bridge_el in bot_el.getElementsByTagName('bridge'): |
59 xmpp_room = bridge_el.getElementsByTagName('xmpp-room')[0] | 59 xmpp_room = bridge_el.getElementsByTagName('xmpp-room')[0] |
60 irc = bridge_el.getElementsByTagName('irc')[0] | 60 irc = bridge_el.getElementsByTagName('irc')[0] |
61 say_level = 'all' | 61 say_level = 'all' |
62 if bridge_el.hasAttribute('say_level'): | 62 if bridge_el.hasAttribute('say_level'): |
63 say_level = bridge_el.getAttribute('say_level') | 63 say_level = bridge_el.getAttribute('say_level') |
64 if bridge_el.hasAttribute('mode'): | 64 if bridge_el.hasAttribute('mode'): |
65 mode = bridge_el.getAttribute('mode') | 65 mode = bridge_el.getAttribute('mode') |
66 else: | 66 else: |
67 mode = 'normal' | 67 mode = 'normal' |
68 bridge_ = bot_.new_bridge(xmpp_room.getAttribute('jid'), irc.getAttribute('chan'), irc.getAttribute('server'), mode, say_level) | 68 bot.new_bridge(xmpp_room.getAttribute('jid'), irc.getAttribute('chan'), irc.getAttribute('server'), mode, say_level) |
69 | 69 |
70 | 70 |
71 while True: | 71 while True: |
72 sleep(1) | 72 sleep(1) |
73 except: | 73 except: |