// src/Controller/HTTPCatController.php
<?php
namespace App\Controller;
use Longman\TelegramBot\Exception\TelegramException;
use Longman\TelegramBot\Telegram;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\Routing\Attribute\Route;
class HTTPCatController extends AbstractController
{
#[Route('/webhook/cat', name: 'webhook_cat')]
public function handleWebhook(): JsonResponse
{
$botApiKey = '<Api Key созданного бота из @BotFather>';
$botUsername = '<Никнейм созданного бота из @BotFather>';
try {
$telegram = new Telegram($botApiKey, $botUsername);
return new JsonResponse(['ok' => $telegram->handle());
} catch (TelegramException $e) {
return $this->json(['error' => $e->getMessage()]
, 400);
}
}