2019-10-12 20:05:55 +00:00
|
|
|
import main
|
2022-08-11 18:22:09 +00:00
|
|
|
from modules import helpers
|
2019-10-12 20:05:55 +00:00
|
|
|
|
2022-07-21 12:39:41 +00:00
|
|
|
|
2019-10-12 20:05:55 +00:00
|
|
|
class ListCommand:
|
|
|
|
def __init__(self, *args):
|
|
|
|
self.list(*args)
|
|
|
|
|
2022-09-05 06:20:30 +00:00
|
|
|
def list(
|
|
|
|
self, addr, authed, data, obj, spl, success, failure, info, incUsage, length
|
|
|
|
):
|
2019-10-12 20:05:55 +00:00
|
|
|
if authed:
|
2020-05-31 12:08:00 +00:00
|
|
|
if length == 1:
|
|
|
|
for i in main.network.keys():
|
2022-08-11 18:22:09 +00:00
|
|
|
first_relay = helpers.get_first_relay(i)
|
|
|
|
####
|
|
|
|
if not first_relay:
|
2020-05-31 12:08:00 +00:00
|
|
|
info("Network has no first instance: %s" % i)
|
|
|
|
continue
|
2022-08-11 18:22:09 +00:00
|
|
|
first_relay.list()
|
|
|
|
success(f"Requested list with instance {first_relay.num} of {i}")
|
2020-05-31 12:08:00 +00:00
|
|
|
return
|
|
|
|
elif length == 2:
|
2019-10-12 20:05:55 +00:00
|
|
|
if not spl[1] in main.network.keys():
|
|
|
|
failure("No such network: %s" % spl[1])
|
|
|
|
return
|
2022-08-11 18:22:09 +00:00
|
|
|
first_relay = helpers.get_first_relay(spl[1])
|
|
|
|
if not first_relay:
|
|
|
|
failure("Could not get first instance")
|
2019-10-12 20:05:55 +00:00
|
|
|
return
|
2022-08-11 18:22:09 +00:00
|
|
|
first_relay.list()
|
|
|
|
success(f"Requested list with instance {first_relay.num} of {spl[1]}")
|
2019-10-12 20:05:55 +00:00
|
|
|
return
|
|
|
|
else:
|
|
|
|
incUsage("list")
|
|
|
|
return
|
|
|
|
else:
|
|
|
|
incUsage(None)
|