Compare commits

..

33 Commits
2.8.3 ... v2

Author SHA1 Message Date
Jerry
d3d64c8f06 fix class empty caused bug 2023-06-13 15:31:51 +08:00
crazywhalecc
f0cba01bd7 update to 2.8.9, fix ergodic order via #365 2023-06-12 21:19:17 +08:00
crazywhalecc
ea83ea2cce update to 2.8.9, fix light cache wrong 2023-06-12 21:19:17 +08:00
Jerry Ma
21f310852a update version to 2.8.8 2023-06-05 22:48:36 +08:00
Wang
6173cf2e37 Update LightCacheInside.php 2023-06-05 21:00:31 +08:00
Wang
4791099a78 Update global.php 2023-06-05 21:00:05 +08:00
Wang
9d1952f5f8 add bool type support for LightCache (#325) 2023-03-03 21:58:40 +08:00
Jerry
6543574695 update version to 2.8.7 2023-02-13 21:04:01 +08:00
Wang
5b1c771a2d 为键名使用强制类型转换string
使用数字作为键名时set()成功保存 但是停止框架后再启动框架数据落地恢复时报错类型不符合
Fatal error: Uncaught TypeError: Swoole\Table::set(): Argument #1 ($key) must be of type string, int given in zhamao/vendor/zhamao/framework/src/ZM/Store/LightCache.php:81
2023-02-13 21:04:01 +08:00
sunxyw
29d7d07c8e increment build number (build 480) 2023-01-26 21:59:27 +08:00
Wang
e85e1e57b1 init database in task worker (#271) 2023-01-24 12:11:41 +08:00
crazywhalecc
90a4c6803e update 2.0 docs 2022-12-31 16:54:03 +08:00
Github Build Bot
ff1b43ad89 increment build number (build 479) 2022-12-24 05:44:40 +00:00
Github Build Bot
cdd273808c update api docs 2022-12-24 05:44:39 +00:00
Jerry
f8bcc359da Merge pull request #196 from zhamao-robot/fix-class-psr-4
修复 getClassesPsr4 中默认过滤方法的路径 Bug
2022-12-24 13:43:47 +08:00
crazywhalecc
ccc0280d2f change fixer config 2022-12-24 01:26:34 +08:00
crazywhalecc
bd98608d2e change fixer config 2022-12-24 01:18:59 +08:00
crazywhalecc
90b6580e80 change global namespace import fixer config 2022-12-24 01:08:24 +08:00
crazywhalecc
64899a50c1 update to 2.8.5, fix getClassesPsr4 .plain find error bug 2022-12-24 01:04:08 +08:00
Jerry
d12f0bf317 Update README.md 2022-12-21 01:13:57 +08:00
Jerry Ma
422dd81bbf Update robot-annotations.md 2022-10-24 11:26:53 +08:00
sunxyw
3a6c821249 fix route-annotations.md static file server demo (#166) 2022-09-26 12:17:07 +08:00
crazywhalecc
a12b5eadf3 fix docs homepage 2022-08-28 11:40:11 +08:00
crazywhalecc
27c5debcb0 add termux support 2022-08-28 11:27:03 +08:00
Jerry Ma
594b7f5f82 Update README.md 2022-08-12 09:46:16 +08:00
Jerry Ma
2c28ed9ab8 fix explode_msg 0 msg error 2022-08-11 10:05:35 +08:00
FishZe
5f3a626557 Update global_functions.php 2022-08-11 10:05:35 +08:00
Github Build Bot
1ebcfa8e7e increment build number (build 478) 2022-08-07 05:19:10 +00:00
Github Build Bot
3edab143c3 update api docs 2022-08-07 05:19:09 +00:00
crazywhalecc
9cd5f24d2f update docs 2022-08-07 13:18:18 +08:00
crazywhalecc
34919afb36 bump version to 2.8.4 2022-08-07 13:18:18 +08:00
crazywhalecc
6282da4972 fix zm_sleep float bug and add test 2022-08-07 13:18:18 +08:00
crazywhalecc
de4748860c update default install php version 2022-08-06 10:23:53 +08:00
22 changed files with 153 additions and 96 deletions

View File

@@ -6,67 +6,77 @@ declare(strict_types=1);
* @since 2.7.0
*/
$rules = [
'@PSR12' => true,
'@Symfony' => true,
'@PhpCsFixer' => true,
'array_syntax' => [
'syntax' => 'short',
],
'list_syntax' => [
'syntax' => 'short',
],
'concat_space' => [
'spacing' => 'one',
],
'blank_line_before_statement' => [
'statements' => [
'declare',
],
],
'ordered_imports' => [
'imports_order' => [
'class',
'function',
'const',
],
'sort_algorithm' => 'alpha',
],
'single_line_comment_style' => [
'comment_types' => [
],
],
'yoda_style' => [
'always_move_variable' => false,
'equal' => false,
'identical' => false,
],
'multiline_whitespace_before_semicolons' => [
'strategy' => 'no_multi_line',
],
'constant_case' => [
'case' => 'lower',
],
'class_attributes_separation' => true,
'combine_consecutive_unsets' => true,
'declare_strict_types' => true,
'linebreak_after_opening_tag' => true,
'lowercase_static_reference' => true,
'no_useless_else' => true,
'no_unused_imports' => true,
'not_operator_with_successor_space' => false,
'not_operator_with_space' => false,
'ordered_class_elements' => true,
'php_unit_strict' => false,
'phpdoc_separation' => false,
'single_quote' => true,
'standardize_not_equals' => true,
'multiline_comment_opening_closing' => true,
'phpdoc_summary' => false,
'php_unit_test_class_requires_covers' => false,
'global_namespace_import' => false,
'phpdoc_order' => false,
];
if (PHP_VERSION_ID > 70400) {
$rules['no_useless_concat_operator'] = false;
}
// 'no_useless_concat_operator' => false,
return (new PhpCsFixer\Config())
->setRiskyAllowed(true)
->setRules([
'@PSR12' => true,
'@Symfony' => true,
'@PhpCsFixer' => true,
'array_syntax' => [
'syntax' => 'short',
],
'list_syntax' => [
'syntax' => 'short',
],
'concat_space' => [
'spacing' => 'one',
],
'blank_line_before_statement' => [
'statements' => [
'declare',
],
],
'ordered_imports' => [
'imports_order' => [
'class',
'function',
'const',
],
'sort_algorithm' => 'alpha',
],
'single_line_comment_style' => [
'comment_types' => [
],
],
'yoda_style' => [
'always_move_variable' => false,
'equal' => false,
'identical' => false,
],
'multiline_whitespace_before_semicolons' => [
'strategy' => 'no_multi_line',
],
'constant_case' => [
'case' => 'lower',
],
'class_attributes_separation' => true,
'combine_consecutive_unsets' => true,
'declare_strict_types' => true,
'linebreak_after_opening_tag' => true,
'lowercase_static_reference' => true,
'no_useless_else' => true,
'no_unused_imports' => true,
'not_operator_with_successor_space' => false,
'not_operator_with_space' => false,
'ordered_class_elements' => true,
'php_unit_strict' => false,
'phpdoc_separation' => false,
'single_quote' => true,
'standardize_not_equals' => true,
'multiline_comment_opening_closing' => true,
'phpdoc_summary' => false,
'php_unit_test_class_requires_covers' => false,
])
->setRules($rules)
->setFinder(
PhpCsFixer\Finder::create()
->in(__DIR__ . '/src')

View File

@@ -46,7 +46,7 @@
**如果有愿意一起开发框架本身的开发者,请提出 PR 或 Issue 参与开发!如果对框架本身的核心设计有更好的想法,可与作者成立开发组(目前仅 2 人),参与 OneBot V12 生态和框架本身的开发。**
**相关正在进行的版本任务见 Projects 一栏!**
**3.0已进入Alpha阶段**
## 简介
@@ -150,7 +150,7 @@ bash <(curl -fsSL https://zhamao.xin/go.sh)
框架和 SDK 是 炸毛机器人 项目的核心框架开源部分。炸毛机器人是作者写的一个高性能机器人,曾获全国计算机设计大赛一等奖。
作者的炸毛机器人已从2018年初起稳定运行了**四年半**,并且持续迭代。
作者的炸毛机器人已从2018年初起稳定运行了**五年**,并且持续迭代。
欢迎随时在 HTTP-API 插件群里提问,当然更好的话可以加作者 QQ[627577391](http://wpa.qq.com/msgrd?v=3&uin=627577391&site=qq&menu=yes)
或提交 [Issue](https://github.com/zhamao-robot/zhamao-framework/issues/new/choose) 进行疑难解答。

View File

@@ -50,6 +50,8 @@ $config['runtime'] = [
],
'namespace' => [],
],
'inside_table_size' => 65536 // 内部表字符串最大长度需要2的倍数
// 正常不要低于65536如果群数量过多可能出现会size不够。若swoole日志出现WARNING TableRow::set_value(): [key=wait_api,field=value]string value is too long可以将该值往大设置。
];
/* 轻量字符串缓存,默认开启 */

View File

@@ -1 +1 @@
module.exports = [{"title":"ZM","collapsable":true,"children":["ZM/ZMServer"]},{"title":"ZM/API","collapsable":true,"children":["ZM/API/GoCqhttpAPIV11","ZM/API/ZMRobot","ZM/API/CQ","ZM/API/TuringAPI","ZM/API/OneBotV11"]},{"title":"ZM/API/Proxies/Bot","collapsable":true,"children":["ZM/API/Proxies/Bot/AbstractBotProxy","ZM/API/Proxies/Bot/AllGroupsProxy","ZM/API/Proxies/Bot/AllBotsProxy"]},{"title":"ZM/Annotation/Swoole","collapsable":true,"children":["ZM/Annotation/Swoole/OnSwooleEventBase"]},{"title":"ZM/Command","collapsable":true,"children":["ZM/Command/CheckConfigCommand"]},{"title":"ZM/Command/Module","collapsable":true,"children":["ZM/Command/Module/ModulePackCommand","ZM/Command/Module/ModuleListCommand"]},{"title":"ZM/Container","collapsable":true,"children":["ZM/Container/Container","ZM/Container/WorkerContainer","ZM/Container/BoundMethod"]},{"title":"ZM/DB","collapsable":true,"children":["ZM/DB/DeleteBody","ZM/DB/UpdateBody","ZM/DB/InsertBody","ZM/DB/DB","ZM/DB/Table","ZM/DB/SelectBody"]},{"title":"ZM/Event","collapsable":true,"children":["ZM/Event/EventTracer","ZM/Event/EventDispatcher","ZM/Event/EventManager"]},{"title":"ZM/Event/SwooleEvent","collapsable":true,"children":["ZM/Event/SwooleEvent/OnTask","ZM/Event/SwooleEvent/OnMessage"]},{"title":"ZM/Http","collapsable":true,"children":["ZM/Http/Response"]},{"title":"ZM/Module","collapsable":true,"children":["ZM/Module/ModulePacker","ZM/Module/ModuleUnpacker","ZM/Module/ModuleBase"]},{"title":"ZM/MySQL","collapsable":true,"children":["ZM/MySQL/MySQLWrapper","ZM/MySQL/MySQLPool","ZM/MySQL/MySQLConnection","ZM/MySQL/MySQLQueryBuilder","ZM/MySQL/MySQLStatement","ZM/MySQL/MySQLStatementWrapper"]},{"title":"ZM/Store","collapsable":true,"children":["ZM/Store/LightCache","ZM/Store/ZMAtomic","ZM/Store/LightCacheInside"]},{"title":"ZM/Store/Redis","collapsable":true,"children":["ZM/Store/Redis/ZMRedis"]},{"title":"ZM/Utils","collapsable":true,"children":["ZM/Utils/MessageUtil","ZM/Utils/Terminal","ZM/Utils/ReflectionUtil","ZM/Utils/HttpUtil","ZM/Utils/DataProvider","ZM/Utils/ZMUtil","ZM/Utils/SignalListener","ZM/Utils/CommandInfoUtil","ZM/Utils/CoMessage"]},{"title":"ZM/Utils/Manager","collapsable":true,"children":["ZM/Utils/Manager/CronManager","ZM/Utils/Manager/ModuleManager","ZM/Utils/Manager/WorkerManager"]}]
module.exports = [{"title":"ZM","collapsable":true,"children":["ZM/ZMServer"]},{"title":"ZM/API","collapsable":true,"children":["ZM/API/CQ","ZM/API/ZMRobot","ZM/API/TuringAPI","ZM/API/GoCqhttpAPIV11","ZM/API/OneBotV11"]},{"title":"ZM/API/Proxies/Bot","collapsable":true,"children":["ZM/API/Proxies/Bot/AllGroupsProxy","ZM/API/Proxies/Bot/AbstractBotProxy","ZM/API/Proxies/Bot/AllBotsProxy"]},{"title":"ZM/Annotation/Swoole","collapsable":true,"children":["ZM/Annotation/Swoole/OnSwooleEventBase"]},{"title":"ZM/Command","collapsable":true,"children":["ZM/Command/CheckConfigCommand"]},{"title":"ZM/Command/Module","collapsable":true,"children":["ZM/Command/Module/ModulePackCommand","ZM/Command/Module/ModuleListCommand"]},{"title":"ZM/Container","collapsable":true,"children":["ZM/Container/BoundMethod","ZM/Container/WorkerContainer","ZM/Container/Container"]},{"title":"ZM/DB","collapsable":true,"children":["ZM/DB/UpdateBody","ZM/DB/DB","ZM/DB/InsertBody","ZM/DB/DeleteBody","ZM/DB/Table","ZM/DB/SelectBody"]},{"title":"ZM/Event","collapsable":true,"children":["ZM/Event/EventDispatcher","ZM/Event/EventTracer","ZM/Event/EventManager"]},{"title":"ZM/Event/SwooleEvent","collapsable":true,"children":["ZM/Event/SwooleEvent/OnMessage","ZM/Event/SwooleEvent/OnTask"]},{"title":"ZM/Http","collapsable":true,"children":["ZM/Http/Response"]},{"title":"ZM/Module","collapsable":true,"children":["ZM/Module/ModuleUnpacker","ZM/Module/ModuleBase","ZM/Module/ModulePacker"]},{"title":"ZM/MySQL","collapsable":true,"children":["ZM/MySQL/MySQLPool","ZM/MySQL/MySQLWrapper","ZM/MySQL/MySQLStatementWrapper","ZM/MySQL/MySQLQueryBuilder","ZM/MySQL/MySQLConnection","ZM/MySQL/MySQLStatement"]},{"title":"ZM/Store","collapsable":true,"children":["ZM/Store/LightCacheInside","ZM/Store/ZMAtomic","ZM/Store/LightCache"]},{"title":"ZM/Store/Redis","collapsable":true,"children":["ZM/Store/Redis/ZMRedis"]},{"title":"ZM/Utils","collapsable":true,"children":["ZM/Utils/CommandInfoUtil","ZM/Utils/Terminal","ZM/Utils/DataProvider","ZM/Utils/SignalListener","ZM/Utils/CoMessage","ZM/Utils/ReflectionUtil","ZM/Utils/MessageUtil","ZM/Utils/ZMUtil","ZM/Utils/HttpUtil"]},{"title":"ZM/Utils/Manager","collapsable":true,"children":["ZM/Utils/Manager/ModuleManager","ZM/Utils/Manager/WorkerManager","ZM/Utils/Manager/CronManager"]}]

View File

@@ -1,7 +1,7 @@
const apiConfig = require('./api')
module.exports = {
title: '炸毛框架',
title: '炸毛框架v2 旧版)',
description: '一个高性能聊天机器人 + Web 框架',
theme: 'antdocs',
markdown: {
@@ -34,7 +34,7 @@ module.exports = {
{ text: 'API', link: '/api/' },
{ text: 'FAQ', link: '/faq/' },
{ text: '更新日志', link: '/update/v2/' },
{ text: '炸毛框架 v1', link: 'https://docs-v1.zhamao.xin/' }
{ text: '炸毛框架 v3最新版', link: 'https://framework.zhamao.xin/' }
],
sidebar: {
'/guide/': [

View File

@@ -1 +1 @@
framework.zhamao.me
docs-v2.zhamao.me

View File

@@ -1,18 +1,17 @@
---
home: true
heroImage: ./logo_trans.png
actionBtn:
text: 快速上手
link: /guide/
type: primary
size: large
actions:
- theme: brand
text: 快速上手
link: /guide/
features:
- title: 高性能
details: 基于 PHP 的 Swoole 高性能扩展,利用 WebSocket 进行与 OneBot 协议兼容的聊天机器人软件的通信,还有数据库连接池、内存缓存、多任务进程等特色,大幅增强性能。
- title: 易于开发
details: 所有功能采用模块化设计,除特殊情况外几乎所有功能都不需要修改框架内任意代码,框架采用灵活的注解进行各类事件绑定,同时支持下断点调试。
- title: 接口直观
details: 支持命令、普通文本、正则匹配、自然语言处理等多种对话解析方式,利用协程巧妙实现了直观的交互式会话模式,同时支持多种富文本的处理。
- title: 高性能
details: 基于 PHP 的 Swoole 高性能扩展,利用 WebSocket 进行与 OneBot 协议兼容的聊天机器人软件的通信,还有数据库连接池、内存缓存、多任务进程等特色,大幅增强性能。
- title: 易于开发
details: 所有功能采用模块化设计,除特殊情况外几乎所有功能都不需要修改框架内任意代码,框架采用灵活的注解进行各类事件绑定,同时支持下断点调试。
- title: 接口直观
details: 支持命令、普通文本、正则匹配、自然语言处理等多种对话解析方式,利用协程巧妙实现了直观的交互式会话模式,同时支持多种富文本的处理。
footer: |
Apache-2.0 Licensed &nbsp;|&nbsp; Copyright © 2019-2022 Zhamao Developer Team &nbsp;|&nbsp; <a href="http://beian.miit.gov.cn">沪ICP备2021010446号-1</a>
---

View File

@@ -212,10 +212,10 @@ class Hello {
| 参数名称 | 参数范围 | 用途 | 默认 |
| ----------- | ------------------------------------ | ------------------------------------------------------------ | ---- |
| notice_type | `string`,支持填入 onebot 标准的内容 | 限定通知事件的类型,见 [OneBot - 通知事件](https://github.com/howmanybots/onebot/blob/master/v11/specs/event/notice.md) | 空 |
| user_id | `int64``string` | 限定通知事件用户 IDQQ 号),同上见 [OneBot - 通知事件](https://github.com/howmanybots/onebot/blob/master/v11/specs/event/notice.md) | 空 |
| group_id | `int64``string` | 限定通知事件群 IDQQ 群号),同上见 [OneBot - 通知事件](https://github.com/howmanybots/onebot/blob/master/v11/specs/event/notice.md) | 空 |
| operator_id | `int64``string` | 限定操作者 QQ 号,同上见 [OneBot - 通知事件](https://github.com/howmanybots/onebot/blob/master/v11/specs/event/notice.md) | 空 |
| notice_type | `string`,支持填入 onebot 标准的内容 | 限定通知事件的类型,见 [OneBot - 通知事件](https://github.com/botuniverse/onebot-11/blob/master/event/notice.md) | 空 |
| user_id | `int64``string` | 限定通知事件用户 IDQQ 号),同上见 [OneBot - 通知事件](https://github.com/botuniverse/onebot-11/blob/master/event/notice.md) | 空 |
| group_id | `int64``string` | 限定通知事件群 IDQQ 群号),同上见 [OneBot - 通知事件](https://github.com/botuniverse/onebot-11/blob/master/event/notice.md) | 空 |
| operator_id | `int64``string` | 限定操作者 QQ 号,同上见 [OneBot - 通知事件](https://github.com/botuniverse/onebot-11/blob/master/event/notice.md) | 空 |
| level | `int` | 事件优先级(越大越靠前) | 20 |
### 用法
@@ -240,10 +240,10 @@ TODO先放着有时间再更。
| 参数名称 | 参数范围 | 用途 | 默认 |
| ------------ | ------------------------------------ | ------------------------------------------------------------ | ---- |
| request_type | `string`,支持填入 onebot 标准的内容 | 限定请求事件的类型,见 [OneBot - 请求事件](https://github.com/howmanybots/onebot/blob/master/v11/specs/event/request.md) | 空 |
| user_id | `int64``string` | 限定请求事件当事人用户 IDQQ 号),见 [OneBot - 请求事件](https://github.com/howmanybots/onebot/blob/master/v11/specs/event/request.md) | 空 |
| sub_type | `string` | 限定请求事件来源群 IDQQ 群号),见 [OneBot - 请求事件](https://github.com/howmanybots/onebot/blob/master/v11/specs/event/request.md) | 空 |
| comment | `string` | 限定验证消息内容,见 [OneBot - 请求事件](https://github.com/howmanybots/onebot/blob/master/v11/specs/event/request.md) | 空 |
| request_type | `string`,支持填入 onebot 标准的内容 | 限定请求事件的类型,见 [OneBot - 请求事件](https://github.com/botuniverse/onebot-11/blob/master/event/request.md) | 空 |
| user_id | `int64``string` | 限定请求事件当事人用户 IDQQ 号),见 [OneBot - 请求事件](https://github.com/botuniverse/onebot-11/blob/master/event/request.md) | 空 |
| sub_type | `string` | 限定请求事件来源群 IDQQ 群号),见 [OneBot - 请求事件](https://github.com/botuniverse/onebot-11/blob/master/event/request.md) | 空 |
| comment | `string` | 限定验证消息内容,见 [OneBot - 请求事件](https://github.com/botuniverse/onebot-11/blob/master/event/request.md) | 空 |
| level | `int` | 事件优先级(越大越靠前) | 20 |
### 用法
@@ -268,7 +268,7 @@ TODO先放着有时间再更。
| 参数名称 | 参数范围 | 用途 | 默认 |
| --------------- | ------------------ | ------------------------------------------------------------ | ---- |
| meta_event_type | `string`**必需** | 限定元事件的类型,见 [OneBot - 元事件](https://github.com/howmanybots/onebot/blob/master/v11/specs/event/meta.md) | |
| meta_event_type | `string`**必需** | 限定元事件的类型,见 [OneBot - 元事件]([OneBot - 请求事件](https://github.com/botuniverse/onebot-11/blob/master/event/meta.md)) | |
| level | `int` | 事件优先级(越大越靠前) | 20 |
### 用法

View File

@@ -231,10 +231,10 @@ $config['static_file_server'] = [
```php
/**
* @RequestMapping("/images/{filename}")
* @param $param
* @param array $param
* @return StaticFileHandler
*/
public function staticImage($param) {
public function staticImage(array $param) {
Console::info("[下载图片] " . $param["filename"]);
return new StaticFileHandler($param["filename"], "/path/to/your/image_dir/");
}

View File

@@ -4,6 +4,10 @@
同时此处将只使用 build 版本号进行区分。
## build 478 (2022-8-7)
- 修复 `zm_sleep()` 无法传入小数的 Bug (#141)
## build 477 (2022-8-5)
- 修复了 `@CQNotice``@CQRequest` 注解无法正常激活的 Bug (#140)

View File

@@ -1,5 +1,11 @@
# 更新日志v2 版本)
## v2.8.4build 478
> 更新时间2022.8.7
- 修复 `zm_sleep()` 无法传入小数的 Bug (#141)
## v2.8.3build 477
> 更新时间2022.8.5

View File

@@ -245,6 +245,9 @@ function install_framework() {
}
# 环境变量设置
if [ "$TMPDIR" != "" ]; then
ZM_TEMP_DIR="$TMPDIR"
fi
test "$ZM_TEMP_DIR" = "" && ZM_TEMP_DIR="/tmp/.zm-runtime"
test "$ZM_CUSTOM_DIR" = "" && ZM_CUSTOM_DIR="zhamao-app"

View File

@@ -105,6 +105,8 @@ class AnnotationParser
}
*/
// 保留ergodic注解
$append_ergodics = [];
// 生成主树
$this->annotation_map[$v]['class_annotations'] = $class_annotations;
$this->annotation_map[$v]['methods'] = $methods;
@@ -120,7 +122,8 @@ class AnnotationParser
foreach (($this->annotation_map[$v]['methods'] ?? []) as $method) {
$copy = clone $vs;
$copy->method = $method->getName();
$this->annotation_map[$v]['methods_annotations'][$method->getName()][] = $copy;
$append_ergodics[$method->getName()][] = $copy;
// $this->annotation_map[$v]['methods_annotations'][$method->getName()][] = $copy;
}
}
@@ -139,6 +142,13 @@ class AnnotationParser
$inserted = [];
// 预处理将Class的ergodic注解拼接到每个方法的注解列表前面且按照顺序修复 #365
foreach (($this->annotation_map[$v]['methods_annotations'] ?? []) as $method_name => $annos) {
if (isset($append_ergodics[$method_name])) {
$this->annotation_map[$v]['methods_annotations'][$method_name] = array_merge($append_ergodics[$method_name], $annos);
}
}
// 预处理3处理每个函数上面的特殊注解就是需要操作一些东西的
foreach (($this->annotation_map[$v]['methods_annotations'] ?? []) as $method_name => $methods_annotations) {
foreach ($methods_annotations as $method_anno) {

View File

@@ -28,9 +28,9 @@ use ZM\Exception\InitException;
class ConsoleApplication extends Application
{
public const VERSION_ID = 477;
public const VERSION_ID = 480;
public const VERSION = '2.8.3';
public const VERSION = '2.8.10';
private static $obj;

View File

@@ -130,6 +130,15 @@ class OnWorkerStart implements SwooleEvent
Framework::saveProcessState(ZM_PROCESS_TASKWORKER, $server->worker_pid, ['worker_id' => $worker_id]);
try {
Framework::$server = $server;
$this->initMySQLPool();
$redis = ZMConfig::get('global', 'redis_config');
if ($redis !== null && $redis['host'] != '') {
if (!extension_loaded('redis')) {
Console::error(zm_internal_errcode('E00029') . "Can not find redis extension.\n");
} else {
ZMRedisPool::init($redis);
}
}
$this->loadAnnotations();
Console::success('TaskWorker #' . $server->worker_id . ' started');
} catch (Exception $e) {

0
src/ZM/Framework.php Executable file → Normal file
View File

View File

@@ -75,7 +75,7 @@ class LightCache
} else {
return false;
}
$result = self::$kv_table->set($k, [
$result = self::$kv_table->set((string) $k, [
'value' => $value,
'expire' => $v['expire'],
'data_type' => $data_type,
@@ -188,6 +188,9 @@ class LightCache
$data_type = '';
} elseif (is_int($value)) {
$data_type = 'int';
} elseif (is_bool($value)) {
$data_type = 'bool';
$value = json_encode($value);
} else {
throw new LightCacheException('E00048', 'Only can set string, array and int');
}

View File

@@ -6,6 +6,7 @@ namespace ZM\Store;
use Exception;
use Swoole\Table;
use ZM\Config\ZMConfig;
use ZM\Exception\LightCacheException;
use ZM\Exception\ZMException;
@@ -17,7 +18,8 @@ class LightCacheInside
public static function init(): bool
{
try {
self::createTable('wait_api', 3, 65536);
$size = ZMConfig::get('global', 'runtime')['inside_table_size'] ?? 65536;
self::createTable('wait_api', 3, $size);
self::createTable('connect', 3, 64); // 用于存单机器人模式下的机器人fd的
self::createTable('static_route', 64, 256); // 用于存储
self::createTable('light_array', 8, 512, 0.6);

View File

@@ -103,7 +103,7 @@ class ZMUtil
/*if (substr(file_get_contents($dir . '/' . $v), 6, 6) == '#plain') {
continue;
}*/
if (file_exists($dir . '/' . $pathinfo['basename'] . '.plain')) {
if (file_exists($dir . '/' . $v . '.plain')) {
continue;
}
if (mb_substr($pathinfo['basename'], 0, 7) == 'global_' || mb_substr($pathinfo['basename'], 0, 7) == 'script_') {

View File

@@ -75,7 +75,7 @@ function explode_msg(string $msg, array $includes = [' ', "\t"]): array
$msg_seg = explode("\n", $msg);
$ls = [];
foreach ($msg_seg as $v) {
if (empty(trim($v))) {
if (trim($v) === '') {
continue;
}
$ls[] = trim($v);
@@ -279,9 +279,10 @@ function get_onebot_target_id_name(string $message_type): string
*
* 与 {@link sleep()} 一致,只是增加了协程支持
*
* @param float|int $seconds 秒数支持到1ms0.001
* @since 2.7.3 此函数不再返回 true
*/
function zm_sleep(int $seconds = 1): void
function zm_sleep($seconds = 1): void
{
if (Coroutine::getCid() !== -1) {
System::sleep($seconds);

View File

@@ -14,8 +14,9 @@ function loader__generated_id__()
require_once Phar::running() . '/' . $v;
}
}
if ('__generate' . 'd_id__' === _PHAR_STUB_ID) {
if (('__generate' . 'd_id__') === _PHAR_STUB_ID) {
echo 'Cannot execute this file directly!' . PHP_EOL;
exit(1);
}
/* @phpstan-ignore-next-line */
return json_decode(file_get_contents(__DIR__ . '/zmplugin.json'), true) ?? ['zm_module' => false];

View File

@@ -76,4 +76,11 @@ class GlobalFunctionsTest extends TestCase
{
$this->assertEquals(['code' => 0, 'signal' => 0, 'output' => "foo\n"], zm_exec('echo foo'));
}
public function testZmSleep(): void
{
$starttime = microtime(true);
zm_sleep(0.001);
$this->assertGreaterThanOrEqual(0.001, microtime(true) - $starttime);
}
}