Answer the question
In order to leave comments, you need to log in
How to make the bot react to a certain word only when there is an image in the message?
I’ve been tinkering with this for the third day now, I can’t find any information.
The message to the bot must contain certain text and an image, only in this case it must react.
If the message contains only this specific text or only an image, then it should not react.
If you use:
@bot.message_handler(content_types=['photo'])
def handle_message(message):
if message.text == "слово":
(Сделать что то)
Answer the question
In order to leave comments, you need to log in
it is necessary to compare not the entire text with the "word", but to look for the occurrence of the "word" in the text of the message.
if "слово" in message.text:
It may even be worth referring not to the text field, but to the caption field. Experiment.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question