1
votes

I want my bot to send a message when it detect documents is sent in a chat.
I add a message handler with document filter.
The code works for chat to the bot directly,
but if I add the bot into a group, the bot has no response if I sent a document in the group.

The code is:

def test(bot, update):
    bot.sendMessage(update.message.chat_id, text='OK!')
    print "OK"

def main():
    token = 'xxxxxxyyyyy'
    updater = Updater(token, workers=10)

    dp = updater.dispatcher

    dp.add_handler(CommandHandler("start", start))
    dp.add_handler(CommandHandler("help", help))
    dp.add_handler(MessageHandler([Filters.document], test))

    updater.start_polling(timeout=10)
    updater.idle()

Why the bot has no response when I send a file in a group? Thanks!

1

1 Answers

2
votes

If code is working in private chat but not working( not receiving messages sent) in a group , the reason is you do NOT set /setprivacy in BotFather.

Go to BotFather and disable /setprivacy for your bot. In this state, your bot will receive all messages not just does start with slash(/) in GROUPS.