【发布时间】:2018-03-31 12:51:07
【问题描述】:
我用 laravel 和 sdk 创建了电报机器人 今天有一个问题 - 机器人正在递归地向用户发送相同的消息 picture
\Telegram::sendMessage([
'chat_id' => $chatid,
'text' => "Считаю...",
]);
$controller = $this->getReportControllerName($text);
$method = $this->getReportMethodName($text);
$report_data = new $controller();
$report_data = $report_data->$method($chatid);
try
{
\Telegram::sendMessage([
'chat_id' => $chatid,
'text' => $report_data,
]);
}
catch (TelegramResponseException $e)
{
$errorData = $e->getResponseData();
if ($errorData['ok'] === false) {
\Telegram::sendMessage([
'chat_id' => '123456789',
'text' => 'There was an error for a user. ' . $errorData['error_code'] . ' ' . $errorData['description'],
]);
}
}
Try-catch block添加后检测问题。在我的日志中有很多 499 和 500 错误。我还能做些什么来解决这个问题?将try-catch 添加到程序的另一部分或其他内容中?
【问题讨论】:
标签: php laravel telegram-bot