Revert "Reformat project"

This reverts commit 64e3e1160aa76d191740342ab3edc68807f890fb.
This commit is contained in:
2022-07-21 13:40:01 +01:00
parent 760e43b59a
commit 3229d9b806
57 changed files with 214 additions and 519 deletions

View File

@@ -1,10 +1,8 @@
import sys
from twisted.internet import reactor
import main
from twisted.internet import reactor
from utils.logging.debug import debug
from utils.logging.log import *
import sys
def handler(sig, frame):

View File

@@ -1,9 +1,7 @@
from copy import deepcopy
from datetime import datetime
from json import dumps
from csiphash import siphash24
from copy import deepcopy
from json import dumps
import main
from utils.logging.debug import debug
@@ -12,24 +10,16 @@ def dedup(numName, b):
c = deepcopy(b)
if "ts" in c.keys():
del c["ts"]
c["approxtime"] = str(datetime.utcnow().timestamp())[
: main.config["Tweaks"]["DedupPrecision"]
]
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
)
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"]
]
main.lastEvents[numName] = main.lastEvents[numName][0 : main.config["Tweaks"]["MaxHash"]]
else:
main.lastEvents[numName] = [castHash]
return False

View File

@@ -1,9 +1,10 @@
from os import listdir
import commands
from main import CommandMap
from utils.logging.debug import debug
from utils.logging.log import *
import commands
from main import CommandMap
def loadCommands(allowDup=False):
@@ -14,15 +15,11 @@ def loadCommands(allowDup=False):
try:
module = __import__("commands.%s" % commandName)
if not commandName in CommandMap:
CommandMap[commandName] = getattr(
getattr(module, commandName), className
)
CommandMap[commandName] = getattr(getattr(module, commandName), className)
debug("Registered command: %s" % commandName)
else:
if allowDup:
CommandMap[commandName] = getattr(
getattr(module, commandName), className
)
CommandMap[commandName] = getattr(getattr(module, commandName), className)
debug("Registered command: %s" % commandName)
error("Duplicate command: %s" % (commandName))

View File

@@ -1,11 +1,12 @@
import sys
from importlib import reload
from os import listdir
from importlib import reload
import sys
import commands
from main import CommandMap
from utils.logging.debug import debug
from utils.logging.log import *
import commands
from main import CommandMap
def loadSingle(commandName):
@@ -14,9 +15,7 @@ def loadSingle(commandName):
try:
if commandName in CommandMap.keys():
reload(sys.modules["commands." + commandName])
CommandMap[commandName] = getattr(
sys.modules["commands." + commandName], className
)
CommandMap[commandName] = getattr(sys.modules["commands." + commandName], className)
debug("Reloaded command: %s" % commandName)
return "RELOAD"
module = __import__("commands.%s" % commandName)

View File

@@ -1,6 +1,5 @@
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):