mirror of
https://github.com/zhamao-robot/zhamao-framework.git
synced 2026-07-23 08:35:35 +08:00
fix BotCommand prefix bug
This commit is contained in:
@@ -365,12 +365,12 @@ class OneBot12Adapter extends ZMPlugin
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// 测试 match
|
// 测试 match
|
||||||
if ($v->match !== '' && $v->match === $head) {
|
if ($v->match !== '' && ($v->prefix . $v->match) === $head) {
|
||||||
array_shift($cmd_explode);
|
array_shift($cmd_explode);
|
||||||
return [$v, $cmd_explode, $full_str];
|
return [$v, $cmd_explode, $full_str];
|
||||||
}
|
}
|
||||||
// 测试 alias
|
// 测试 alias
|
||||||
if ($v->match !== '' && $v->alias !== [] && in_array($head, $v->alias, true)) {
|
if ($v->match !== '' && $v->alias !== [] && in_array($head, array_map(fn ($x) => $v->prefix . $x, $v->alias), true)) {
|
||||||
array_shift($cmd_explode);
|
array_shift($cmd_explode);
|
||||||
return [$v, $cmd_explode, $full_str];
|
return [$v, $cmd_explode, $full_str];
|
||||||
}
|
}
|
||||||
@@ -610,7 +610,7 @@ class OneBot12Adapter extends ZMPlugin
|
|||||||
{
|
{
|
||||||
$handler = new AnnotationHandler(BotCommand::class);
|
$handler = new AnnotationHandler(BotCommand::class);
|
||||||
$handler->setReturnCallback(function ($result) use ($ctx) {
|
$handler->setReturnCallback(function ($result) use ($ctx) {
|
||||||
if (is_string($result)) {
|
if (is_string($result) || $result instanceof MessageSegment) {
|
||||||
$ctx->reply($result);
|
$ctx->reply($result);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user