H
H
Hamio2021-02-24 14:10:59
Python
Hamio, 2021-02-24 14:10:59

I don't know how to save the answer in the Telegram bot (aiogram)?

I want the user to ask a question to the bot, like "What are you doing?"

In response, he receives "The bot is working hard to please the user, but what are you doing?"

And I need the answer of the bot "Keep up the good work" (exactly the next one) to any next answer, since I have a link to the help on incomprehensible lines.

The code below

is elif message.text.lower() == 'what are you doing?':
await bot.send_message(message.chat.id, 'The bot is working hard to please the user, what are you doing?')
elif message.text. lower () == '':
await bot.send_message(message.chat.id, 'Keep up the good work')

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alex K, 2021-02-24
@alexk111

Store the user state either in the database or in memory (depending on the final task) as a simple key-value, where the key is the user id and the value is the current step in the bot. When checking an incoming message, also check the user's step in the bot.

S
Stefan, 2021-02-27
@MEDIOFF

There is a very cool thing in aiogram - Finite State Machine, I think it will help you

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question