You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
1.7 KiB
Python

import main
class ModCommand:
# This could be greatly improved, but not really important right now
def __init__(self, *args):
self.mod(*args)
def mod(
self, addr, authed, data, obj, spl, success, failure, info, incUsage, length
):
if authed:
if length == 4:
if not spl[1] in main.network.keys():
failure("Network does not exist: %s" % spl[1])
return
try:
setattr(main.network[spl[1]], spl[2], spl[3])
except Exception as e:
failure(f"Something went wrong: {e}")
return
main.saveConf("network")
success(
"Successfully set key %s to %s on %s" % (spl[2], spl[3], spl[1])
)
return
# Find a better way to do this
# elif length == 6:
# 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
# try:
# x = getattr(main.network[spl[1]], spl[2])
# x[spl[3]] = spl[4]
# except Exception as err:
# failure("Error: %s" % err)
# return
else:
incUsage("mod")
return
else:
incUsage(None)