segakgd / telegram_client
A PHP client for using Telegram API
1.0.2
2025-03-16 21:50 UTC
Requires
- php: >=8.2
- ext-curl: *
This package is not auto-updated.
Last update: 2025-08-17 23:54:12 UTC
README
A PHP client library for interacting with the Telegram Bot API.
Features
- Send messages
- Send exceptions
Installation
Install via Composer:
composer require segakgd/telegram_client
Usage
$telegramManager = new TelegramManager(); $telegramToken = '0000000:0000000000000000000000000'; $message = $telegramMessageBuilder ->addText("Привет, мир!") ->newLine() ->addIndent() ->bold("Это жирный текст") ->newLine(2) ->italic("Курсивный текст") ->newLine() ->monospace("Моноширинный текст") ->newLine() ->addLink("Нажми сюда", "https://example.com") ->getMessage(); $chatId = '0000000'; $messageDto = $telegramManager->createMessage($chatId, $message); $response = $telegramManager->sendMessage( message: $messageDto, token: $telegramToken, );
Usage with exceptions
$telegramManager = new TelegramManager(); $telegramToken = '0000000:0000000000000000000000000'; $exception1 = new Exception('1'); $exception2 = new Exception(message: '2', previous: $exception1); $exception3 = new Exception(message: '3', previous: $exception2); $exception4 = new Exception(message: '4', previous: $exception3); $exception5 = new Exception(message: '5', previous: $exception4); $exception6 = new Exception(message: '6', previous: $exception5); $message = (new TelegramExceptionManager())->makeReport($exception6); $chatId = '0000000'; $messageDto = $telegramManager->createMessage($chatId, $message); $response = $telegramManager->sendMessage( message: $messageDto, token: $telegramToken, );