I create a telegram bot whit python-telegram-bot. I have defined a list of words for the bot,and I want to manage the chat bot in the group, that is, if there is a word in the chats in the list defined, the bot will delete it. I added the bot to a group and admin it there, and the bot should control the messages sent to the group, and if there is a word in the message that is on the mlist, the bot should delete the message. my codes:
from telegram.ext import Updater
updater = Updater(token='TOKEN')
dispatcher = updater.dispatcher
mlist=['world', 'by', 'hello']
def delete_method(bot, update):
bot.delete_message(chat_id=message.chat_id, message_id=message.message_id, *args, **kwargs)
if message in mlist:
delete_method(bot, update)
updater.start_polling()
# for exit
# updater.idle()