diff --git a/README.md b/README.md index b3cae58..ad239ac 100644 --- a/README.md +++ b/README.md @@ -114,6 +114,7 @@ python3 src/main.py * remove old and unused logs at start and guild leaving * GDPR disclaimer before scanning * start and stop dates + * bug fix and improvements * **v1.12** * more scans: `%words` * concurrent `fast` analysis diff --git a/src/logs/channel_logs.py b/src/logs/channel_logs.py index 99fbfdb..39d854b 100644 --- a/src/logs/channel_logs.py +++ b/src/logs/channel_logs.py @@ -8,6 +8,8 @@ from utils import FakeMessage CHUNK_SIZE = 2000 FORMAT = 3 +NOT_SERIALIZED = ["channel", "guild", "start_date"] + class ChannelLogs: def __init__(self, channel: Union[discord.TextChannel, dict], guild: Any): @@ -92,8 +94,7 @@ class ChannelLogs: def dict(self) -> dict: channel = dict(self.__dict__) - channel.pop("channel", None) - channel.pop("guild", None) - channel.pop("start_date", None) + for key in NOT_SERIALIZED: + channel.pop(key, None) channel["messages"] = [message.dict() for message in self.messages] return channel diff --git a/src/logs/message_log.py b/src/logs/message_log.py index f534155..263c245 100644 --- a/src/logs/message_log.py +++ b/src/logs/message_log.py @@ -8,6 +8,9 @@ IMAGE_FORMAT = [".gif", ".gifv", ".png", ".jpg", ".jpeg", ".bmp"] EMBED_IMAGES = ["image", "gifv"] +NOT_SERIALIZED = ["channel"] + + class MessageLog: def __init__(self, message: Union[discord.Message, dict], channel: Any): self.channel = channel @@ -79,7 +82,8 @@ class MessageLog: def dict(self) -> dict: message = dict(self.__dict__) - message.pop("channel", None) + for key in NOT_SERIALIZED: + message.pop(key, None) message["created_at"] = self.created_at.isoformat() message["edited_at"] = ( self.edited_at.isoformat() if self.edited_at is not None else None