steadfast/telegram-bot-api
Composer 安装命令:
composer require steadfast/telegram-bot-api
包简介
Telegram Bot API written in PHP
关键字:
README 文档
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(); });
统计信息
- 总下载量: 28
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-08-23