D
D
Danya  2020-08-03 21:38:30
Python
Danya  , 2020-08-03 21:38:30

TelegramBot Message filter?

It is necessary that the bot checks the message for the presence of words familiar to it, and if such are present, then delete them.
Here is my code.

@bot.message_handler(content_types=['text'])
def filter(message):
    if message.text == "Привет":
        bot.delete_message(message.chat.id, message.message_id)

Problem:
If the bot sees "Hi" it deletes it, but if you write "Hi, how are you" it will not delete it!
Please tell me how to solve the problem?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
Timur Pokrovsky, 2020-08-03
@MrBrainop

if 'Привет' in message.text:

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question