tigris/tigris
Composer 安装命令:
composer require tigris/tigris
包简介
Tigris is a modern Telegram bot framework written in PHP
关键字:
README 文档
README
Tigris is a modern reactive event-driven Telegram bot framework written in PHP.
Usage
Without extending the Bot class
Create a bot instance
$bot = (new BotFactory())->create($apiToken);
Define your custom even handlers
$bot = (new BotFactory())->create($apiToken); $bot->addListener(MessageEvent::EVENT_TEXT_MESSAGE_RECEIVED, function (MessageEvent $event) use ($bot) { // sending your first message $bot->getApi()->sendMessage([ 'chat_id' => $event->message->chat->id, 'text' => 'Hello World!', ]); });
Run your bot
$bot->run();
Extending the Bot class
Extend the Tigris\Bot class to create your own bot implementation
class SampleBot extends \Tigris\Bot { // bootstraping your bot public function bootstrap() { // registering event callback $this->addListener(MessageEvent::EVENT_TEXT_MESSAGE_RECEIVED, function (MessageEvent $event) { // sending your first message $this->getApi()->sendMessage([ 'chat_id' => $event->message->chat->id, 'text' => 'Hello World!', ]); }); } }
Run the bot instance
$bot = (new BotFactory(SampleBot::class))->create($apiToken); $bot->run();
License
MIT
统计信息
- 总下载量: 87
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-05-24