from twisted.internet import reactor from core.bot import IRCBot, IRCBotFactory import main from utils.logging.log import * def addBot(name): instance = main.pool[name] log("Started bot %s to %s:%s protocol %s nickname %s" % (name, instance["host"], instance["port"], instance["protocol"], instance["nickname"])) if instance["protocol"] == "ssl": 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 instance["bind"] == None: bot = IRCBotFactory(name) rct = reactor.connectSSL(instance["host"], int(instance["port"]), bot, contextFactory) main.ReactorPool[name] = rct main.FactoryPool[name] = bot return else: bot = IRCBotFactory(name) rct = reactor.connectSSL(instance["host"], int(instance["port"]), bot, contextFactory, bindAddress=instance["bind"]) main.ReactorPool[name] = rct main.FactoryPool[name] = bot return