Skip to content

Commit

Permalink
Fix message find by date
Browse files Browse the repository at this point in the history
  • Loading branch information
AlberLC committed Jun 29, 2022
1 parent 1d3e8b7 commit 6c5d271
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion multibot/bots/multi_bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]:
Expand Down
4 changes: 2 additions & 2 deletions multibot/bots/twitch_bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 6c5d271

Please sign in to comment.