R
R
Revs12021-12-04 14:50:13
Python
Revs1, 2021-12-04 14:50:13

How to check multiple conditions in telegram bot?

Hello!
Is it possible to check several conditions so that at least one match condition is met and a message is thrown?
That is, for example, the user enters the number 1 or 3, and when entering any of these numbers, the condition was met and a message flew out

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Andrew, 2021-12-04
@remberq

I myself have just started learning programming, but I can kind of tell you.
Do it with or or and
Example if x < 3 or x != 0
It means that if one of these conditions is true, then the test will pass
Example if x == 5 and y == 4
Means that the test will pass only if both conditions are True
It seems the syntax is correct, I apologize in advance if there are jambs)

I
Igor, 2021-12-04
@karonion

I am working with pyTelegramBotApi and I implement like this:
if message.text == '1' or message.text == '3':
bot.send.message(message.chat.id, text='Hello')
i.e. If the text of the user's message contains this or that information, the bot reacts to it accordingly.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question