monolith/legacy/commands/cmd.py

23 lines
761 B
Python
Raw Normal View History

2022-07-21 12:40:05 +00:00
from utils.deliver_relay_commands import deliverRelayCommands
2022-07-21 12:39:41 +00:00
class CmdCommand:
def __init__(self, *args):
self.cmd(*args)
def cmd(self, addr, authed, data, obj, spl, success, failure, info, incUsage, length):
if authed:
if length > 4:
if not spl[1].isdigit():
failure("Must be a number, not %s" % spl[1])
return
commands = {spl[3]: [" ".join(spl[4:])]}
success("Sending commands to relay %s as user %s" % (spl[2], spl[3]))
deliverRelayCommands(int(spl[1]), commands, user=spl[2])
return
else:
incUsage("cmd")
return
else:
incUsage(None)