Skip to content

Commit

Permalink
update to 1.5.8 version
Browse files Browse the repository at this point in the history
add fullMatch to CQCommand.php
  • Loading branch information
crazywhalecc committed Jun 26, 2020
1 parent e976a96 commit 504934f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 2 additions & 0 deletions src/ZM/Annotation/CQ/CQCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
10 changes: 9 additions & 1 deletion src/ZM/Event/CQ/MessageEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public function onActivate() {
$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))) &&
Expand Down Expand Up @@ -135,6 +135,14 @@ public function onActivate() {
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;
}
}
}
Expand Down

0 comments on commit 504934f

Please sign in to comment.