Answer the question
In order to leave comments, you need to log in
How to make a limited number of input of a certain command in aiogram?
I am writing a bot on aiogram with a link to the PostgreSQL database.
Essence of the question:
There are 2 commands in the bot: ("/start", "/menu")
When you click on /start, the user is added to the PostgreSQL database. (The table looks like: ID, full_name, user_name, telegram_id, quantity). quantity = 10 by default.
When you click on /menu - plain text is displayed.
How to make it so that when you click on / test - quantity decreases each time by 1? Those. 9,8,7... And when quantity became 0, a message was displayed that the limit had been exhausted.
Answer the question
In order to leave comments, you need to log in
In the /test command handler, do a SELECT quantity for the sender.
If nothing is found, report the need to register via /start.
If a positive value is returned, execute an UPDATE query, and then do what is required.
If zero is returned, report limit exhaustion.
What exactly are the problems?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question