From 0b9603d9f2e74f5517823ff146e889a436eca7f3 Mon Sep 17 00:00:00 2001 From: Factorino73 Date: Thu, 2 Jan 2025 16:15:10 +0400 Subject: [PATCH] feat/add-argument-priority-for-the-ai-command-handler --- src/bot/telegram_userbot.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/bot/telegram_userbot.py b/src/bot/telegram_userbot.py index fe69355..4084c56 100644 --- a/src/bot/telegram_userbot.py +++ b/src/bot/telegram_userbot.py @@ -56,9 +56,13 @@ class TelegramUserBot: # Extract the command argument command_arg: Optional[str] = " ".join(message.text.split()[1:]) + if not command_arg and message.reply_to_message and message.reply_to_message.text: + # Use the text of the replied message if no argument is provided + command_arg = message.reply_to_message.text + if not command_arg: - self.logger.warning(f"No argument provided for /ai command by chat_id={message.chat.id}") - await message.reply_text("Please provide a message after /ai.") + self.logger.warning(f"No argument or replied message provided for /ai command by chat_id={message.chat.id}") + await message.reply_text("Please provide a message after /ai or reply to a message.") return # Send an initial message indicating processing