maalls/botman-bundle

安装次数: 4

依赖: 0

建议者: 0

安全: 0

星标: 5

关注者: 2

分支: 1

公开问题: 0

类型:symfony-bundle

v1.2.2 2018-02-22 10:25 UTC

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/