V
V
Vasily Alibabaevich2018-02-04 16:30:28
PHP
Vasily Alibabaevich, 2018-02-04 16:30:28

Why is the bot not responding to commands?

Good afternoon.
Initial server data: Centos 7, php 5.6 with all extensions, library https://github.com/TelegramBot/Api is used

<?php

    require_once("vendor/autoload.php");
    const TOKEN = "тут стоит токен";
    $bot = new \TelegramBot\Api\Client(TOKEN);

if(!file_exists("registered.trigger")){
    /**
     * файл registered.trigger будет создаваться после регистрации бота.
     * если этого файла нет значит бот не зарегистрирован
     */

    // URl текущей страницы
    $page_url = "https://".$_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
    $result = $bot->setWebhook($page_url);
    if($result){
        file_put_contents("registered.trigger",time());
        $bot->sendMessage("мой ID", "Веб-хук установлен со статусом: ".$result);// создаем файл дабы прекратить повторные регистрации
    }
}
    $bot->sendMessage("мой ID", "HELLO WORLD!");

    $bot->command('start', function ($message) use ($bot) {
    $answer = 'Добро пожаловать!';
    $bot->sendMessage($message->getChat()->getId(), $answer);
});

$bot->run();

The joke is that messages are sent, but it does not accept the start command, as if the web hook is not installed. The SSL certificate is valid, not self-signed. List of commands via botfaser installed.
Tell me, what could be the matter?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Skobkin, 2018-02-04
@skobkin

Well, take a debugger, see if updates come to your bot through a webhook, see how it processes them.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question