rodchyn / botman-bundle
v1.2.3
2018-08-16 06:05 UTC
Requires
- botman/driver-botframework: ^1
- doctrine/cache: ^1.7
Requires (Dev)
- phpunit/phpunit: ^7
README
这个扩展可以帮助你在 symfony 框架内配置和创建 BotMan。
需求
Symfony 4, php 7+
安装
使用 composer 安装 symfoy 扩展
composer require maalls/botman-bundle
在 config/service.yaml 中添加 bot 配置作为参数
parameters: botman: botman: conversation_cache_time: 30 botframework: app_id: xxxxxxxxxx app_key: xxxxxxxxxx
示例
通过自动装配创建 bot
// in src/Service/MyService.php function __construct(\Maalls\BotManBundle\Service\Factory $factory) { // Create BotMan with BotFramework Driver. $bot = $factory->createBotFramework(); // \BotMan\BotMan\BotMan // Config can be added or overwritten $bot = $factory->createBotFramework(["botman" => ["conversation_cache_time" => 5]]); // OR with a specific driver $bot = $factory->create(\BotMan\Drivers\Telegram\TelegramDriver::class, ["telegram" => ["token" => "xxxx"]]); $bot->hears("(.*)", function($bot, $message) { $bot->reply("Anyway, hello."); }); }
测试
./vendor/bin/phpunit tests/