Compare commits

...

26 Commits
1.6.2 ... 1.6.3

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
Whale
b6756179f5 Update README.md 2020-08-23 23:54:24 +08:00
jerry
1adcf76203 change logo 2020-08-23 23:53:45 +08:00
Whale
5b003ab575 Add files via upload 2020-08-23 23:52:07 +08:00
Whale
75f6aa531e Update README.md 2020-08-23 23:50:11 +08:00
Whale
6e1f4820f8 Update README.md 2020-08-23 23:49:16 +08:00
Whale
50ce81334b Update README.md 2020-08-23 23:49:05 +08:00
Whale
0ed0aa089a Update README.md 2020-08-23 23:48:47 +08:00
Whale
102ba769ec Update README.md 2020-08-23 23:48:05 +08:00
Whale
e062f484b1 Update README.md 2020-08-23 23:45:45 +08:00
Whale
3be3e8412a Update README.md 2020-08-23 23:44:15 +08:00
Whale
ab5abf1c00 Update README.md 2020-08-19 15:55:51 +08:00
Whale
3aaa72cfb9 Update README.md 2020-08-14 11:06:04 +08:00
Whale
10f846c214 Update README.md 2020-08-05 09:09:03 +08:00
Whale
67a42c4be9 Update README.md 2020-08-03 21:40:54 +08:00
Whale
7e4e58a322 Update README.md 2020-08-03 21:40:21 +08:00
6 changed files with 46 additions and 24 deletions

View File

@@ -1,33 +1,39 @@
# zhamao-framework
<div align="center">
<img src="/resources/images/logo_trans.png" height = "150" alt="炸毛框架"><br>
<h2>炸毛框架</h2>
炸毛框架 (zhamao-frameowork) 是一个协程高性能的聊天机器人 + Web 服务器开发框架<br><br>
[![作者QQ](https://img.shields.io/badge/作者QQ-627577391-orange.svg)]()
[![zhamao License](https://img.shields.io/hexpm/l/plug.svg?maxAge=2592000)](https://github.com/zhamao-robot/zhamao-framework/blob/master/LICENSE)
[![Latest Stable Version](http://img.shields.io/packagist/v/zhamao/framework.svg)](https://packagist.org/packages/zhamao/framework)
[![Banner](https://img.shields.io/badge/CQHTTP-v11-black)]()
[![dev-version](https://img.shields.io/badge/dev--version-v2.0.0--a1-green)]()
[![stupid counter](https://img.shields.io/github/search/zhamao-robot/zhamao-framework/stupid.svg)](https://github.com/zhamao-robot/zhamao-framework/search?q=stupid)
[![TODO counter](https://img.shields.io/github/search/zhamao-robot/zhamao-framework/TODO.svg)](https://github.com/zhamao-robot/zhamao-framework/search?q=TODO)
协程高性能的 **QQ 机器人 + Web 服务器** 开发框架(炸毛框架)。
</div>
<img src="https://avatars0.githubusercontent.com/u/48620312" height = "200" alt="炸毛框架" align=center/>
## 开发者注意
**由于 CQHTTP 不再提供维护,转为 [OneBot 标准](https://github.com/howmanybots/onebot)(原 CQHTTP 插件衍生而来的机器人 HTTP 接口标准),本框架也将在未来改为兼容此标准。**
**以上涉及的变更将在下一个大版本 (v2.0.0) 更新,请关注 2.0-dev 分支 和 Project 模块!**
**v2.0版本即将到来,请持续关注 [新文档](https://zhamao.xin/docs-v2/) 进度和 Project 模块展示的测试进度!**
## 简介
zhamao-framework 是一个基于 酷Q 的 PHP Swoole 的机器人框架,它会对 QQ 机器人收到的消息进行解析处理,并以模块化的形式进行开发,来完成机器人的自然语言对话等功能。
框架对接 酷Q 的桥梁是 **CQHTTP** 插件,这里是它的[项目地址](https://github.com/richardchien/coolq-http-api/)。
zhamao-framework 是一个 PHP Swoole 的聊天机器人框架,兼容 OneBot 标准,它会对微信公众号等终端收到的消息进行解析处理,并以模块化的形式进行开发,来完成机器人的自然语言对话等功能。
除了起到解析消息的作用,炸毛框架 还提供了完整的 WebSocket + HTTP 服务器,你还能用此框架构建出高性能的 API 接口服务器。
## 开始
先安装环境,环境安装见下方文档。
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/)
## 特点
- 支持多账号
@@ -45,7 +51,6 @@ Pages托管[https://framework.zhamao.xin/](https://framework.zhamao.xin/)
| 模块名称 | 说明 | 模块地址 |
| ------------------ | -------------------------------- | ------------------------------------------------------------ |
| 微信公众号兼容模块 | 为框架提供微信公众号订阅号兼容层 | [zhamao-wechat-patch](https://github.com/zhamao-robot/zhamao-wechat-patch) |
| 通用模块 | 图片上传和下载模块 | [zhamao-general-tools](https://github.com/zhamao-robot/zhamao-general-tools) |
## 计划开发内容
@@ -79,11 +84,15 @@ Pages托管[https://framework.zhamao.xin/](https://framework.zhamao.xin/)
### 支付宝
![支付宝二维码](/resources/images/alipay_img.jpg)
如果你对我们的周边感兴趣,我们还有炸毛机器人定制 logo 的雨伞,详情咨询作者 QQ我们会作为您捐助了本项目
## 关于
框架和 SDK 是 炸毛机器人 项目的核心框架开源部分。炸毛机器人3276124472是作者写的一个高性能机器人,曾获全国计算机设计大赛一等奖。
框架和 SDK 是 炸毛机器人 项目的核心框架开源部分。炸毛机器人是作者写的一个高性能机器人,曾获全国计算机设计大赛一等奖。
欢迎随时在 HTTP-API 插件群里提问,当然更好的话可以加作者 QQ627577391或提交 Issue 进行疑难解答。
本项目在更新内容时,请及时关注 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",

Binary file not shown.

After

Width:  |  Height:  |  Size: 61 KiB

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);
}
/**