Closed DARL0K closed 5 years ago
Я использую следующий код код:
private function sendMessage(Subscriber $subscriber, $message, $parseMode = null)
{
try {
$this->botApi->sendMessage($subscriber->getChat(), $message, $parseMode);
$this->io->success('Sent');
} catch (\TelegramBot\Api\HttpException $e) {
if ($e->getCode() == 403) {
$this->subscriptionManager->removeSubscription($subscriber);
$this->io->comment(sprintf('Blocked subscriber "%s" (%d)', $subscriber->getPhone(), $subscriber->getChat()));
} else {
$this->io->error(sprintf('Error sending message (%s)', $e->getCode()));
throw $e;
}
}
}
Уже поймал через catch exception, но все равно спасибо } catch (\TelegramBot\Api\Exception $e) { file_put_contents('last_request.txt', $e->getMessage()); }
Здравствуйте. Есть идеи, как узнать заблокировал юзер бота или нет? Я знаю что при отправке вернет json с 403 кодом но я не могу его отловить кодом. Есть идеи? Данный код ничего не возвращает if(!empty($message->getText())) { $bot->sendChatAction($fid, "typing"); usleep( 500000 ); $bot->sendMessage($fid, $message->getText()); file_put_contents('last_request.txt', file_get_contents('php://input')); }