I’m operating on a Debian 8 server with an ISP 5 connection. I’ve installed the library from the GitHub repository for Telegram bots but my bot is unresponsive to messages and commands. The server does not provide logs, so I’m unsure about the issue. I’ve acquired an SSL certificate through Let’s Encrypt for my IP address. Below are the relevant setup scripts.
set.php
<?php
require __DIR__ . '/vendor/autoload.php';
$API_KEY = 'your_api_key';
$BOT_NAME = 'my_telegram_bot';
$hook_url = 'https://your_ip/hook.php';
try {
$telegram = new Longman\TelegramBot\Telegram($API_KEY, $BOT_NAME);
$result = $telegram->setWebhook($hook_url);
if ($result->isOk()) {
echo $result->getDescription();
}
} catch (Longman\TelegramBot\Exception\TelegramException $e) {
echo $e;
}
?>
hook.php
<?php
require __DIR__ . '/vendor/autoload.php';
$API_KEY = 'your_api_key';
$BOT_NAME = 'my_telegram_bot';
$commands_path = __DIR__ . '/Commands/';
try {
$telegram = new Longman\TelegramBot\Telegram($API_KEY, $BOT_NAME);
$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);
?>