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

@@ -6,21 +6,25 @@ class DelCommand:
def delete(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
del main.pool[spl[1]]
if spl[1] in main.ReactorPool.keys():
if spl[1] in main.FactoryPool.keys():
main.FactoryPool[spl[1]].stopTrying()
main.ReactorPool[spl[1]].disconnect()
if spl[1] in main.IRCPool.keys():
del main.IRCPool[spl[1]]
del main.ReactorPool[spl[1]]
del main.FactoryPool[spl[1]]
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]].delete_relay(int(spl[2]))
if spl[1]+spl[2] in main.ReactorPool.keys():
if spl[1]+spl[2] in main.FactoryPool.keys():
main.FactoryPool[spl[1]+spl[2]].stopTrying()
main.ReactorPool[spl[1]+spl[2]].disconnect()
if spl[1]+spl[2] in main.IRCPool.keys():
del main.IRCPool[spl[1]+spl[2]]
del main.ReactorPool[spl[1]+spl[2]]
del main.FactoryPool[spl[1]+spl[2]]
success("Successfully removed bot: %s" % spl[1])
main.saveConf("pool")
main.saveConf("network")
return
else:
incUsage("del")