From da1b6442de8ef4c26b2071fbe3149716fc753b0f Mon Sep 17 00:00:00 2001 From: Nickelza Date: Sun, 5 Nov 2023 17:43:33 +0100 Subject: [PATCH] fix(game): Not checking for spam if game input --- src/chat/manage_message.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/chat/manage_message.py b/src/chat/manage_message.py index ba4ae97d..b7c90c37 100644 --- a/src/chat/manage_message.py +++ b/src/chat/manage_message.py @@ -213,7 +213,7 @@ async def manage_after_db(update: Update, context: ContextTypes.DEFAULT_TYPE, is # Check for spam only if a valid command or private chat if command != Command.ND or message_source is MessageSource.PRIVATE: - if await is_spam(update, context, message_source, command): + if await is_spam(update, context, message_source, command, user): logging.warning(f'Spam detected for chat {update.effective_chat.id}: Ignoring message') return @@ -506,13 +506,14 @@ def add_or_update_group_chat(update, group: Group) -> GroupChat: async def is_spam(update: Update, context: ContextTypes.DEFAULT_TYPE, message_source: MessageSource, - command: Command) -> bool: + command: Command, user: User) -> bool: """ Check if the message is spam, which would cause flooding :param update: Telegram update :param context: Telegram context :param message_source: The message source :param command: The command + :param user: The user :return: True if the message is spam """ @@ -526,7 +527,7 @@ async def is_spam(update: Update, context: ContextTypes.DEFAULT_TYPE, message_so return False # Not managing spam for other message sources # Game input, don't check for spam - if command is Command.PVT_GAME_GUESS_INPUT: + if user is not None and user.get_current_private_screen() is Screen.PVT_GAME_GUESS_INPUT: return False # Russian roulette, don't check for spam