From 6c5d271536c976f1988195716e75136dd93fec82 Mon Sep 17 00:00:00 2001 From: AlberLC Date: Wed, 29 Jun 2022 06:49:15 +0200 Subject: [PATCH] Fix message find by date --- multibot/bots/multi_bot.py | 2 +- multibot/bots/twitch_bot.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/multibot/bots/multi_bot.py b/multibot/bots/multi_bot.py index 50e24a7..b64de66 100644 --- a/multibot/bots/multi_bot.py +++ b/multibot/bots/multi_bot.py @@ -307,7 +307,7 @@ async def _ban(self, user: int | str | User, group_: int | str | Chat | Message, @staticmethod async def _check_messages(): before_date = datetime.datetime.now(datetime.timezone.utc) - constants.MESSAGE_EXPIRATION_TIME - Message.collection.delete_many({'last_update': {'$lte': before_date}}) + Message.collection.delete_many({'date': {'$lte': before_date}}) BotAction.collection.delete_many({'date': {'$lte': before_date}}) async def _find_users_to_punish(self, message: Message) -> OrderedSet[User]: diff --git a/multibot/bots/twitch_bot.py b/multibot/bots/twitch_bot.py index b7511a4..b2ac99e 100644 --- a/multibot/bots/twitch_bot.py +++ b/multibot/bots/twitch_bot.py @@ -141,8 +141,8 @@ async def clear(self, n_messages: int, chat: int | str | Chat | Message): 'author': {'$ne': owner_user.object_id}, 'chat': chat.object_id, 'is_deleted': False, - 'last_update': {'$gt': datetime.datetime.now(datetime.timezone.utc) - datetime.timedelta(days=1)} - }, sort_keys=(('last_update', pymongo.DESCENDING),), lazy=True) + 'date': {'$gt': datetime.datetime.now(datetime.timezone.utc) - datetime.timedelta(days=1)} + }, sort_keys=(('date', pymongo.DESCENDING),), lazy=True) deleted_message_count = 0 while deleted_message_count < n_messages: