skip to Main Content

i use server on Debian 8 with ISP 5. I have installed that lib: https://github.com/akalongman/php-telegram-bot. Webhook was set but bot doesn’t respond messages and commands. Server hadn’t logs, I do not know what the problem is 🙁

I received a SSL from Let’s Encrypt in ISP Manager for IP adress.
enter image description here

Here is my set.php

<?php
// Load composer
require __DIR__ . '/vendor/autoload.php';

$API_KEY = 'key';
$BOT_NAME = 'evtepo_bot';
$hook_url = 'https://213./hook.php';
try {
    // Create Telegram API object
    $telegram = new LongmanTelegramBotTelegram($API_KEY, $BOT_NAME);

    // Set webhook
    $result = $telegram->setWebhook($hook_url);
    if ($result->isOk()) {
        echo $result->getDescription();
    }

} catch (LongmanTelegramBotExceptionTelegramException $e) {
    echo $e;
}

And hook.php

<?php
// Load composer
require __DIR__ . '/vendor/autoload.php';

$API_KEY = 'key';
$BOT_NAME = 'evtepo_bot';
$commands_path = __DIR__ . '/Commands/';

try {
    // Create Telegram API object
    $telegram = new LongmanTelegramBotTelegram($API_KEY, $BOT_NAME);

    // Handle telegram webhook request
    $telegram->handle();
} catch (LongmanTelegramBotExceptionTelegramException $e) {
     echo $e;
     LongmanTelegramBotTelegramLog::initErrorLog(__DIR__ . '/' . $BOT_NAME . '_error.log');
     LongmanTelegramBotTelegramLog::initDebugLog(__DIR__ . '/' . $BOT_NAME . '_debug.log');
     LongmanTelegramBotTelegramLog::initUpdateLog(__DIR__ . '/' . $BOT_NAME . '_update.log');
}

$telegram->addCommandsPath($commands_path);

2

Answers


  1. Chosen as BEST ANSWER

    The problem was that I needed to buy a domain and get a SSL from Lets'Encrypt.


  2. You should use getWebhookInfo method to check if the updates were delivered to the hook and if there were any errors.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search