D
D
Dmitry2021-09-22 01:30:49
Telegram
Dmitry, 2021-09-22 01:30:49

Trigger/State per Telegram bot command?

Is there a state or any trigger for commands to the bot? That is, we sent a command to the bot and it prohibits us from executing other commands (only allow the /cancel command) until we fulfill the following conditions.

How does is called? Where is this to google?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Stefan, 2021-09-22
@refreak

There is FSM in aiogram, google it, MB is what you wanted

A
accountnujen, 2021-09-22
@accountnujen

look, you have a user id. No one forbids you to write it to the database and issue a certain status.
For example, my bot is forbidden to use until you provide your phone number (there is a "share your number" button).
The bottom line is this: the user writes / start. I drive his ID into the database and write the status 0. Then I suggest sharing the contact.
if he does anything but "share the number", then the bot will send him a message: "you did not share the number" and again offer to share it. The circle will repeat until the person says their phone number. And then I will put status 1 in the database. Now, when a user sends a message, I will check whether he has status 1 or not. If yes, then he can continue to use the bot.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question