rodchyn/botman-bundle

安装: 7

依赖: 0

推荐: 0

安全: 0

星标: 0

关注者: 1

分支: 1

类型:symfony-bundle

v1.2.3 2018-08-16 06:05 UTC

This package is auto-updated.

Last update: 2024-09-09 02:29:09 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

示例

通过自动装配创建 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/