Added check for webhook file existing but empty.

This commit is contained in:
ArabCoders 2024-01-07 16:50:54 +03:00
parent 1fbc52f4aa
commit 4dbc6b44d4

View file

@ -14,10 +14,14 @@ class Webhooks:
def __init__(self, file: str):
if os.path.exists(file):
try:
if os.path.getsize(file) < 2:
raise Exception(f'file is empty.')
log.info(f'Loading webhooks from {file}')
with open(file, 'r') as f:
self.targets = json.load(f)
except Exception as e:
log.error(f'Error loading webhooks from {file}: {e}')
pass
async def send(self, event: str, item: ItemDTO) -> list[dict]: