diff --git a/commands/allc.py b/commands/allc.py new file mode 100644 index 0000000..9e662fe --- /dev/null +++ b/commands/allc.py @@ -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) diff --git a/conf/example/config.json b/conf/example/config.json index 5ecb53f..a595963 100644 --- a/conf/example/config.json +++ b/conf/example/config.json @@ -28,6 +28,7 @@ "Password": "s", "Tweaks": { "MaxHash": 10, + "DedupPrecision": 9, "ZNC": { "Prefix": "*" }, diff --git a/conf/help.json b/conf/help.json index 522f00e..1e55f3a 100644 --- a/conf/help.json +++ b/conf/help.json @@ -25,5 +25,6 @@ "provision": "provision []", "cmd": "cmd ", "token": "token [] []", - "all": "all " + "all": "all ", + "allc": "allc <(network)|(alias)> " } diff --git a/threshold b/threshold index 648ed4f..d63a8b2 100755 --- a/threshold +++ b/threshold @@ -1,11 +1,14 @@ #!/usr/bin/env python from twisted.internet import reactor from twisted.internet.ssl import DefaultOpenSSLContextFactory -from sys import argv +from sys import argv, stdout, stderr #from twisted.python import log #from sys import stdout #log.startLogging(stdout) - +from codecs import getwriter # fix printing odd shit to the terminal +stdout = getwriter("utf8")(stdout) # this is a generic fix but we all know +stderr = getwriter("utf8")(stderr) # it's just for the retards on Rizon using + # unicode quit messages for no reason import main main.initMain() diff --git a/utils/dedup.py b/utils/dedup.py index ee07bb5..03255e3 100644 --- a/utils/dedup.py +++ b/utils/dedup.py @@ -6,7 +6,7 @@ from utils.logging.debug import debug def dedup(numName, c): # deduplication - c["approxtime"] = int(datetime.utcnow().timestamp()) + c["approxtime"] = str(datetime.utcnow().timestamp())[:main.config["Tweaks"]["DedupPrecision"]] castHash = siphash24(main.hashKey, dumps(c, sort_keys=True).encode("utf-8")) del c["approxtime"] isDuplicate= any(castHash in main.lastEvents[x] for x in main.lastEvents.keys() if not x == numName)