Fixed leeks

This commit is contained in:
Frisk 2024-09-15 19:38:42 +02:00
parent 5927c65c70
commit 4a07582d5d

View file

@ -1,6 +1,7 @@
import asyncio import asyncio
import collections import collections
import logging import logging
import re
from typing import Union, Optional from typing import Union, Optional
from src.database import db from src.database import db
@ -14,8 +15,14 @@ class UpdateDB:
self.updated: list[tuple[str, tuple[Union[str, int], ...]]] = [] self.updated: list[tuple[str, tuple[Union[str, int], ...]]] = []
def json(self): def json(self):
def remove_webhooks(arg):
re_match = re.match(r"^(\d{17,20})/[a-zA-Z0-9_-]{68}$", arg)
if re_match is not None:
return f"{re_match.group(1)}/[CENSORED DISCORD WEBHOOK TOKEN]"
else:
return arg
# since pickled Discord messages are bytes object which is not serializable, we strip it here # since pickled Discord messages are bytes object which is not serializable, we strip it here
return [(item[0], [arg for arg in item[1] if not isinstance(arg, bytes)]) for item in self.updated] return [(item[0], [remove_webhooks(arg) for arg in item[1] if not isinstance(arg, bytes)]) for item in self.updated]
def add(self, sql_expression: tuple[str, tuple[Union[str, int, bytes], ...]]): def add(self, sql_expression: tuple[str, tuple[Union[str, int, bytes], ...]]):
self.updated.append(sql_expression) self.updated.append(sql_expression)