Renovate the module system and implement adding and resuming pool instances using the new relay/alias/network system
This commit is contained in:
@@ -1,39 +1,38 @@
|
||||
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 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"]))
|
||||
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))
|
||||
|
||||
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)
|
||||
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:
|
||||
main.ReactorPool[name] = rct
|
||||
main.FactoryPool[name] = bot
|
||||
return
|
||||
else:
|
||||
bot = IRCBotFactory(name)
|
||||
rct = reactor.connectSSL(host,
|
||||
port,
|
||||
bot, contextFactory)
|
||||
|
||||
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
|
||||
|
||||
main.ReactorPool[name] = rct
|
||||
main.FactoryPool[name] = bot
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user