mirror of
https://github.com/zhamao-robot/zhamao-framework.git
synced 2026-07-24 00:55:35 +08:00
update to 1.5.8 version
add fullMatch to CQCommand.php
This commit is contained in:
@@ -3,7 +3,7 @@
|
|||||||
"description": "High performance QQ robot and web server development framework",
|
"description": "High performance QQ robot and web server development framework",
|
||||||
"minimum-stability": "stable",
|
"minimum-stability": "stable",
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"version": "1.5.7",
|
"version": "1.5.8",
|
||||||
"authors": [
|
"authors": [
|
||||||
{
|
{
|
||||||
"name": "whale",
|
"name": "whale",
|
||||||
|
|||||||
@@ -19,6 +19,8 @@ class CQCommand extends AnnotationBase implements Level
|
|||||||
public $match = "";
|
public $match = "";
|
||||||
/** @var string */
|
/** @var string */
|
||||||
public $regexMatch = "";
|
public $regexMatch = "";
|
||||||
|
/** @var string */
|
||||||
|
public $fullMatch = "";
|
||||||
/** @var string[] */
|
/** @var string[] */
|
||||||
public $alias = [];
|
public $alias = [];
|
||||||
/** @var string */
|
/** @var string */
|
||||||
|
|||||||
@@ -100,7 +100,7 @@ class MessageEvent
|
|||||||
$obj = [];
|
$obj = [];
|
||||||
foreach (ZMBuf::$events[CQCommand::class] ?? [] as $v) {
|
foreach (ZMBuf::$events[CQCommand::class] ?? [] as $v) {
|
||||||
/** @var CQCommand $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"])) &&
|
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->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))) &&
|
($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 true;
|
||||||
});
|
});
|
||||||
return;
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user