Y
Y
yescc2018-03-31 12:21:59
ruby
yescc, 2018-03-31 12:21:59

How to implement multi-step command for Telegram bot?

In my bot, I use the telegram-bot-ruby gem .
I want to implement a conditional /signup command that would script like this:

Scenario

(шаг 1)
-> Бот присылает сообщение "Введите ваш город"
--> Бот ожидает ввода от пользователя
-> Бот присылает сообщение "Город установлен"
(шаг 2)
-> Бот присылает сообщение "Введите любимый фрукт"
--> Бот ожидает ввода от пользователя
-> Бот присылает сообщение "Фрукт установлен"

That is, the question is in some kind of state storage and sequential processing or something like that, but I don’t know how to do it. I would like to look at a banal example of such when.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
C
Chronic 86, 2018-03-31
@chronic86

Look towards the Iterator gem.

A
arudmin, 2018-03-31
@arudmin

In general terms, with the help of finite automata.
Examples: https://groosha.gitbooks.io/telegram-bot-lessons/c...

V
Vasily Shakhunov, 2018-04-21
@inf

Something like this https://github.com/webchi/myskitrainer_bot/blob/ma...
Via context_handler

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question