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 DisableCommand:
|
2019-01-26 18:58:21 +00:00
|
|
|
def __init__(self, *args):
|
|
|
|
self.disable(*args)
|
2018-02-23 22:05:40 +00:00
|
|
|
|
2022-09-05 06:20:30 +00:00
|
|
|
def disable(
|
|
|
|
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-09-28 18:46:10 +00:00
|
|
|
if not spl[2].isdigit():
|
2019-09-29 13:57:36 +00:00
|
|
|
failure("Must be a number, not %s" % spl[2])
|
2019-09-28 18:46:10 +00:00
|
|
|
return
|
|
|
|
relayNum = int(spl[2])
|
2022-07-21 12:39:41 +00:00
|
|
|
name = spl[1] + spl[2]
|
2019-09-28 18:46:10 +00:00
|
|
|
if not spl[1] in main.IRCPool.keys():
|
|
|
|
info("Note - instance not running, proceeding anyway")
|
2022-07-21 12:40:05 +00:00
|
|
|
if relayNum not in main.network[spl[1]].relays.keys():
|
2019-08-11 20:58:14 +00:00
|
|
|
failure("No such relay: %s in network %s" % (spl[2], spl[1]))
|
|
|
|
return
|
2019-09-28 18:46:10 +00:00
|
|
|
main.network[spl[1]].relays[relayNum]["enabled"] = False
|
2019-09-29 21:45:16 +00:00
|
|
|
user = main.alias[relayNum]["nick"]
|
2019-08-11 20:58:14 +00:00
|
|
|
network = spl[1]
|
2022-07-21 12:40:05 +00:00
|
|
|
# relay = main.network[spl[1]].relays[relayNum]
|
2019-01-26 18:58:21 +00:00
|
|
|
commands = {"status": ["Disconnect"]}
|
2022-07-21 12:39:41 +00:00
|
|
|
deliverRelayCommands(relayNum, commands, user=user + "/" + network)
|
2019-08-11 20:58:14 +00:00
|
|
|
main.saveConf("network")
|
2019-09-28 18:46:10 +00:00
|
|
|
if name in main.ReactorPool.keys():
|
|
|
|
if name in main.FactoryPool.keys():
|
|
|
|
main.FactoryPool[name].stopTrying()
|
|
|
|
main.ReactorPool[name].disconnect()
|
2019-10-02 19:26:05 +00:00
|
|
|
if name in main.IRCPool.keys():
|
2019-09-28 18:46:10 +00:00
|
|
|
del main.IRCPool[name]
|
|
|
|
del main.ReactorPool[name]
|
|
|
|
del main.FactoryPool[name]
|
2019-08-11 20:58:14 +00:00
|
|
|
success("Successfully disabled bot %s on network %s" % (spl[2], spl[1]))
|
2018-02-23 22:05:40 +00:00
|
|
|
return
|
|
|
|
else:
|
|
|
|
incUsage("disable")
|
|
|
|
return
|
|
|
|
else:
|
|
|
|
incUsage(None)
|