diff --git a/composer.json b/composer.json index 588e5d2a..55642760 100644 --- a/composer.json +++ b/composer.json @@ -3,7 +3,7 @@ "description": "High performance QQ robot and web server development framework", "minimum-stability": "stable", "license": "Apache-2.0", - "version": "1.5.7", + "version": "1.5.8", "authors": [ { "name": "whale", diff --git a/src/ZM/Annotation/CQ/CQCommand.php b/src/ZM/Annotation/CQ/CQCommand.php index 4c78bcb2..6d468b6b 100644 --- a/src/ZM/Annotation/CQ/CQCommand.php +++ b/src/ZM/Annotation/CQ/CQCommand.php @@ -19,6 +19,8 @@ class CQCommand extends AnnotationBase implements Level public $match = ""; /** @var string */ public $regexMatch = ""; + /** @var string */ + public $fullMatch = ""; /** @var string[] */ public $alias = []; /** @var string */ diff --git a/src/ZM/Event/CQ/MessageEvent.php b/src/ZM/Event/CQ/MessageEvent.php index 3ca2858a..11f9492a 100644 --- a/src/ZM/Event/CQ/MessageEvent.php +++ b/src/ZM/Event/CQ/MessageEvent.php @@ -100,7 +100,7 @@ class MessageEvent $obj = []; foreach (ZMBuf::$events[CQCommand::class] ?? [] as $v) { /** @var CQCommand $v */ - if ($v->match == "" && $v->regexMatch == "") continue; + if ($v->match == "" && $v->regexMatch == "" && $v->fullMatch == "") continue; elseif (($v->user_id == 0 || ($v->user_id != 0 && $v->user_id == context()->getData()["user_id"])) && ($v->group_id == 0 || ($v->group_id != 0 && $v->group_id == (context()->getData()["group_id"] ?? 0))) && ($v->discuss_id == 0 || ($v->discuss_id != 0 && $v->discuss_id == (context()->getData()["discuss_id"] ?? 0))) && @@ -135,6 +135,14 @@ class MessageEvent return true; }); return; + } elseif ($v->fullMatch != "" && (preg_match("/".$v->fullMatch."/u", ctx()->getMessage(), $args)) != 0) { + Console::debug("Calling $c -> {$v->method}"); + array_shift($args); + $this->function_call = EventHandler::callWithMiddleware($obj[$c], $v->method, $class_construct, [$args], function ($r) { + if (is_string($r)) context()->reply($r); + return true; + }); + return; } } }