from twisted.internet import reactor from core.bot import IRCBot, IRCBotFactory from twisted.internet.ssl import DefaultOpenSSLContextFactory import main from utils.logging.log import * def startBot(name): inst = main.pool[name] relay, alias, network = inst["relay"], inst["alias"], inst["network"] host = main.relay[relay]["host"] port = int(main.relay[relay]["port"]) log("Started bot %s to %s network %s" % (name, relay, network)) keyFN = main.certPath+main.config["Key"] certFN = main.certPath+main.config["Certificate"] contextFactory = DefaultOpenSSLContextFactory(keyFN.encode("utf-8", "replace"), certFN.encode("utf-8", "replace")) if "bind" in main.relay[relay].keys(): bot = IRCBotFactory(name) rct = reactor.connectSSL(host, port, bot, contextFactory, bindAddress=main.relay[relay]["bind"]) main.ReactorPool[name] = rct main.FactoryPool[name] = bot return else: bot = IRCBotFactory(name) rct = reactor.connectSSL(host, port, bot, contextFactory) main.ReactorPool[name] = rct main.FactoryPool[name] = bot return