Telegram Bot 不回复消息
Telegram Bot doesn't respond messages
我在带有 ISP 5 的 Debian 8 上使用服务器。我已经安装了那个库:https://github.com/akalongman/php-telegram-bot。 Webhook 已设置,但机器人不响应消息和命令。服务器没有日志,我不知道是什么问题:(
我在 ISP 管理器中收到了来自 Let's Encrypt 的 SSL 以获取 IP 地址。
enter image description here
这是我的 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;
}
和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);
您应该使用 getWebhookInfo 方法来检查更新是否已传递到挂钩以及是否有任何错误。
问题是我需要购买域并从 Lets'Encrypt 获取 SSL。
我在带有 ISP 5 的 Debian 8 上使用服务器。我已经安装了那个库:https://github.com/akalongman/php-telegram-bot。 Webhook 已设置,但机器人不响应消息和命令。服务器没有日志,我不知道是什么问题:(
我在 ISP 管理器中收到了来自 Let's Encrypt 的 SSL 以获取 IP 地址。 enter image description here
这是我的 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;
}
和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);
您应该使用 getWebhookInfo 方法来检查更新是否已传递到挂钩以及是否有任何错误。
问题是我需要购买域并从 Lets'Encrypt 获取 SSL。