refactor CommandHelpGenerator to CommandInfoUtil

This commit is contained in:
sunxyw
2022-04-30 20:02:44 +08:00
parent 687260e53c
commit 8cb6a32341
4 changed files with 191 additions and 80 deletions

View File

@@ -13,6 +13,7 @@ use ZM\Annotation\Http\RequestMapping;
use ZM\Annotation\Swoole\OnCloseEvent;
use ZM\Annotation\Swoole\OnOpenEvent;
use ZM\Annotation\Swoole\OnRequestEvent;
use ZM\Annotation\Swoole\OnStart;
use ZM\API\CQ;
use ZM\API\OneBotV11;
use ZM\API\TuringAPI;
@@ -24,6 +25,7 @@ use ZM\Event\EventDispatcher;
use ZM\Exception\InterruptException;
use ZM\Module\QQBot;
use ZM\Requests\ZMRequest;
use ZM\Utils\CommandInfoUtil;
use ZM\Utils\MessageUtil;
use ZM\Utils\ZMUtil;
@@ -232,7 +234,12 @@ class Hello
#[CQCommand('帮助')]
public function help(): string
{
$helps = MessageUtil::generateCommandHelp();
$util = resolve(CommandInfoUtil::class);
$commands = $util->get();
$helps = [];
foreach ($commands as $command) {
$helps[] = $util->getHelp($command['id']);
}
array_unshift($helps, '帮助:');
return implode("\n", $helps);
}