带有 VK 社区回调驱动程序的 Botman Studio 听说在组内不起作用

Botman Studio with VK Community Callback driver hears not works inside Group

  1. 听说回退都很好:
use App\Http\Controllers\BotManController;
use BotMan\BotMan\Messages\Conversations\Conversation;
    
$botman = resolve('botman');
$botman->hears('Начать', function($bot) {
 $bot->startConversation(new OnboardingConversation);
}); //this works
$botman->fallback(function($bot) {
 $bot->startConversation(new OnboardingConversation);
}); //this works
  1. 内部组与 VK 驱动程序 听说 不工作,但 fallback 工作:
use App\Http\Controllers\BotManController;
use BotMan\BotMan\Messages\Conversations\Conversation;
    
$botman = resolve('botman');
$botman->group(['driver' => [VkCommunityCallbackDriver::class]], function($botman) {    
 $botman->hears('Начать', function($bot) {
  $bot->startConversation(new OnboardingConversation);
 }); //this NOT works
 $botman->fallback(function($bot) {
  $bot->startConversation(new OnboardingConversation);
 }); //this works
});

所有我想做的事情——例如 VK 和 Telegram 的通用机器人,但我需要检查用户是否在目标平台的黑名单中,所以如果“Driver”与 botman 的“MatchingMiddleware”有些相似——我不知道不明白为什么在“组”中听不到声音,这是来自网站的官方示例: official botman video tutorial screenshot

这个例子也不行:https://botman.io/2.0/receiving#command-groups-drivers

在 VK Driver 网站上没有关于“组”的信息:https://github.com/yageorgiy/botman-vk-community-callback-driver

更新: 我检查了 Marcel 视频和他的工作流程,在 Botman 视频中很多次他在 Sublime Text 编辑器中使用了一些魔术键,所以我 google 它,它是 PHP Companion,所以我安装了 Sublime Text and PHP Companion通过Tools->Command Pallete,并点击VkCommunityCallbackDriver,然后再次Tools->Command Pallete with command PHP Companion:Find 使用,出现了这段代码:

use BotMan\Drivers\VK\VkCommunityCallbackDriver;
use BotMan\Drivers\Telegram\TelegramDriver;

魔法起作用了,现在驱动程序的组方法起作用了,我仍然不明白为什么在文档或视频课程中没有指出这一点,好像组方法不是主要方法。

我仍然不明白为什么它不能从“盒子”开始工作,因为我一直认为编码人员使用这种复杂的解决方案是为了过上轻松的生活。但是经过 2 天的空搜索,我感到疲倦,所以我根据 Botman https://beyondco.de/course/build-a-chatbot/middleware-system/matching-middleware:

的官方视频教程编写了自定义中间件以仅“听到”VK 驱动程序

App\Middleware\VkMatchingMiddleware.php

<?php
namespace App\Middleware;
use BotMan\BotMan\BotMan;
use BotMan\BotMan\Interfaces\Middleware\Matching;
use BotMan\BotMan\Messages\Incoming\IncomingMessage;

class VkMatchingMiddleware implements Matching
{
    /**
* Handle a captured message.
*
* @param IncomingMessage $message
* @param callable $next
* @param BotMan $bot
*
* @return mixed
*/
    public function matching(IncomingMessage $message, $pattern, $regexMatched)
    {
        return $regexMatched && isset($message->getExtras()["client_info"]);
    }
}

Routes\botman.php:

<?php
use App\Http\Controllers\BotManController;
use BotMan\BotMan\Messages\Conversations\Conversation;
use App\Middleware\VkMatchingMiddleware;

$VkMatchingMiddleware = new VkMatchingMiddleware();

$botman = resolve('botman');

$botman->hears('Begin', function($bot) {
    $extras = $bot->getMessage()->getExtras();
    $bot->reply(print_r($extras, 1));
})->middleware($VkMatchingMiddleware);

$botman->fallback(function($bot) {    
    $bot->reply('fallback');
});

如果有人知道为什么它以这种方式工作但在 Vanilla 中不起作用,我很乐意看到解释。​​