I am built a telegram bot with the Python-Telegram-Bot framework.I added it to a group and admin the bot in the group.

bot codes:

from telegram.ext import Updater, MessageHandler, CommandHandler, Filters

updater = Updater(token='TOKEN')
dispatcher = updater.dispatcher

def sticker_method(bot, update):
    update.message.delete()

def sticker_delete():
    dispatcher.add_handler(MessageHandler(Filters.sticker, sticker_method))
    updater.start_polling() 
    updater.idle()

def sticker_undelete():
    dispatcher.remove_handler(MessageHandler(Filters.sticker, sticker_method))

start_command = CommandHandler('start', sticker_delete)
dispatcher.add_handler(start_command)

notdelete_command = CommandHandler('notdelete', sticker_undelete)
dispatcher.add_handler(notdelete_command)

updater.start_polling() 
updater.idle()

After the group creator sends the bot command /start, the bot will delete the stickers that the group members send to the group.

And also, when the group creator command /notdelete send it to the bot, the bot should not delete the stickers that members send to the group.

But the bot does not work; when the group creator sends the group command /start to the bot, it will not delete the bot stickers that are sent to the group.

What do you think the problem is that the bot does not work ???

The codes do not give any error, but as I said, the bot does not work.

1

There are 1 best solutions below

3
On

First, make sure it's supergroup, not normal group

Your bot need Delete Message permission, and Privacy Mode should be disabled.

Bots can't get message list, they can only receive that when someone send it, so you need to log Enable/Disable state to your own database, and delete Sticker when received new message.