A
A
Artemy Family2019-10-14 15:37:51
Bots
Artemy Family, 2019-10-14 15:37:51

Logic, Telegram bot algorithm. How?

Hello!
There was a need to make a shutdown and shutdown in the bot.
When OFF only the Admin sees everything, the rest is some kind of text, they say come later.
Implemented like this:

while (true) {
            if ($bot->isAdmin($chat_id) == true) {
                break;
            }else{
                # ВКЛ- и ВЫКЛючение БОТа
                if ($bot->getSettings()['on_off'] == 'off') {
                    $reply = "Какой то текст...";
                    $reply_markup = $telegram->replyKeyboardHide(['hide_keyboard' => true,]);
                    $telegram->sendMessage([ 'chat_id' => $chat_id, 'text' => $reply, 'reply_markup' => $reply_markup, ]);
                    return;
                }
                break;
            }
        }

If admin, then exit the break loop;
If not an admin, look ON or OFF the bot. If ON then we go out.
The problem is that all this slows down the bot. Written in PHP, either telegram-bot-sdk irazasyed
Such a cycle at the beginning where we get the text and below where $result['callback_query'] total two.
+ the same loop for another option.
In general, the response speed has noticeably decreased.
Please let me know if there is any other way to do it!
Now done on switch case.
switch ($text) {
            case '/start':
                ...

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question