2022-07-21 12:39:59 +00:00
|
|
|
import main
|
|
|
|
|
2022-07-21 12:39:41 +00:00
|
|
|
|
2019-08-09 22:06:34 +00:00
|
|
|
class ModCommand:
|
2019-08-11 20:58:14 +00:00
|
|
|
# This could be greatly improved, but not really important right now
|
2019-01-26 18:58:21 +00:00
|
|
|
def __init__(self, *args):
|
|
|
|
self.mod(*args)
|
2018-02-23 22:05:40 +00:00
|
|
|
|
2022-09-05 06:20:30 +00:00
|
|
|
def mod(
|
|
|
|
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 == 4:
|
|
|
|
if not spl[1] in main.network.keys():
|
|
|
|
failure("Network does not exist: %s" % spl[1])
|
2018-02-23 22:05:40 +00:00
|
|
|
return
|
|
|
|
|
2019-08-11 20:58:14 +00:00
|
|
|
try:
|
|
|
|
setattr(main.network[spl[1]], spl[2], spl[3])
|
2022-07-21 12:40:05 +00:00
|
|
|
except Exception as e:
|
|
|
|
failure(f"Something went wrong: {e}")
|
2018-02-23 22:05:40 +00:00
|
|
|
return
|
2019-08-11 20:58:14 +00:00
|
|
|
|
|
|
|
main.saveConf("network")
|
2022-09-05 06:20:30 +00:00
|
|
|
success(
|
|
|
|
"Successfully set key %s to %s on %s" % (spl[2], spl[3], spl[1])
|
|
|
|
)
|
2018-02-23 22:05:40 +00:00
|
|
|
return
|
2019-09-29 21:45:16 +00:00
|
|
|
# Find a better way to do this
|
2022-07-21 12:39:41 +00:00
|
|
|
# elif length == 6:
|
2019-09-29 21:45:16 +00:00
|
|
|
# if not spl[1] in main.network.keys():
|
|
|
|
# failure("Network does not exist: %s" % spl[1])
|
|
|
|
# return
|
|
|
|
# if not spl[3].isdigit():
|
|
|
|
# failure("Must be a number, not %s" % spl[3])
|
|
|
|
# return
|
|
|
|
# if not int(spl[3]) in main.network[spl[1]].relays.keys():
|
|
|
|
# failure("Relay/alias does not exist: %s" % spl[3])
|
|
|
|
# return
|
2018-02-23 22:05:40 +00:00
|
|
|
|
2019-09-29 21:45:16 +00:00
|
|
|
# try:
|
|
|
|
# x = getattr(main.network[spl[1]], spl[2])
|
|
|
|
# x[spl[3]] = spl[4]
|
|
|
|
# except Exception as err:
|
|
|
|
# failure("Error: %s" % err)
|
|
|
|
# return
|
2018-02-23 22:05:40 +00:00
|
|
|
|
|
|
|
else:
|
|
|
|
incUsage("mod")
|
|
|
|
return
|
|
|
|
else:
|
|
|
|
incUsage(None)
|