Improvements to query and self event detection, implement all command and debug flags
parent
1ec0e1f7e6
commit
f34ddab6fc
@ -0,0 +1,23 @@
|
|||||||
|
import main
|
||||||
|
from core.bot import deliverRelayCommands
|
||||||
|
|
||||||
|
class All:
|
||||||
|
def __init__(self, *args):
|
||||||
|
self.all(*args)
|
||||||
|
|
||||||
|
def all(self, addr, authed, data, obj, spl, success, failure, info, incUsage, length):
|
||||||
|
if authed:
|
||||||
|
if length > 2:
|
||||||
|
for i in main.pool.keys():
|
||||||
|
relay = main.pool[i]["relay"]
|
||||||
|
network = main.pool[i]["network"]
|
||||||
|
alias = main.pool[i]["alias"]
|
||||||
|
commands = {spl[1]: [" ".join(spl[2:])]}
|
||||||
|
success("Sending commands to relay %s as user %s" % (relay, alias+"/"+network))
|
||||||
|
deliverRelayCommands(relay, commands, user=alias+"/"+network)
|
||||||
|
return
|
||||||
|
else:
|
||||||
|
incUsage("all")
|
||||||
|
return
|
||||||
|
else:
|
||||||
|
incUsage(None)
|
@ -0,0 +1,21 @@
|
|||||||
|
from datetime import datetime
|
||||||
|
from csiphash import siphash24
|
||||||
|
from json import dumps
|
||||||
|
import main
|
||||||
|
from utils.logging.debug import debug
|
||||||
|
|
||||||
|
def dedup(numName, c):
|
||||||
|
# deduplication
|
||||||
|
c["approxtime"] = int(datetime.utcnow().timestamp())
|
||||||
|
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)
|
||||||
|
if isDuplicate:
|
||||||
|
debug("Duplicate: %s" % (c))
|
||||||
|
return True
|
||||||
|
if numName in main.lastEvents.keys():
|
||||||
|
main.lastEvents[numName].insert(0, castHash)
|
||||||
|
main.lastEvents[numName] = main.lastEvents[numName][0:main.config["Tweaks"]["MaxHash"]]
|
||||||
|
else:
|
||||||
|
main.lastEvents[numName] = [castHash]
|
||||||
|
return False
|
@ -0,0 +1,7 @@
|
|||||||
|
import main
|
||||||
|
# we need a seperate module to log.py, as log.py is imported by main.py, and we need to access main
|
||||||
|
# to read the setting
|
||||||
|
def debug(data):
|
||||||
|
if main.config["Debug"]:
|
||||||
|
print("[DEBUG]", data)
|
||||||
|
|
Loading…
Reference in New Issue