Add deduplication precision toggle, fix printing odd characters and implement sending messages to all instances of a certain network, or all networks associated with a certain alias
parent
22bd0d3ac6
commit
545282e201
@ -0,0 +1,46 @@
|
||||
import main
|
||||
from core.bot import deliverRelayCommands
|
||||
|
||||
class Allc:
|
||||
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":
|
||||
if spl[2] in main.network.keys():
|
||||
for i in main.pool.keys():
|
||||
if main.pool[i]["network"] == spl[2]:
|
||||
targets.append(i)
|
||||
else:
|
||||
failure("No such network: %s" % spl[2])
|
||||
return
|
||||
elif spl[1] == "alias":
|
||||
if spl[2] in main.alias.keys():
|
||||
for i in main.pool.keys():
|
||||
if main.pool[i]["alias"] == spl[2]:
|
||||
targets.append(i)
|
||||
else:
|
||||
failure("No such alias: %s" % spl[2])
|
||||
return
|
||||
else:
|
||||
incUsage("allc")
|
||||
return
|
||||
if len(targets) == 0:
|
||||
failure("No matches found: %s" % spl[2])
|
||||
return
|
||||
for i in targets:
|
||||
relay = main.pool[i]["relay"]
|
||||
network = main.pool[i]["network"]
|
||||
alias = main.pool[i]["alias"]
|
||||
commands = {spl[3]: [" ".join(spl[4:])]}
|
||||
success("Sending commands to relay %s as user %s" % (relay, alias+"/"+network))
|
||||
deliverRelayCommands(relay, commands, user=alias+"/"+network)
|
||||
return
|
||||
else:
|
||||
incUsage("allc")
|
||||
return
|
||||
else:
|
||||
incUsage(None)
|
Loading…
Reference in New Issue