Skip to content

Commit

Permalink
fix(game): Not checking for spam if game input
Browse files Browse the repository at this point in the history
  • Loading branch information
Nickelza committed Nov 5, 2023
1 parent acacd0d commit da1b644
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/chat/manage_message.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
"""

Expand All @@ -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
Expand Down

0 comments on commit da1b644

Please sign in to comment.