oe24y2022-03-05 10:32:28
oe24y, 2022-03-05 10:32:28

Aiogram: How to save user entered data?

My bot is essentially step-by-step. At each step, I get input from the user.
In the last step, I need to get them all.
Tell me how to do it? Where and how to remember the entered data at each step?
Bot without using a database

Answer the question

In order to leave comments, you need to log in

2 answer(s)
InternetMaster, 2022-03-05

Well, what about steps by State? If yes, then this is . At the second step, you write down your last name, or whatever you want. At the end you extract the content:await state.update_data(name='Вячеслав')

n = await state.get_data()
name = n['name']

Vindicar, 2022-03-05

Well, the algorithm is always the same.
You need to store for each user of the bot the step on which he is, and all the data entered earlier.
Then, upon receiving the text from the user, we look for his ID in the storage, look at what step he is at, and try to interpret the received text depending on this.
But where to store the data is a matter of implementation. You can make a dictionary of the form "User ID - data set", you can make a database. The principle does not change.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question