Compare commits

...

11 Commits

Author SHA1 Message Date
jerry
c04130fed1 update composer file 2020-11-15 18:52:52 +08:00
jerry
7fefcb850a update to 1.6.3 version
fix response redirect bug
fix document_index not working
2020-11-15 18:50:37 +08:00
Whale
1fe54d4b94 Update README.md 2020-11-10 23:25:44 +08:00
Whale
13a32bec79 Update README.md 2020-10-03 09:29:17 +08:00
Whale
0f5786c8c4 Update LICENSE 2020-09-25 15:35:34 +08:00
Whale
4ed046769f Update LICENSE 2020-09-25 15:34:48 +08:00
Whale
690980f72d Update README.md 2020-09-25 15:33:39 +08:00
Whale
f025eeb34a Update README.md 2020-09-20 15:57:21 +08:00
Whale
d642f50ef1 Update README.md 2020-09-20 00:39:20 +08:00
Whale
2900754307 Update README.md 2020-09-08 09:50:30 +08:00
Whale
dffeac668d Update SECURITY.md 2020-09-01 17:46:03 +08:00
5 changed files with 33 additions and 22 deletions

View File

@@ -17,13 +17,9 @@
## 开发者注意
**由于 CQHTTP 不再提供维护,转为 [OneBot 标准](https://github.com/howmanybots/onebot)(原 CQHTTP 插件衍生而来的机器人 HTTP 接口标准),本框架也将在未来改为兼容此标准。**
**同时将标准实现层独立出来,但默认依赖,对于一些基础的定义层会发生变更。**
**以上涉及的变更将在下一个大版本 (v2.0.0) 更新,请关注 commit 和 project**
**以上涉及的变更将在下一个大版本 (v2.0.0) 更新,请关注 2.0-dev 分支 和 Project 模块!**
**v2.0版本即将到来,请持续关注 [新文档](https://zhamao.xin/docs-v2/) 进度和 Project 模块展示的测试进度!**
## 简介
zhamao-framework 是一个 PHP Swoole 的聊天机器人框架,兼容 OneBot 标准,它会对微信公众号等终端收到的消息进行解析处理,并以模块化的形式进行开发,来完成机器人的自然语言对话等功能。
@@ -33,13 +29,11 @@ zhamao-framework 是一个 PHP Swoole 的聊天机器人框架,兼容 OneBot
## 开始
先安装环境,环境安装见下方文档。
1. `composer create-project zhamao/framework-starter` 从模板新建基础文档结构进行使用
2. 你也可以直接**Release** 中下载最新的 phar 包,放入文件夹后 `php server.phar` 快速启动框架
2. 你也可以直接拉取本项目,进入文件夹后 `composer update` 加载依赖后使用 `bin/start init` 快速初始化框架文件
3. 还可以使用 Dockerfile 构建 Docker 容器
## 文档
Pages托管[https://framework.zhamao.xin/](https://framework.zhamao.xin/)
国内服务器:[https://framework2.zhamao.xin/](https://framework2.zhamao.xin/)
[https://framework.zhamao.xin/](https://framework.zhamao.xin/)
## 特点
- 支持多账号
@@ -90,6 +84,8 @@ Pages托管[https://framework.zhamao.xin/](https://framework.zhamao.xin/)
### 支付宝
![支付宝二维码](/resources/images/alipay_img.jpg)
如果你对我们的周边感兴趣,我们还有炸毛机器人定制 logo 的雨伞,详情咨询作者 QQ我们会作为您捐助了本项目
## 关于
框架和 SDK 是 炸毛机器人 项目的核心框架开源部分。炸毛机器人是作者写的一个高性能机器人,曾获全国计算机设计大赛一等奖。
@@ -98,3 +94,5 @@ Pages托管[https://framework.zhamao.xin/](https://framework.zhamao.xin/)
本项目在更新内容时,请及时关注 GitHub 动态,更新前请将自己的模块代码做好备份。
项目框架采用 Apache-2.0 协议开源,在分发或重写修改等操作时需遵守协议。项目模块部分(`Module` 文件夹) 在非借鉴框架内代码时可不遵守 Apache-2.0 协议进行分发和修改(声明版权)。
**注意**:在你使用 mirai 等 `AGPL-3.0` 协议的机器人软件与框架连接时,使用本框架需要将你编写或修改的部分使用 `AGPL-3.0` 协议重新分发。

View File

@@ -4,9 +4,9 @@
| Version | Supported |
| ------- | ------------------ |
| 1.2.x | :white_check_mark: |
| 1.1.x | :x: |
| 1.0.x | :x: |
| 2.0 | :white_check_mark: |
| 1.6.x | :white_check_mark: |
| 1.x | :x: |
## Reporting a Vulnerability

View File

@@ -3,7 +3,7 @@
"description": "High performance QQ robot and web server development framework",
"minimum-stability": "stable",
"license": "Apache-2.0",
"version": "1.6.2",
"version": "1.6.3",
"authors": [
{
"name": "whale",

View File

@@ -27,7 +27,8 @@ class RequestEvent implements SwooleEvent
*/
private $response;
public function __construct(Request $request, Response $response) {
public function __construct(Request $request, Response $response)
{
$this->request = $request;
$this->response = $response;
}
@@ -36,7 +37,8 @@ class RequestEvent implements SwooleEvent
* @return $this|SwooleEvent
* @throws Exception
*/
public function onActivate() {
public function onActivate()
{
ZMUtil::checkWait();
foreach (ZMBuf::globals("http_header") as $k => $v) {
$this->response->setHeader($k, $v);
@@ -49,7 +51,10 @@ class RequestEvent implements SwooleEvent
$params = [];
while (true) {
$r = array_shift($uri);
if ($r === null) break;
if ($r === null) {
if ($node == ZMBuf::$req_mapping) goto statics;
else break;
}
if (($cnt = count($node["son"] ?? [])) == 1) {
if (isset($node["param_route"])) {
foreach ($node["son"] as $k => $v) {
@@ -80,13 +85,18 @@ class RequestEvent implements SwooleEvent
}
}
}
statics:
if (ZMBuf::globals("static_file_server")["status"]) {
$base_dir = ZMBuf::globals("static_file_server")["document_root"];
$base_index = ZMBuf::globals("static_file_server")["document_index"];
$uri = $this->request->server["request_uri"];
$path = realpath($base_dir . urldecode($uri));
if ($path !== false) {
if (is_dir($path) && mb_substr($uri, -1, 1) != "/") {
$this->response->redirect($uri . "/", 301);
$this->response->end();
return $this;
}
if (is_dir($path)) $path = $path . '/';
$work = realpath(DataProvider::getWorkingDir()) . '/';
if (strpos($path, $work) !== 0) {
@@ -150,7 +160,8 @@ class RequestEvent implements SwooleEvent
/**
* @inheritDoc
*/
public function onAfter() {
public function onAfter()
{
foreach (ZMBuf::$events[SwooleEventAfter::class] ?? [] as $v) {
if (strtolower($v->type) == "request" && $this->parseSwooleRule($v)) {
$c = $v->class;
@@ -162,12 +173,14 @@ class RequestEvent implements SwooleEvent
return $this;
}
private function responseStatus(int $int) {
private function responseStatus(int $int)
{
$this->response->status($int);
$this->response->end();
}
private function parseSwooleRule($v) {
private function parseSwooleRule($v)
{
switch (explode(":", $v->rule)[0]) {
case "containsGet":
case "containsPost":

View File

@@ -184,7 +184,7 @@ class Response
* @return mixed
*/
public function redirect($location, $http_code = null) {
return $this->redirect($location, $http_code);
return $this->response->redirect($location, $http_code);
}
/**