W
W
worker002021-05-12 19:57:10
Python
worker00, 2021-05-12 19:57:10

How to make the bot wait for a response from the user?

I am writing a bot for VK in python and I don’t know how to make the bot wait for a response from the user
For example: The
bot writes: write a name, user: <name>, and the bot responds depending on the answer
I use the vk_api library
609c08b6ed9dc598706961.jpeg

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vindicar, 2021-05-13
@Vindicar

If you need to process a sequence of messages, describe a state machine.
Each state is a situation where the bot is waiting for a set of possible responses.
Each response is a transition from state to state.
When processing a message, you look at what transitions are in the current state, choose the most appropriate one and execute its logic.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question