Answer the question
In order to leave comments, you need to log in
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();
Answer the question
In order to leave comments, you need to log in
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 questionAsk a Question
731 491 924 answers to any question