Rework data structures, storing all front-end network data in Network objects

This commit is contained in:
Al Beano
2019-08-11 21:58:14 +01:00
parent f6657cb905
commit e5adcfef4c
24 changed files with 258 additions and 284 deletions

View File

@@ -1,5 +1,4 @@
import main
from core.helper import startBot
from core.bot import deliverRelayCommands
class EnableCommand:
@@ -8,22 +7,26 @@ class EnableCommand:
def enable(self, addr, authed, data, obj, spl, success, failure, info, incUsage, length):
if authed:
if length == 2:
if not spl[1] in main.pool.keys():
failure("Name does not exist: %s" % spl[1])
if length == 3:
if not spl[1] in main.network.keys():
failure("No such network: %s" % spl[1])
return
main.pool[spl[1]]["enabled"] = True
user = main.pool[spl[1]]["alias"]
network = main.pool[spl[1]]["network"]
relay = main.pool[spl[1]]["relay"]
if not int(spl[2]) in main.network[spl[1]].relays.keys():
failure("No such relay: %s in network %s" % (spl[2], spl[1]))
return
main.network[spl[1]].relays[int(spl[2])]["enabled"] = True
user = main.network[spl[1]].aliases[int(spl[2])]
network = spl[1]
relay = main.network[spl[1]].relays[int(spl[2])]
commands = {"status": ["Connect"]}
deliverRelayCommands(relay, commands, user=user+"/"+network)
main.saveConf("pool")
if not spl[1] in main.IRCPool.keys():
startBot(spl[1])
main.saveConf("network")
if not spl[1]+spl[2] in main.IRCPool.keys():
main.network[spl[1]].start_bot(int(spl[2]))
else:
pass
success("Successfully enabled bot %s" % spl[1])
success("Successfully enabled bot %s on network %s" % (spl[2], spl[1]))
return
else:
incUsage("enable")