热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

Heardoesn'tworkwithwitmiddleware

Hello,Ihavethiscode:

Hello,

I have this code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
        $config = [

            'microsoft_app_id'     => $this->dbbot->microsoft_app_id,

            'microsoft_app_key'    => $this->dbbot->microsoft_app_key,

            'microsoft_bot_handle' => $this->dbbot->name

        ];



        $millow = BotFactory::create($config, new LaravelCache(), $request, new FileStorage(storage_path('bot')));



        $millow->hears('test', function (myBot $bot) use ($id) {

            $bot->reply('This is a test!');

        });



        $millow->middleware(Wit::create('*********'));

        $millow->fallback(function (myBot $bot) use ($id) {

            $bot->userStorage()->save(['id' => $id], 'bot');

            $this->getContact($bot, $id);

            $extras   = $bot->getMessage()->getExtras();

            $entities = $extras['entities'];

            try {

                $intent = $entities['intent'][0]['value'];

                switch ($intent) {

                    case "greetings":

                        return $bot->randomReply(trans('bot.random.greetings'));

                        break;

                    case "info":

                        return $bot->reply(trans('bot.random.info', [

                            'name'    => $this->dbbot->name,

                            'company' => $this->dbbot->company

                        ]));

                        break;

                    default:

                        return $bot->reply('The intent is: ' . $intent);

                        break;

                }

            } catch (\Exception $e) {

                $bot->reply('Sorry, I did not understand you.');

            }

        });



        $millow->listen();

If I type 'test' on the bot, I get the message 'Sorry, I did not understand you.'

If I remove the line

1
$millow->middleware(Wit::create('*********'));

and type test, I get the correct reply 'This is a test!'.

I am using Laravel.

Is this a bug or I am doing something wrong?

Thank you.

该提问来源于开源项目:botman/botman

Implemented in




1
dev-master

https://github.com/mpociot/botman/commit/66d8da5b2192ad2ac145da2fc7ea6caadc93e2ff


   



推荐阅读
author-avatar
夜半MM
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有