2018-03-14 20:13:40 +00:00
|
|
|
import main
|
2019-01-26 18:58:21 +00:00
|
|
|
from core.helper import startBot
|
|
|
|
from core.bot import deliverRelayCommands
|
2018-02-23 22:05:40 +00:00
|
|
|
|
|
|
|
class Enable:
|
2019-01-26 18:58:21 +00:00
|
|
|
def __init__(self, *args):
|
|
|
|
self.enable(*args)
|
2018-02-23 22:05:40 +00:00
|
|
|
|
|
|
|
def enable(self, addr, authed, data, obj, spl, success, failure, info, incUsage, length):
|
|
|
|
if authed:
|
|
|
|
if length == 2:
|
2018-04-21 13:44:07 +00:00
|
|
|
if not spl[1] in main.pool.keys():
|
2018-02-23 22:05:40 +00:00
|
|
|
failure("Name does not exist: %s" % spl[1])
|
|
|
|
return
|
2018-03-14 20:13:40 +00:00
|
|
|
main.pool[spl[1]]["enabled"] = True
|
2019-01-26 18:58:21 +00:00
|
|
|
user = main.pool[spl[1]]["alias"]
|
|
|
|
network = main.pool[spl[1]]["network"]
|
|
|
|
relay = main.pool[spl[1]]["relay"]
|
|
|
|
commands = {"status": ["Connect"]}
|
|
|
|
deliverRelayCommands(relay, commands, user=user+"/"+network)
|
2018-03-14 20:13:40 +00:00
|
|
|
main.saveConf("pool")
|
|
|
|
if not spl[1] in main.IRCPool.keys():
|
2019-01-26 18:58:21 +00:00
|
|
|
startBot(spl[1])
|
2018-02-23 22:05:40 +00:00
|
|
|
else:
|
|
|
|
pass
|
|
|
|
success("Successfully enabled bot %s" % spl[1])
|
|
|
|
return
|
|
|
|
else:
|
|
|
|
incUsage("enable")
|
|
|
|
return
|
|
|
|
else:
|
|
|
|
incUsage(None)
|