Answer the question
In order to leave comments, you need to log in
How to make each person have their own dialogue?
For example: the first person answers the question, he already has a question 5/10. Then, if the second person writes to him, then he will also have a 5/10 question. And the second person can answer for the first. How to implement it in telegram? So that everyone has their own dialogue with the bot, and not the same.
Answer the question
In order to leave comments, you need to log in
Create a dictionary and write down which person has which question?
https://pythonworld.ru/tipy-dannyx-v-python/slovar...
Well, look, just on the fingers is the simplest type of interaction. Suppose there is a dialogue state:
undefined or 0 - the user did not write anything, but pressed / start - we answer with the button and transfer to state 1.
1 - the user pressed the button - we ask for the phone and transfer to state 2.
2 - the user entered the phone - we do what we need and return to state 0.
So we start a dictionary:
user_states = dict()
Next, for each message, we do:
try:
user_states[message.from_user.id]
except KeyError:
user_states[message.from_user.id] = 0
if user_states[message.from_user.id] == 0:
bot.send_message (посылаем кнопку)
user_states[message.from_user.id] = 1
elif user_states[message.from_user.id] == 1:
bot.send_message (спрашиваем телефон)
user_states[message.from_user.id] = 2
elif user_states[message.from_user.id] == 2:
bot.send_message (как прикажете, господин)
do_somethine_awesome
user_states[message.from_user.id] = 0
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question