Reputation: 214
I want to create a telegram bot to predict football scores with my friends. So I have a list of fixtures (e.g. ["Man Utd vs Spurs", "Liverpool vs Man City", "Arsenal vs Chelsea"]).
I want to send these fixtures to a user one by one. So it should look like this:
user_message: /prediction
bot_message: fixture1
user_message: score1
bot_message: fixture2
user_message: score2
...
bot_message: fixture10
user_message: score10
bot_message: Predictions saved!
But I can't understand how to make a bot wait for a user's reply. I tried to use register_next_step_handler
but it doesn't work as I expected.
for fixture in prediction.schedule:
bot.send_message(message.chat.id, fixture["fixture_name"])
bot.register_next_step_handler(message, make_prediction)
...
It firstly sends all the messages (10 in my case) and then executes make_prediction
function 10 times after just one user message.
This is how it works now:
Upvotes: 0
Views: 555
Reputation: 74
One of solutions:
I suppose you will store user's predictions somewhere in array
Initially all of user's predictions are empty — filled with null value
When user call /prediction
command, you start end:
So, to user this dialog will look like this:
> /prediction
# Foo vs Bar ?
> Foo
# A vs B ?
> I bet my house to A!
# Thanks for your predictions!
Upvotes: 0