2019-08-16 20:27:23 +00:00
|
|
|
import main
|
|
|
|
from core.bot import deliverRelayCommands
|
|
|
|
|
2019-09-29 13:57:36 +00:00
|
|
|
class AllcCommand:
|
2019-08-16 20:27:23 +00:00
|
|
|
def __init__(self, *args):
|
|
|
|
self.allc(*args)
|
|
|
|
|
|
|
|
def allc(self, addr, authed, data, obj, spl, success, failure, info, incUsage, length):
|
|
|
|
if authed:
|
|
|
|
if length > 4:
|
|
|
|
targets = []
|
|
|
|
if spl[1] == "network":
|
2019-09-29 13:57:36 +00:00
|
|
|
for i in main.network.keys():
|
|
|
|
for x in main.network[i].relays.keys():
|
|
|
|
if main.network[i].relays[x]["net"] == spl[2]:
|
|
|
|
targets.append((i, x))
|
2019-08-16 20:27:23 +00:00
|
|
|
elif spl[1] == "alias":
|
2019-09-29 13:57:36 +00:00
|
|
|
for i in main.network.keys():
|
2019-09-29 21:45:16 +00:00
|
|
|
[targets.append((i, x)) for x in main.alias.keys() if
|
|
|
|
main.alias[x]["nick"] == spl[2] and
|
|
|
|
x in main.network[i].aliases.keys()]
|
2019-08-16 20:27:23 +00:00
|
|
|
else:
|
|
|
|
incUsage("allc")
|
|
|
|
return
|
|
|
|
if len(targets) == 0:
|
|
|
|
failure("No matches found: %s" % spl[2])
|
|
|
|
return
|
|
|
|
for i in targets:
|
2019-09-29 13:57:36 +00:00
|
|
|
net = i[0]
|
|
|
|
num = i[1]
|
2019-09-29 21:45:16 +00:00
|
|
|
alias = main.alias[num]["nick"]
|
2019-08-16 20:27:23 +00:00
|
|
|
commands = {spl[3]: [" ".join(spl[4:])]}
|
2019-09-29 13:57:36 +00:00
|
|
|
success("Sending commands to relay %i as user %s" % (num, alias+"/"+net))
|
|
|
|
deliverRelayCommands(num, commands, user=alias+"/"+net)
|
2019-08-16 20:27:23 +00:00
|
|
|
return
|
|
|
|
else:
|
|
|
|
incUsage("allc")
|
|
|
|
return
|
|
|
|
else:
|
|
|
|
incUsage(None)
|