2

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 Longman\TelegramBot\Telegram($API_KEY, $BOT_NAME);

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

} catch (Longman\TelegramBot\Exception\TelegramException $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 Longman\TelegramBot\Telegram($API_KEY, $BOT_NAME);

    // Handle telegram webhook request
    $telegram->handle();
} catch (Longman\TelegramBot\Exception\TelegramException $e) {
     echo $e;
     \Longman\TelegramBot\TelegramLog::initErrorLog(__DIR__ . '/' . $BOT_NAME . '_error.log');
     \Longman\TelegramBot\TelegramLog::initDebugLog(__DIR__ . '/' . $BOT_NAME . '_debug.log');
     \Longman\TelegramBot\TelegramLog::initUpdateLog(__DIR__ . '/' . $BOT_NAME . '_update.log');
}

$telegram->addCommandsPath($commands_path);
MyZik
  • 220
  • 2
  • 15

2 Answers2

0

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

ManzoorWani
  • 1,016
  • 7
  • 14
0

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

MyZik
  • 220
  • 2
  • 15
  • Did you setup webhook with Lets Encrypt cert? I am trying to switch from my self-signed cert to a Lets Encrypt cert but Telegram fails at validating the new cert. – Poulad Jul 03 '17 at 11:31