首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Botman没有回复

Botman没有回复
EN

Stack Overflow用户
提问于 2018-04-25 16:30:29
回答 1查看 1.1K关注 0票数 2

Botman没有回答下面是我的代码

所有文件都通过composer下载

PHP 7.0版

Codeigniter版本3

控制器:-

代码语言:javascript
复制
require __DIR__ . '/vendor/autoload.php';

use BotMan\BotMan\BotMan;
use BotMan\BotMan\Drivers\DriverManager;
use BotMan\BotMan\BotManFactory;
use BotMan\BotMan\Cache\CodeIgniterCache;

defined('BASEPATH') OR exit('No direct script access allowed');

class Home extends CI_Controller {

public function __construct() {
    parent::__construct();
    $this->load->model('healthcare_model');
    $config = [
        'botman' => [
            'conversation_cache_time' => 30
        ],
    ];

// Load the driver(s) you want to use

// Create an instance

    $this->load->driver('cache');

    $this->botman = BotManFactory::create($config, new CodeIgniterCache($this->cache->file));
}

public function chat() {

    $this->load->view('home/chat', $data);
}

public function chat_reply() {
    $this->botman->hears('hello', function($bot) {
        $bot->reply('bye~');
    });
    // Listen
    $this->botman->listen();
}

查看:

代码语言:javascript
复制
<!doctype html>
<html>
 <head>
    <title>BotMan Widget</title>
    <meta charset="UTF-8">
    <link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/botman-web-widget@0/build/assets/css/chat.min.css">
</head>
<body>
    <script id="botmanWidget" src='https://cdn.jsdelivr.net/npm/botman-web-widget@0/build/js/chat.js'></script>
</body>
<script>
    var botmanWidget = {
        frameEndpoint: '/home/chat',
        chatServer: '/home/chat_reply'
    };
</script>
<script src='https://cdn.jsdelivr.net/npm/botman-web-widget@0/build/js/widget.js'></script>

我不能找到问题,因为它没有显示任何问题,但它没有回复。

请帮帮我!提前谢谢。

EN

回答 1

Stack Overflow用户

发布于 2019-02-19 19:02:54

你没提到瓶人版本。botman 2.0版的以下解决方案

您需要同等或更高版本的php7.1.3。因为在聊天机器人中,他们正在使用一些额外的功能,这些功能是在PHP版本7.1.3中添加的,比如代替list($array1,$array2)=$data现在添加了新的功能$array1,$array2=$data,它作为list($array1,$array2)工作,以及在7.1.3版本中所做的更多更改,所以你必须将你的PHP版本从7.0升级到7.1.3或更高版本。

然后使用composer安装botman webwidget驱动程序。现在尝试用下面的代码更新你的代码。

代码语言:javascript
复制
use BotMan\BotMan\BotMan;
use BotMan\BotMan\Drivers\DriverManager;
use BotMan\BotMan\BotManFactory;
use BotMan\BotMan\Cache\CodeIgniterCache;
use BotMan\BotMan\Messages\Incoming\Answer;
use BotMan\BotMan\Messages\Conversations\Conversation;
use BotMan\BotMan\Messages\Outgoing\Question;
use BotMan\BotMan\Messages\Outgoing\Actions\Button;
use BotMan\BotMan\Messages\Attachments\Image;
use BotMan\BotMan\Messages\Outgoing\OutgoingMessage;

    public function chat_reply() {
            $config = [];
            $this->load->driver('cache', array('adapter' => 'apc', 'backup' => 'file'));
            DriverManager::loadDriver(\BotMan\Drivers\Web\WebDriver::class);
            $botman = BotManFactory::create($config, new CodeIgniterCache($this->cache->file));
            $botman->hears("Hi", function (BotMan $bot) {
                    $bot->reply('bye~');
            });
    }
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50017498

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档