2022-07-21 12:40:05 +00:00
|
|
|
from utils.deliver_relay_commands import deliverRelayCommands
|
2019-01-26 18:58:21 +00:00
|
|
|
|
2022-07-21 12:39:41 +00:00
|
|
|
|
2019-08-09 22:06:34 +00:00
|
|
|
class CmdCommand:
|
2019-01-26 18:58:21 +00:00
|
|
|
def __init__(self, *args):
|
|
|
|
self.cmd(*args)
|
|
|
|
|
2022-09-05 06:20:30 +00:00
|
|
|
def cmd(
|
|
|
|
self, addr, authed, data, obj, spl, success, failure, info, incUsage, length
|
|
|
|
):
|
2019-01-26 18:58:21 +00:00
|
|
|
if authed:
|
|
|
|
if length > 4:
|
2019-08-25 20:29:11 +00:00
|
|
|
if not spl[1].isdigit():
|
2019-09-29 13:57:36 +00:00
|
|
|
failure("Must be a number, not %s" % spl[1])
|
2019-08-11 20:58:14 +00:00
|
|
|
return
|
2019-08-25 20:29:11 +00:00
|
|
|
commands = {spl[3]: [" ".join(spl[4:])]}
|
2019-08-11 20:58:14 +00:00
|
|
|
success("Sending commands to relay %s as user %s" % (spl[2], spl[3]))
|
2019-08-25 20:29:11 +00:00
|
|
|
deliverRelayCommands(int(spl[1]), commands, user=spl[2])
|
2019-01-26 18:58:21 +00:00
|
|
|
return
|
|
|
|
else:
|
|
|
|
incUsage("cmd")
|
|
|
|
return
|
|
|
|
else:
|
|
|
|
incUsage(None)
|