steadfast / telegram-bot-api
Telegram Bot API written in PHP
Installs: 28
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/steadfast/telegram-bot-api
Requires
- php: >=5.5.0
Requires (Dev)
This package is auto-updated.
Last update: 2025-09-25 14:06:05 UTC
README
An extended native Telegram Bot API in PHP without requirements. Supports all methods and types of responses.
Installation
composer require steadfast/telegram-bot-api
Client usage
How to send message:
use TelegramBot\Api\BotApi; $bot = new BotApi($bot_api_token); $bot->sendMessage($chat_id, $message_text);
Server usage
To handle commands:
use TelegramBot\Api\Client; $bot = new Client($bot_api_token); $bot->command('ping', function ($message) use ($bot) { $bot->sendMessage($message->getChat()->getId(), 'pong!'); });
To handle an event when the bot was added to a group:
use TelegramBot\Api\Client; $bot = new Client($bot_api_token); $bot->wasAddedToAGroup(function ($message) use ($bot) { $bot->sendMessage($message->getChat()->getId(), "Let's welcome our new member!"); });
To handle an event when the bot was removed from a group:
use TelegramBot\Api\Client; $bot = new Client($bot_api_token); $bot->wasRemovedFromAGroup(function ($message) use ($bot) { $bot->sendMessage($message->getChat()->getId(), "Say goodbye to our friend!"); });
To handle any events:
use TelegramBot\Api\Client; $bot = new Client($bot_api_token); $bot->on(function ($update) { echo $update->getUpdateId(); });