2018-03-14 20:13:40 +00:00
|
|
|
import main
|
2022-07-21 12:40:05 +00:00
|
|
|
from utils.deliver_relay_commands import deliverRelayCommands
|
2018-02-23 22:05:40 +00:00
|
|
|
|
2022-07-21 12:39:41 +00:00
|
|
|
|
2019-08-09 22:06:34 +00:00
|
|
|
class EnableCommand:
|
2019-01-26 18:58:21 +00:00
|
|
|
def __init__(self, *args):
|
|
|
|
self.enable(*args)
|
2018-02-23 22:05:40 +00:00
|
|
|
|
2022-09-05 06:20:30 +00:00
|
|
|
def enable(
|
|
|
|
self, addr, authed, data, obj, spl, success, failure, info, incUsage, length
|
|
|
|
):
|
2018-02-23 22:05:40 +00:00
|
|
|
if authed:
|
2019-08-11 20:58:14 +00:00
|
|
|
if length == 3:
|
|
|
|
if not spl[1] in main.network.keys():
|
|
|
|
failure("No such network: %s" % spl[1])
|
2018-02-23 22:05:40 +00:00
|
|
|
return
|
2019-08-25 20:29:11 +00:00
|
|
|
if not spl[2].isdigit():
|
|
|
|
failure("Must be a number, not %s" % spl[2])
|
|
|
|
return
|
2019-08-11 20:58:14 +00:00
|
|
|
if not int(spl[2]) in main.network[spl[1]].relays.keys():
|
2019-08-25 20:29:11 +00:00
|
|
|
failure("No such relay on %s: %s" % (spl[2], spl[1]))
|
2019-08-11 20:58:14 +00:00
|
|
|
return
|
|
|
|
|
|
|
|
main.network[spl[1]].relays[int(spl[2])]["enabled"] = True
|
2019-09-29 21:45:16 +00:00
|
|
|
user = main.alias[int(spl[2])]["nick"]
|
2019-08-11 20:58:14 +00:00
|
|
|
network = spl[1]
|
2019-01-26 18:58:21 +00:00
|
|
|
commands = {"status": ["Connect"]}
|
2022-07-21 12:39:41 +00:00
|
|
|
deliverRelayCommands(int(spl[2]), commands, user=user + "/" + network)
|
2019-08-11 20:58:14 +00:00
|
|
|
main.saveConf("network")
|
2022-07-21 12:39:41 +00:00
|
|
|
if not spl[1] + spl[2] in main.IRCPool.keys():
|
2019-08-11 20:58:14 +00:00
|
|
|
main.network[spl[1]].start_bot(int(spl[2]))
|
2018-02-23 22:05:40 +00:00
|
|
|
else:
|
|
|
|
pass
|
2019-08-11 20:58:14 +00:00
|
|
|
success("Successfully enabled bot %s on network %s" % (spl[2], spl[1]))
|
2018-02-23 22:05:40 +00:00
|
|
|
return
|
|
|
|
else:
|
|
|
|
incUsage("enable")
|
|
|
|
return
|
|
|
|
else:
|
|
|
|
incUsage(None)
|