PageRenderTime 31ms CodeModel.GetById 17ms app.highlight 9ms RepoModel.GetById 1ms app.codeStats 0ms

/python_bot/hopmod_bot.tac

http://suckerserv.googlecode.com/
Unknown | 28 lines | 19 code | 9 blank | 0 comment | 0 complexity | 9f1fbebd58aa2de7a328c779dbeca6bb MD5 | raw file
 1import sys
 2
 3from twisted.application import service, internet
 4
 5from config import irc_identity, irc_nickname, servers, stats_url
 6from controller import Controller
 7from irc_client import HMIRCFactory
 8from server_client import HMServerFactory
 9
10application = service.Application('Hopmod irc bot')
11
12c = Controller(irc_identity, servers)
13f = HMIRCFactory(c, irc_nickname)
14f.stats_url = stats_url
15
16internet.TCPClient(irc_identity['host'], irc_identity['port'], f).setServiceParent(application)
17
18for name, server in servers.iteritems():
19    formatted_name = (server['format'] % name) if 'format' in server else name
20
21    f = HMServerFactory(c, name, formatted_name, server['password'])
22    if 'reconnect_time' in server:
23        f.reconnect_time = server['reconnect_time']
24    if 'admin_channel' in server:
25        f.admin_channel  = server['admin_channel']
26
27    internet.TCPClient(server['host'], server['port'], f).setServiceParent(application)
28