add CQCommand alias

switch spl_autoload to psr-4 autoload
This commit is contained in:
whale
2020-06-13 11:28:31 +08:00
parent 5fd45c2542
commit 3b8aac5d8f
6 changed files with 41 additions and 13 deletions

View File

@@ -40,7 +40,7 @@ class MessageEvent
public function onBefore() {
$obj_list = ZMBuf::$events[CQBefore::class]["message"] ?? [];
foreach ($obj_list as $v) {
if($v->level < 200) break;
if ($v->level < 200) break;
EventHandler::callWithMiddleware(
$v->class,
$v->method,
@@ -65,7 +65,7 @@ class MessageEvent
}
}
foreach (ZMBuf::$events[CQBefore::class]["message"] ?? [] as $v) {
if($v->level >= 200) continue;
if ($v->level >= 200) continue;
$c = $v->class;
if (ctx()->getCache("level") != 0) continue;
EventHandler::callWithMiddleware(
@@ -117,6 +117,13 @@ class MessageEvent
return true;
});
return;
} elseif (in_array($word[0], $v->alias)) {
Console::debug("Calling $c -> {$v->method}");
$this->function_call = EventHandler::callWithMiddleware($obj[$c], $v->method, $class_construct, [$word], function ($r) {
if (is_string($r)) context()->reply($r);
return true;
});
return;
} elseif ($v->regexMatch != "" && ($args = matchArgs($v->regexMatch, context()->getMessage())) !== false) {
Console::debug("Calling $c -> {$v->method}");
$this->function_call = EventHandler::callWithMiddleware($obj[$c], $v->method, $class_construct, [$args], function ($r) {