From 957c69bd1e6d7a6610ea5b85362e53ea179defe4 Mon Sep 17 00:00:00 2001 From: jerry Date: Sat, 27 Feb 2021 16:19:18 +0800 Subject: [PATCH] update to 2.2.7 version fix reply() bug fix access_token bug --- composer.json | 2 +- docs/update/v2.md | 22 ++++++++++++++++++++++ src/ZM/ConsoleApplication.php | 2 +- src/ZM/Context/Context.php | 8 +++++--- src/ZM/Event/ServerEventHandler.php | 2 +- 5 files changed, 30 insertions(+), 6 deletions(-) diff --git a/composer.json b/composer.json index ebabf6ef..b4f00878 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": "2.2.6", + "version": "2.2.7", "extra": { "exclude_annotate": [ "src/ZM" diff --git a/docs/update/v2.md b/docs/update/v2.md index 29f3f711..61f51871 100644 --- a/docs/update/v2.md +++ b/docs/update/v2.md @@ -1,5 +1,27 @@ # 更新日志(v2 版本) +## v2.2.7 + +> 更新时间:2021.2.27 + +- 修复:2.2.6 版本下 `reply()` 方法在群里调用会 at 成员的 bug +- 修复:空 `access_token` 的情况下会无法连入的 bug +- 修复:使用 Closure 闭包函数自行编写逻辑的判断返回 false 无法阻断连接的 bug +- + +## v2.2.6 + +> 更新时间:2021.2.26 + +- 新增:`uuidgen()` 全局函数,快速生成 uuid +- 修复:MySQL `rawQuery()` 在参数为非数组时会报 Warning 的 bug +- 新增:示例模块的 API 示例:一言查询 +- 优化:删减部分无用代码 +- 更改:`ctx()->reply()` 方法改为调用隐藏方法:`.handle_quick_operation` +- 修复:`ctx()->finalReply()` 一直以来的 bug(未阻断事件) +- 新增:`access_token` 配置项支持闭包函数自行设计判断方式和逻辑 +- 新增:全局函数 `working_dir()` + ## v2.2.5 > 更新时间:2021.2.20 diff --git a/src/ZM/ConsoleApplication.php b/src/ZM/ConsoleApplication.php index 36a0e6b2..ccf746fe 100644 --- a/src/ZM/ConsoleApplication.php +++ b/src/ZM/ConsoleApplication.php @@ -97,7 +97,7 @@ class ConsoleApplication extends Application } private function selfCheck() { - if (!extension_loaded("swoole")) die("Can not find swoole extension.\nSee: https://github.com/zhamao-robot/zhamao-framework/issues/19"); + if (!extension_loaded("swoole")) die("Can not find swoole extension.\nSee: https://github.com/zhamao-robot/zhamao-framework/issues/19\n"); if (version_compare(SWOOLE_VERSION, "4.4.13") == -1) die("You must install swoole version >= 4.4.13 !"); if (version_compare(PHP_VERSION, "7.2") == -1) die("PHP >= 7.2 required."); return true; diff --git a/src/ZM/Context/Context.php b/src/ZM/Context/Context.php index 9ead9f13..ce7dddcb 100644 --- a/src/ZM/Context/Context.php +++ b/src/ZM/Context/Context.php @@ -104,20 +104,22 @@ class Context implements ContextInterface * @param $msg * @param bool $yield * @return mixed + * @noinspection PhpMissingBreakStatementInspection */ public function reply($msg, $yield = false) { switch ($this->getData()["message_type"]) { case "group": + $operation["at_sender"] = false; + // no break case "private": case "discuss": $this->setCache("has_reply", true); $data = $this->getData(); $conn = $this->getConnection(); + $operation["reply"] = $msg; return (new ZMRobot($conn))->setCallback($yield)->callExtendedAPI(".handle_quick_operation", [ "context" => $data, - "operation" => [ - "reply" => $msg - ] + "operation" => $operation ]); } return false; diff --git a/src/ZM/Event/ServerEventHandler.php b/src/ZM/Event/ServerEventHandler.php index ab14f2bc..5c8e89bd 100644 --- a/src/ZM/Event/ServerEventHandler.php +++ b/src/ZM/Event/ServerEventHandler.php @@ -420,7 +420,7 @@ class ServerEventHandler return; } } elseif (is_string($token)) { - if ($access_token !== $token) { + if ($access_token !== $token && $token !== "") { $server->close($request->fd); Console::warning("Unauthorized access_token: " . $access_token); return;