update to 2.2.7 version

fix reply() bug
fix access_token bug
This commit is contained in:
jerry
2021-02-27 16:19:18 +08:00
parent 2902c5e805
commit 957c69bd1e
5 changed files with 30 additions and 6 deletions

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;