2019-01-26 18:58:21 +00:00
|
|
|
import main
|
|
|
|
from core.bot import deliverRelayCommands
|
|
|
|
|
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)
|
|
|
|
|
|
|
|
def cmd(self, addr, authed, data, obj, spl, success, failure, info, incUsage, length):
|
|
|
|
if authed:
|
|
|
|
if length > 4:
|
2019-08-11 20:58:14 +00:00
|
|
|
if not spl[1] in main.network.keys():
|
|
|
|
failure("No such network: %s" % spl[1])
|
|
|
|
return
|
|
|
|
if not int(spl[2]) in main.network[spl[1]].relays.keys():
|
|
|
|
failure("No such relay: %s on network: %s" % (spl[2], spl[1]))
|
2019-01-26 18:58:21 +00:00
|
|
|
return
|
|
|
|
|
2019-08-11 20:58:14 +00:00
|
|
|
commands = {spl[4]: [" ".join(spl[5:])]}
|
|
|
|
success("Sending commands to relay %s as user %s" % (spl[2], spl[3]))
|
|
|
|
deliverRelayCommands(main.network[spl[1]].relays[spl[2]], commands, user=spl[3]+"/"+spl[1])
|
2019-01-26 18:58:21 +00:00
|
|
|
return
|
|
|
|
else:
|
|
|
|
incUsage("cmd")
|
|
|
|
return
|
|
|
|
else:
|
|
|
|
incUsage(None)
|