maalls / botman-bundle
v1.2.2
2018-02-22 10:25 UTC
Requires
- doctrine/cache: ^1.7
- maalls/driver-botframework: ^1
Requires (Dev)
- phpunit/phpunit: ^7
This package is not auto-updated.
Last update: 2024-09-29 04:43:16 UTC
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
示例
通过自动装配创建机器人
// 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/