father-bot / chatgpt_telegram_bot

💬 Telegram bot with ChatGPT, Python-based, using OpenAI's API.
https://t.me/chatgpt_karfly_bot
MIT License
5.16k stars 1.8k forks source link

Issue with Bot Responding to Unmentioned GIFs and Videos #454

Open bannedin40countries opened 6 months ago

bannedin40countries commented 6 months ago

Hi, I am encoutering an issue where the bot (v1.5) responds to GIFs and videos in group chats without being explicitly mentioned. The bot automatically replies with: "I don't know how to read files or videos. Send the picture in normal mode (Quick Mode)."

This behavior persists even though the bot is not mentioned or tagged. Is this a bug? Otherwise, I am looking for guidance or a fix to ensure that the bot only responds when directly mentioned or replying to its messages in group chats.

image

hirakujira commented 6 months ago

Yes, they forgot to block unmentioned video/file messages in the group chat

This is a quick fix:

async def unsupport_message_handle(update: Update, context: CallbackContext, message=None):
    # check if bot was mentioned (for group chats)
    if not await is_bot_mentioned(update, context):
        return
    error_text = f"I don't know how to read files or videos. Send the picture in normal mode (Quick Mode)."
    logger.error(error_text)
    await update.message.reply_text(error_text)
    return
bannedin40countries commented 6 months ago

Yes, they forgot to block unmentioned video/file messages in the group chat

This is a quick fix:

async def unsupport_message_handle(update: Update, context: CallbackContext, message=None):
    # check if bot was mentioned (for group chats)
    if not await is_bot_mentioned(update, context):
        return
    error_text = f"I don't know how to read files or videos. Send the picture in normal mode (Quick Mode)."
    logger.error(error_text)
    await update.message.reply_text(error_text)
    return

This works. Thanks a bunch!