X
X
XenK2016-06-15 15:40:05
PHP
XenK, 2016-06-15 15:40:05

Entering command for telegram bot?

Now I use this option:
/add [name]
and, accordingly, a regular expression for this:

preg_match('/\/add\s(.+)/i, $msg, $msg)
$msg = $msg[1];
...

I want to make it so that after entering / add, the bot prompts you to enter a name. If, for example, within 30 seconds, the user did not enter anything, then the command was canceled. How it is better to implement it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Muhammad, 2016-06-15
@muhammad_97

We save an entry in the cache that we are waiting for a message from such and such a user and write a handler (callback) there. With each request, we check if there is something in the cache, if there is, then we call the callback, otherwise we call the standard command handler.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question