Skip to content

Commit

Permalink
update to 2.2.7 version
Browse files Browse the repository at this point in the history
fix reply() bug
fix access_token bug
  • Loading branch information
crazywhalecc committed Feb 27, 2021
1 parent 2902c5e commit 957c69b
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 6 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": "2.2.6",
"version": "2.2.7",
"extra": {
"exclude_annotate": [
"src/ZM"
Expand Down
22 changes: 22 additions & 0 deletions docs/update/v2.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/ZM/ConsoleApplication.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public function run(InputInterface $input = null, OutputInterface $output = null
}

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;
Expand Down
8 changes: 5 additions & 3 deletions src/ZM/Context/Context.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,20 +104,22 @@ public function getCQResponse() { return self::$context[$this->cid]["cq_response
* @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;
Expand Down
2 changes: 1 addition & 1 deletion src/ZM/Event/ServerEventHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ public function onOpen($server, Request $request) {
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;
Expand Down

0 comments on commit 957c69b

Please sign in to comment.