Allow gaps in relay numbering

This commit is contained in:
2022-08-11 19:22:09 +01:00
parent 4c8b584ef4
commit 502b45cda5
8 changed files with 86 additions and 40 deletions

View File

@@ -1,4 +1,5 @@
import main
from modules import helpers
class ListCommand:
@@ -9,27 +10,24 @@ class ListCommand:
if authed:
if length == 1:
for i in main.network.keys():
if 1 not in main.network[i].relays.keys():
first_relay = helpers.get_first_relay(i)
####
if not first_relay:
info("Network has no first instance: %s" % i)
continue
if not i + "1" in main.IRCPool.keys():
info("No IRC instance: %s - 1" % i)
continue
main.IRCPool[i + "1"].list()
success("Requested list with first instance of %s" % i)
first_relay.list()
success(f"Requested list with instance {first_relay.num} of {i}")
return
elif length == 2:
if not spl[1] in main.network.keys():
failure("No such network: %s" % spl[1])
return
if 1 not in main.network[spl[1]].relays.keys():
failure("Network has no first instance")
first_relay = helpers.get_first_relay(spl[1])
if not first_relay:
failure("Could not get first instance")
return
if spl[1] + "1" not in main.IRCPool.keys():
failure("No IRC instance: %s - 1" % spl[1])
return
main.IRCPool[spl[1] + "1"].list()
success("Requested list with first instance of %s" % spl[1])
first_relay.list()
success(f"Requested list with instance {first_relay.num} of {spl[1]}")
return
else:
incUsage("list")