Compare commits

...

1024 Commits

Author SHA1 Message Date
crazywhalecc
f33956f585 increment build number (build 667) 2023-01-04 16:11:58 +00:00
Jerry
5f0de0d513 Merge pull request #242 from zhamao-robot/onebot-file-transfer
添加 OneBot 12 文件上传和下载工具
2023-01-05 00:10:50 +08:00
Jerry
9c97d4a41c Merge pull request #241 from zhamao-robot/add-prompt-message
重构新的 waitMessage 到 prompt
2023-01-05 00:10:31 +08:00
crazywhalecc
cd4b7df1d7 add onebot file downloader and uploader 2023-01-04 23:21:41 +08:00
crazywhalecc
926b77a429 add prompt for bot context 2023-01-04 23:09:58 +08:00
crazywhalecc
7c30ba6b03 increment build number (build 666) 2023-01-04 13:39:30 +00:00
Jerry
cd85bd087c Merge pull request #240 from zhamao-robot/beta5-update
Beta5 系列升级内容(包含 Redis、sendAction 协程、reply 模式、修复 data 报错)
2023-01-04 21:38:17 +08:00
crazywhalecc
53ae4b1ed7 add bot context resume procedure 2023-01-04 21:24:29 +08:00
crazywhalecc
e526a94520 fix data error bug 2023-01-04 21:24:04 +08:00
crazywhalecc
d708485918 add match reply mode 2023-01-04 21:23:25 +08:00
crazywhalecc
c73a3e85aa add coroutine waiting result for sendAction 2023-01-04 21:22:54 +08:00
crazywhalecc
61ddf9515c cs fix 2023-01-04 20:44:13 +08:00
crazywhalecc
5b98480950 add redis wrapper 2023-01-04 20:43:03 +08:00
sunxyw
25fa833495 fix doxygen sudo permission (#239) 2023-01-04 16:54:46 +08:00
sunxyw
4b2af374f5 increment build number (build 665) 2023-01-04 08:45:21 +00:00
sunxyw
6238224e8c add postgres support (#236) 2023-01-04 16:44:26 +08:00
Jerry
fe890025c5 Merge pull request #237 from zhamao-robot/update-readme
更新首页介绍
2023-01-04 16:36:49 +08:00
sunxyw
78612b6e58 fix doxygen permission (#238) 2023-01-04 16:36:37 +08:00
Jerry
4957731760 Update README.md 2023-01-04 16:28:01 +08:00
sunxyw
fba39219cf increment build number (build 664) 2023-01-04 08:20:12 +00:00
sunxyw
b5329aef7c update api docs 2023-01-04 08:19:53 +00:00
sunxyw
4d6fc097c2 Merge pull request #235 from zhamao-robot/chore-updates
修复一些小问题和添加 GitAttributes
2023-01-04 16:18:53 +08:00
sunxyw
863c2d8c7a add workflow timeout limit 2023-01-04 15:33:38 +08:00
sunxyw
3596d6077d fix php8.0 coroutine fail 2023-01-04 15:26:41 +08:00
sunxyw
ed40799fe3 add .gitattributes 2023-01-04 14:42:27 +08:00
sunxyw
32afd38ad4 update bin permission 2023-01-04 14:36:25 +08:00
sunxyw
e0049fc7da increment build number (build 663) 2023-01-04 05:46:56 +00:00
sunxyw
f8c4bc01bc Merge pull request #234 from zhamao-robot/fix-some-tests
暂时停用网络请求测试并修复文件系统测试
2023-01-04 13:46:09 +08:00
sunxyw
0c13cded89 fix test result printer (#233) 2023-01-04 13:45:48 +08:00
sunxyw
690f8aed10 add cron support (#232) 2023-01-04 13:45:24 +08:00
sunxyw
5d473eddcf mark network io test as incomplete 2023-01-03 23:55:58 +08:00
sunxyw
2d6896adde fix FileSystemTest no perm 2023-01-03 23:35:38 +08:00
crazywhalecc
8f8002608e increment build number (build 662) 2023-01-03 10:39:03 +00:00
Jerry
9c3e6ce8bd Merge pull request #231 from zhamao-robot/fix-route-bug
修复 Route 注解无法正常解析的 Bug
2023-01-03 18:38:19 +08:00
Jerry
3a04c98f62 Update README.md 2023-01-03 13:29:05 +08:00
crazywhalecc
e8c8bd0ba7 fix route not working bug 2023-01-03 01:05:22 +08:00
crazywhalecc
939b02fdbc increment build number (build 661) 2023-01-02 17:05:14 +00:00
Jerry
cd52bfbfa5 Merge pull request #230 from zhamao-robot/redis
新增 Redis 支持
2023-01-03 01:04:34 +08:00
crazywhalecc
c78b7fa2b0 add redis support 2023-01-03 00:50:31 +08:00
crazywhalecc
e5b3509ebf update config for redis 2023-01-03 00:49:44 +08:00
crazywhalecc
d45d34430d refactor console table output things 2023-01-03 00:49:06 +08:00
crazywhalecc
26e172680d add sql validation 2023-01-03 00:48:31 +08:00
crazywhalecc
429eae64c6 increment build number (build 660) 2023-01-02 15:24:51 +00:00
Jerry
19aab968ae Merge pull request #229 from zhamao-robot/refactor-annotation
重构注解解析器和优化部分代码
2023-01-02 23:23:58 +08:00
crazywhalecc
7d9a8a5ee1 simplify and refactor the rest some code 2023-01-02 23:17:23 +08:00
crazywhalecc
1abdfc761d add dependency checker for plugin manager 2023-01-02 23:16:32 +08:00
crazywhalecc
43634974fc refactor annotation parser 2023-01-02 23:16:08 +08:00
crazywhalecc
5893d18149 change v3.sh comment 2023-01-02 23:15:19 +08:00
crazywhalecc
a145814923 to beta5 2023-01-02 23:15:07 +08:00
crazywhalecc
366b49ca82 add windows installation document 2023-01-02 23:14:44 +08:00
crazywhalecc
dbbc6f75d8 add level for Init 2023-01-02 23:14:30 +08:00
crazywhalecc
316c29628a add bat 2023-01-02 23:14:11 +08:00
sunxyw
11cd4ef56e increment build number (build 659) 2023-01-02 15:10:19 +00:00
sunxyw
fe8b38f968 Merge pull request #228 from zhamao-robot/refactor-command-manual
重构命令手册插件
2023-01-02 23:09:10 +08:00
sunxyw
8477bf153f fix CommandManualPlugin blocking annotations 2023-01-02 23:07:50 +08:00
sunxyw
2f94f5258d adjust StaticManualFactory method visibility 2023-01-02 23:01:40 +08:00
sunxyw
eb05cea443 fix reversed priority 2023-01-02 23:01:39 +08:00
sunxyw
af26086019 refactor command manual 2023-01-02 23:01:39 +08:00
Jerry
a0950a4be3 Merge pull request #227 from zhamao-robot/update-v3-sh
update v3.sh update script
2023-01-02 17:29:37 +08:00
crazywhalecc
9f970857ae update v3.sh update script 2023-01-02 17:22:40 +08:00
sunxyw
1a1fc8c558 increment build number (build 658) 2023-01-01 12:55:49 +00:00
sunxyw
fd7b9928ba Merge pull request #226 from zhamao-robot/add-build-command
添加 Phar 构建命令
2023-01-01 20:54:52 +08:00
sunxyw
da1bbee24c add built-in php support 2023-01-01 16:04:02 +08:00
sunxyw
3086bcdf6d simplify file filtering 2023-01-01 00:18:27 +08:00
sunxyw
50d6e75e71 add phar compression 2022-12-31 23:57:56 +08:00
sunxyw
413d783d53 use built-in default value 2022-12-31 23:01:00 +08:00
sunxyw
85240c753b add build command 2022-12-31 22:59:03 +08:00
crazywhalecc
c2c5433220 increment build number (build 657) 2022-12-31 13:05:23 +00:00
Jerry
5cd28964e6 Merge pull request #225 from zhamao-robot/refactor-config-config
重构配置类配置
2022-12-31 21:04:28 +08:00
crazywhalecc
d87b7dc0f7 increment build number (build 656) 2022-12-31 12:55:21 +00:00
Jerry
1d27091558 Merge pull request #224 from zhamao-robot/edge-bug-fix
边缘 Bug 修复
2022-12-31 20:53:35 +08:00
crazywhalecc
3dafbf4fbd increment build number (build 655) 2022-12-31 12:50:11 +00:00
Jerry
3a78f5e2b1 Merge pull request #223 from zhamao-robot/fix-ob12-cmd-bug
修复有关 BotCommand 的 Bug
2022-12-31 20:29:16 +08:00
sunxyw
3f26648a3c fix ZMRequestTest wrong assertion 2022-12-31 20:22:55 +08:00
sunxyw
a62e950870 add more path to cs-fix 2022-12-31 20:12:45 +08:00
sunxyw
aee7fa332a refactor config config 2022-12-31 20:12:20 +08:00
crazywhalecc
c1a0fae6e6 add interactive chat box docs 2022-12-31 19:57:49 +08:00
crazywhalecc
ed31edcc5c add some comments 2022-12-31 19:39:50 +08:00
crazywhalecc
4aea90cb39 add multiple bot support 2022-12-31 19:39:08 +08:00
crazywhalecc
a58c3aadab remove debug logger 2022-12-31 19:27:06 +08:00
Jerry
f2fb40b67c Merge pull request #222 from zhamao-robot/psr-simple-cache
将 KV 库接口调整为 PSR-16
2022-12-31 19:25:00 +08:00
crazywhalecc
18df76f650 fix AnnotationHandler return callback not working for BotCommand 2022-12-31 19:12:29 +08:00
crazywhalecc
dce126136b fix BotCommand prefix bug 2022-12-31 19:11:39 +08:00
crazywhalecc
d32f7b0ff8 update to beta4 version 2022-12-31 19:10:50 +08:00
crazywhalecc
d55362e190 update global functions for KV 2022-12-31 19:08:52 +08:00
crazywhalecc
6bcedea720 cs fix 2022-12-31 19:04:57 +08:00
Jerry
ccc801e6cb Merge pull request #221 from zhamao-robot/docs-update-1
更新部分文档
2022-12-31 19:03:07 +08:00
crazywhalecc
a2404482a3 change to psr-16 2022-12-31 19:02:41 +08:00
crazywhalecc
4c41dd09d2 update some docs 2022-12-31 18:12:28 +08:00
crazywhalecc
ab83194bbe Merge remote-tracking branch 'origin/main' 2022-12-31 17:42:18 +08:00
crazywhalecc
6013571267 update README.md and docs test activate 2022-12-31 17:41:20 +08:00
Jerry
2636bc2e35 Merge pull request #220 from zhamao-robot/update-workflows
根据最新的分支命名更新 Workflows
2022-12-31 17:37:01 +08:00
crazywhalecc
a2b013402b update workflows for newest 3.0 branch 2022-12-31 17:29:26 +08:00
Jerry
206f041d29 Merge pull request #219 from zhamao-robot/update-v3-docs-build
升级 v3 文档构建发布路径
2022-12-31 17:20:18 +08:00
crazywhalecc
ce885a7a61 update 3.0 docs build path 2022-12-31 17:19:23 +08:00
crazywhalecc
b0d0d5eba9 update 3.0 docs build path 2022-12-31 17:19:05 +08:00
sunxyw
d45c4e24fd switch hook to captainhook (#218) 2022-12-31 17:17:03 +08:00
crazywhalecc
49fffcc464 update 3.0 docs build path 2022-12-31 17:15:18 +08:00
crazywhalecc
e89d5ad1ac increment build number (build 654) 2022-12-31 08:14:31 +00:00
Jerry
11aed8c6be Merge pull request #217 from zhamao-robot/light-cache-update
新增全新的 LightCache
2022-12-31 16:13:37 +08:00
crazywhalecc
46d2f895e2 increment build number (build 653) 2022-12-31 07:45:20 +00:00
crazywhalecc
ed6b65eb88 cs fix 2022-12-31 15:45:09 +08:00
Jerry
8efb63a334 Merge pull request #216 from zhamao-robot/zm-request-update
新增 ZMRequest
2022-12-31 15:44:15 +08:00
crazywhalecc
13b5c44627 let getDriver() method always work 2022-12-31 15:36:33 +08:00
crazywhalecc
2a3c953c36 add ZMRequest support 2022-12-31 15:35:19 +08:00
crazywhalecc
fd8b3721ae add LightCache support 2022-12-31 15:27:09 +08:00
Jerry
3734f5d476 Merge pull request #215 from zhamao-robot/add-v3-sh
添加 v3 版本的一键安装脚本
2022-12-31 11:21:01 +08:00
crazywhalecc
088f963ad1 add v3.sh (and test my mac gpg) 2022-12-30 17:38:33 +08:00
crazywhalecc
c8a6bc69d3 increment build number (build 652) 2022-12-30 08:32:09 +00:00
Jerry
8584cc647c Merge pull request #214 from zhamao-robot/bot-action-and-some-update
拆分 Bot 动作到 Trait 以及更新一些类型强化的代码
2022-12-30 16:31:02 +08:00
crazywhalecc
d8ac604592 increment build number (build 651) 2022-12-30 08:16:55 +00:00
Jerry
9acb5e760b Merge pull request #213 from zhamao-robot/container-coroutine-support
让容器支持协程
2022-12-30 16:15:56 +08:00
crazywhalecc
96879bf415 update some doc and types 2022-12-30 16:15:22 +08:00
crazywhalecc
d7e815d670 fix windows CtrlC capture bug 2022-12-30 16:13:57 +08:00
crazywhalecc
dfcb8a4550 separate bot action method to BotActionTrait 2022-12-30 16:13:25 +08:00
crazywhalecc
96fa6b105c add coroutine for container 2022-12-30 11:30:29 +08:00
crazywhalecc
b86f51ab46 increment build number (build 650) 2022-12-30 03:23:40 +00:00
Jerry
8473a1152d Merge pull request #211 from zhamao-robot/fix-bot-context-not-sync
修复 BotContext 不同步问题
2022-12-30 11:22:43 +08:00
Jerry
65acfaa0bd Merge pull request #212 from zhamao-robot/add-event-docs
加(一些)事件文档
2022-12-30 10:06:34 +08:00
sunxyw
c58e08998a add event docs 2022-12-29 17:52:21 +08:00
sunxyw
9cf905421e fix bot context not sync 2022-12-29 14:58:18 +08:00
sunxyw
c65694402f increment build number (build 649) 2022-12-28 14:06:04 +00:00
sunxyw
0d24ae6192 add command manual plugin (#210) 2022-12-28 22:05:03 +08:00
sunxyw
383e0e22af increment build number (build 648) 2022-12-27 12:40:06 +00:00
sunxyw
87840930e0 use solution repository instead of built-in (#209)
* use solution repository instead of built-in

* suppress static analysis
2022-12-27 20:39:24 +08:00
sunxyw
05b3321af7 add windows entry binary (#208) 2022-12-27 15:39:36 +08:00
crazywhalecc
19e380d1fb increment build number (build 647) 2022-12-26 13:01:15 +00:00
Jerry
d1f69556b7 Merge pull request #206 from zhamao-robot/v3-beta2
发布 beta2
2022-12-26 21:00:22 +08:00
crazywhalecc
80ba34351c update to beta2 2022-12-26 20:02:47 +08:00
sunxyw
81a5e48b26 renew docs (#205) 2022-12-26 18:31:27 +08:00
crazywhalecc
aa28675016 increment build number (build 646) 2022-12-26 07:33:05 +00:00
Jerry
f8ecfa2745 Merge pull request #203 from zhamao-robot/bot-command-enhancement
完善 BotCommand 和 CommandArgument 的解析
2022-12-26 15:32:06 +08:00
crazywhalecc
efda3f4408 enhancement for BotCommand and CommandArgument 2022-12-26 03:19:53 +08:00
crazywhalecc
a5b29ac398 increment build number (build 645) 2022-12-25 19:17:43 +00:00
Jerry
73151db726 Merge pull request #202 from zhamao-robot/plugin-make-command
添加插件生成功能
2022-12-26 03:17:00 +08:00
crazywhalecc
aab57ce216 add PHPDoc 2022-12-25 23:20:57 +08:00
crazywhalecc
f140784a50 add PHPDoc 2022-12-25 23:19:49 +08:00
crazywhalecc
579269cb5b add plugin make command 2022-12-25 23:11:10 +08:00
sunxyw
ed5a9c6c12 add HttpEventListener test (#200) 2022-12-25 19:29:44 +08:00
sunxyw
ca430123c9 increment build number (build 644) 2022-12-25 11:08:18 +00:00
sunxyw
bc68aff654 Merge pull request #201 from zhamao-robot/change-container-impl
切换容器实现为 PHP-DI
2022-12-25 19:07:34 +08:00
sunxyw
19e3280e29 adjust container listening event level 2022-12-25 18:21:58 +08:00
sunxyw
a813e80b32 add class alias support 2022-12-25 18:15:07 +08:00
sunxyw
05b3446f59 change container to php-di 2022-12-25 17:42:32 +08:00
crazywhalecc
60ce722010 increment build number (build 643) 2022-12-24 08:57:41 +00:00
Jerry
1fc329c670 Merge pull request #197 from zhamao-robot/catcode-add-text-options
新增 CatCode encode 时选择是否编码文本的参数
2022-12-24 16:56:50 +08:00
crazywhalecc
4035ffcffb strict types 2022-12-24 16:19:26 +08:00
sunxyw
b41871a2a2 refactor config test (#199) 2022-12-24 15:46:13 +08:00
sunxyw
a44a7e86d7 Merge pull request #192 from zhamao-robot/move-api-docs-to-doxygen
用 Doxygen 替代 API Docs
2022-12-24 14:41:11 +08:00
sunxyw
716734d26f fix docs link target 2022-12-24 14:39:03 +08:00
sunxyw
b3e97febe1 adjust .gitignore 2022-12-24 14:36:27 +08:00
sunxyw
520db4b550 add doxy preview 2022-12-24 14:36:26 +08:00
sunxyw
c6c3efade4 fix typo 2022-12-24 14:36:26 +08:00
sunxyw
0b7f5f9f05 change api link to external 2022-12-24 14:36:26 +08:00
sunxyw
33a14dee8b move api docs to doxygen 2022-12-24 14:36:25 +08:00
crazywhalecc
bddc54b93d increment build number (build 642) 2022-12-24 05:59:33 +00:00
Jerry
2e0f5e2c51 Merge pull request #198 from zhamao-robot/v3-fix-class-psr-4
修复 getClassesPsr4 中默认过滤方法的路径 Bug
2022-12-24 13:58:28 +08:00
sunxyw
2c6f6067ca increment build number (build 641) 2022-12-24 05:35:58 +00:00
sunxyw
dcf41091ef add event provider test (#195) 2022-12-24 13:34:53 +08:00
crazywhalecc
8040a329cb fix getClassesPsr4 default ignore dir bug 2022-12-24 01:42:56 +08:00
crazywhalecc
6e43d4092f add CatCode text encode options 2022-12-24 01:38:15 +08:00
sunxyw
0ac2985fc1 increment build number (build 640) 2022-12-23 14:57:18 +00:00
sunxyw
1e037b9610 Merge pull request #194 from zhamao-robot/add-tests
添加些许测试
2022-12-23 22:56:33 +08:00
sunxyw
38b70db2dc add more FileSystemTest 2022-12-23 22:43:25 +08:00
sunxyw
b35d546555 add phpstan extension for prophecy 2022-12-23 20:26:35 +08:00
sunxyw
5e3d07abe6 add FileSystemTest 2022-12-23 20:23:07 +08:00
sunxyw
1d131871f1 add CatCode test 2022-12-23 17:35:19 +08:00
sunxyw
5e8f80b626 enhance test run (#193) 2022-12-23 17:16:08 +08:00
sunxyw
9128efbaa1 increment build number (build 639) 2022-12-20 17:26:49 +00:00
sunxyw
3545e1173e Merge pull request #190 from zhamao-robot/fix-init-command-dir
修复相对路径问题
2022-12-21 01:25:49 +08:00
sunxyw
9bf95223a1 fix user command dir path 2022-12-21 01:19:45 +08:00
sunxyw
3f2bd69002 fix global define bootstrapper relative path 2022-12-21 00:38:37 +08:00
sunxyw
4554bbc85b remove internal files from extract list 2022-12-21 00:34:24 +08:00
sunxyw
8901c31631 fix command loader relative path 2022-12-21 00:28:20 +08:00
sunxyw
61ece52edc fix init command dir 2022-12-21 00:13:53 +08:00
crazywhalecc
fb936e97ac remove prefer for composer 2022-12-20 23:49:41 +08:00
crazywhalecc
8ca4f7400a increment build number (build 638) 2022-12-20 15:46:29 +00:00
Jerry
61b48676ae Merge pull request #188 from zhamao-robot/v3-beta1
Beta 1 发布
2022-12-20 23:45:43 +08:00
crazywhalecc
257e59b79f remove debug log 2022-12-20 23:42:29 +08:00
crazywhalecc
c19791c31d remove debug log 2022-12-20 23:41:58 +08:00
crazywhalecc
c99747c1f6 add class alias helper generate command 2022-12-20 23:36:43 +08:00
crazywhalecc
a9b6989966 Merge remote-tracking branch 'origin/v3-beta1' into v3-beta1
# Conflicts:
#	src/Globals/global_class_alias.php
2022-12-20 23:22:55 +08:00
crazywhalecc
c9bf0fb13c prerelease of beta1 2022-12-20 23:19:55 +08:00
sunxyw
04247048d4 increment build number (build 637) 2022-12-20 15:05:27 +00:00
sunxyw
b2a6c2f5e0 add container class_alias support (#189) 2022-12-20 23:04:26 +08:00
crazywhalecc
865c306e14 prerelease of beta1 2022-12-20 20:10:40 +08:00
sunxyw
588fc919d9 increment build number (build 636) 2022-12-19 12:23:38 +00:00
sunxyw
8ff7da4d23 PHP80 小修 (#187)
* migrate-php80

fix styles
fix static analyse

* fix some bugs
2022-12-19 20:22:47 +08:00
sunxyw
da516b487d update readme test badge src (#186) 2022-12-19 15:20:01 +08:00
crazywhalecc
06615cbb29 increment build number (build 635) 2022-12-19 06:02:03 +00:00
crazywhalecc
463ee0cced update api docs 2022-12-19 06:01:59 +00:00
Jerry
208ccd6642 Merge pull request #185 from zhamao-robot/plugin-update-post
完善插件加载系统
2022-12-19 14:01:02 +08:00
crazywhalecc
cd2bb1b570 add plugin loader support 2022-12-19 01:45:27 +08:00
crazywhalecc
52a195aca2 fix DBException syntax error 2022-12-19 01:43:47 +08:00
crazywhalecc
fbc3cf00a2 increment build number (build 634) 2022-12-18 12:14:53 +00:00
crazywhalecc
ede5f456a8 update api docs 2022-12-18 12:14:51 +00:00
Jerry
2633e91d4d Merge pull request #184 from zhamao-robot/plugin-update-pre
插件和 OneBot 12 适配器前置内容
2022-12-18 20:13:50 +08:00
crazywhalecc
39b3a74d34 refactor with php-libonebot factory classes 2022-12-18 18:33:51 +08:00
crazywhalecc
3ecd224ce6 separate onebot 12 adapter things 2022-12-18 18:31:35 +08:00
sunxyw
49c7033eaa update dependencies (#180)
* update dependencies

* revert swoole-helper update
2022-12-18 15:58:48 +08:00
crazywhalecc
20ca848df9 increment build number (build 633) 2022-12-17 16:42:49 +00:00
crazywhalecc
5b0e3ed636 update api docs 2022-12-17 16:42:47 +00:00
Jerry
14840715bc Merge pull request #181 from zhamao-robot/8.0-upgrade
兼容 8.x PHP 一些改动
2022-12-18 00:41:56 +08:00
crazywhalecc
ed4537e5d5 update some strict parameters and separate easter eggs 2022-12-18 00:17:28 +08:00
crazywhalecc
58d4b4427d update default download native php to 8.1 2022-12-18 00:15:55 +08:00
crazywhalecc
8c6aba9361 rename Instant to ZM 2022-12-18 00:15:34 +08:00
crazywhalecc
1173949bba rename Instant to ZM 2022-12-18 00:15:19 +08:00
crazywhalecc
279956456c remove unused files 2022-12-18 00:11:54 +08:00
crazywhalecc
3f8c557a96 add requirement tokenizer 2022-12-18 00:11:33 +08:00
sunxyw
ff93201ab1 increment build number (build 632) 2022-12-17 16:00:09 +00:00
sunxyw
cd94539e99 update api docs 2022-12-17 16:00:07 +00:00
sunxyw
adc1d176e3 Merge pull request #179 from zhamao-robot/migrate-symfony-console-v6
迁移 Symfony Console V6
2022-12-17 23:59:19 +08:00
sunxyw
44c25f7fdd make commands lazily loaded 2022-12-17 22:30:19 +08:00
sunxyw
3806983bc2 change commands definition to attribute 2022-12-17 21:53:24 +08:00
sunxyw
c6f877700e add contributing document (#178) 2022-12-17 19:45:04 +08:00
sunxyw
c2fb90dfc7 increment build number (build 631) 2022-12-17 11:43:42 +00:00
sunxyw
ca61e6a238 update api docs 2022-12-17 11:43:41 +00:00
sunxyw
9399e54da8 Merge pull request #176 from zhamao-robot/docker-compose-support
增加 Docker Compose 支持
2022-12-17 19:42:42 +08:00
sunxyw
385f217b96 remove symfony/polyfill-php80 2022-12-17 16:29:28 +08:00
sunxyw
65bb6a2473 improve Command phpdoc 2022-12-17 16:27:49 +08:00
sunxyw
a430cf59c4 add docker init to InitCommand 2022-12-16 21:58:19 +08:00
sunxyw
4bf328ef67 refactor InitCommand 2022-12-16 18:05:51 +08:00
sunxyw
ebb724415d split InitException to SingletonViolationException 2022-12-16 17:59:12 +08:00
sunxyw
daa07dcb2b add docker compose support 2022-12-16 15:29:10 +08:00
sunxyw
635f081437 increment build number (build 630) 2022-11-18 07:22:16 +00:00
sunxyw
c7b4ca2a82 Merge pull request #173 from zhamao-robot/advance-exception
改进异常
2022-11-18 15:21:33 +08:00
sunxyw
b5c91531fa fix comment position 2022-11-18 15:16:48 +08:00
sunxyw
8199e91ce0 remove todo from InterruptException 2022-11-17 21:11:11 +08:00
sunxyw
44c32c1711 fix styles 2022-11-15 23:14:31 +08:00
sunxyw
5a3da43640 fix unused argument 2022-11-15 23:11:24 +08:00
sunxyw
352f3e920e deprecate ZMKnownException 2022-11-15 21:51:15 +08:00
sunxyw
5f4a00c77e refactor ZMException 2022-11-15 21:48:46 +08:00
crazywhalecc
aeea6f5dc1 increment build number (build 629) 2022-11-14 02:10:52 +00:00
Jerry
ea74a531b4 Merge pull request #172 from zhamao-robot/orgianze-bootstrap
重新组织 Bootstraper
2022-11-14 10:09:52 +08:00
sunxyw
02003b2bd3 reduce useless method 2022-11-12 01:15:40 +08:00
sunxyw
723dfd30a2 fix styles 2022-11-08 17:33:25 +08:00
sunxyw
aa29dc99f3 orgianze bootstrapper 2022-11-08 17:28:07 +08:00
crazywhalecc
74ba4d0145 increment build number (build 628) 2022-11-06 02:15:29 +00:00
crazywhalecc
5705f5227f update api docs 2022-11-06 02:15:28 +00:00
Jerry
3bb34b46ee Merge pull request #170 from zhamao-robot/proxy-server
添加代理、升级到 PHP8.0
2022-11-06 10:14:47 +08:00
crazywhalecc
4d0ea99f47 fix posix killer 2022-11-04 12:35:17 +08:00
sunxyw
fe70c07113 Merge pull request #171 from zhamao-robot/update-workflow
更新Workflow
2022-11-04 11:36:49 +08:00
sunxyw
27c6bf1864 add PHP8.2 support 2022-11-03 17:37:52 +08:00
sunxyw
f4ded4c6d7 drop PHP7.4 support 2022-11-03 17:36:09 +08:00
sunxyw
4a2c7f5ecb bump fkirc/skip-duplicate-actions to v5 2022-11-03 17:35:38 +08:00
crazywhalecc
7a051380e2 fix php version requirements 2022-11-03 10:36:08 +08:00
crazywhalecc
35dec947df add proxy server command and update lowest version of PHP >= 8.0 2022-11-03 10:18:17 +08:00
crazywhalecc
6b34427855 increment build number (build 627) 2022-10-02 10:35:36 +00:00
crazywhalecc
59a9f30089 update api docs 2022-10-02 10:35:35 +00:00
Jerry Ma
779564ebb6 Merge pull request #169 from zhamao-robot/state-and-windows
add state and ctrl+C support for windows
2022-10-02 18:34:49 +08:00
crazywhalecc
a4f992b9e5 add state and ctrl+C support for windows 2022-09-26 22:44:41 +08:00
sunxyw
cf3f09600b increment build number (build 626) 2022-09-23 14:12:45 +00:00
sunxyw
83c1d63408 update api docs 2022-09-23 14:12:42 +00:00
sunxyw
43337c34c8 fix config upstream changes (#168) 2022-09-23 22:11:26 +08:00
crazywhalecc
bb431ccf53 increment build number (build 625) 2022-09-23 09:09:14 +00:00
crazywhalecc
ba69cc93ee update api docs 2022-09-23 09:09:12 +00:00
Jerry Ma
406de8f4df Merge pull request #167 from zhamao-robot/fix-relative-path-check-in-windows
修复 isRelativePath 在 Windows 环境判断相反的 Bug
2022-09-23 17:08:13 +08:00
crazywhalecc
fd05fe6e25 fix 2022-09-23 12:50:44 +08:00
sunxyw
10a0ee9142 increment build number (build 624) 2022-09-11 11:33:47 +00:00
sunxyw
836d4dc1ef Merge pull request #165 from zhamao-robot/refactor-workflow
重构 Workflow
2022-09-11 19:32:56 +08:00
sunxyw
a18fcdb21e adjust workflow php version 2022-09-10 16:04:15 +08:00
sunxyw
6c9cd06e4a simplify incrememt build number 2022-09-09 21:03:51 +08:00
sunxyw
44c1ac054c avoid duplicate workflow runs 2022-09-09 20:55:44 +08:00
sunxyw
9d77d60887 fix styles 2022-09-09 18:59:46 +08:00
sunxyw
8f7fd97ebe refactor workflow 2022-09-09 18:54:55 +08:00
sunxyw
87e3b2249c increment build number (build 623) 2022-08-28 06:12:39 +00:00
sunxyw
5e12af77a4 drop config array access support (#163) 2022-08-28 14:12:01 +08:00
sunxyw
47244373d7 add custom phpunit printer (#164) 2022-08-28 13:03:58 +08:00
sunxyw
a72530598a increment build number (build 622) 2022-08-27 18:20:38 +00:00
sunxyw
2679facf24 update api docs 2022-08-27 18:20:37 +00:00
sunxyw
cf9db4b0d4 add config trace (#159)
* add config trace

* fix config tracer bug
2022-08-28 02:19:26 +08:00
crazywhalecc
f341c8585e increment build number (build 621) 2022-08-27 12:34:51 +00:00
crazywhalecc
28f7b47034 update api docs 2022-08-27 12:34:50 +00:00
Jerry Ma
99954f9140 Merge pull request #162 from zhamao-robot/windows-support-relative-path
FileSystem.php isRelativePath() 对 Windows 的兼容性
2022-08-27 20:34:02 +08:00
Jerry Ma
85b21d63ed Merge pull request #161 from zhamao-robot/fix-config-overwrite-bug
修复 Framework 中 Config 重写的 Bug
2022-08-27 20:33:48 +08:00
Jerry Ma
ef443d9912 Merge pull request #160 from zhamao-robot/sqlite-support
Sqlite 支持
2022-08-27 20:33:36 +08:00
crazywhalecc
db2b22c822 FileSystem.php isRelativePath() compatibility for windows 2022-08-27 20:03:22 +08:00
crazywhalecc
24156884e4 fix config overwrite bug in framework init 2022-08-27 19:56:29 +08:00
crazywhalecc
6413567353 change global config for database 2022-08-27 19:51:09 +08:00
crazywhalecc
84f84dad40 add sqlite extensions for github action 2022-08-27 19:50:40 +08:00
crazywhalecc
dd01653da9 add SQLiteDriver.php and change MySQLDriver.php 2022-08-27 19:47:45 +08:00
crazywhalecc
085472a12c refactor MySQL component to support SQLite at the same time 2022-08-27 19:45:23 +08:00
crazywhalecc
e9b6965678 remove redundant library 2022-08-27 19:39:02 +08:00
sunxyw
1a9680c09a increment build number (build 620) 2022-08-27 08:26:49 +00:00
sunxyw
40f8fe22ee update api docs 2022-08-27 08:26:48 +00:00
sunxyw
be6002dd64 Merge pull request #157 from zhamao-robot/fix-config-loading
修正&改进配置加载
2022-08-27 16:25:43 +08:00
sunxyw
96ebb770b6 add environment aliases 2022-08-27 01:12:38 +08:00
sunxyw
9bcdb254c9 increment build number (build 619) 2022-08-26 16:54:30 +00:00
sunxyw
87e71f1eb8 add repl command (#155) 2022-08-27 00:53:45 +08:00
sunxyw
451ce104c5 fix config loading 2022-08-27 00:42:43 +08:00
sunxyw
7920711988 increment build number (build 618) 2022-08-23 15:43:41 +00:00
sunxyw
6e78f2caf2 update api docs 2022-08-23 15:43:37 +00:00
sunxyw
2727b056eb Merge pull request #146 from zhamao-robot/refactor-config
基于 LibOB Config 类重构 ZMConfig
2022-08-23 23:42:30 +08:00
sunxyw
975d0e3540 allow multiple set config 2022-08-23 18:18:20 +08:00
sunxyw
eb7e700e7c replace legacy config 2022-08-23 18:02:00 +08:00
sunxyw
18892a14c2 ready to replace legacy config 2022-08-23 17:51:20 +08:00
sunxyw
6cbde80a1c delete outdated config classes 2022-08-23 17:36:45 +08:00
sunxyw
6fc875aa72 fix windows compatibility 2022-08-23 16:00:55 +08:00
sunxyw
29f5c3c758 change confusing name global to default 2022-08-23 15:59:55 +08:00
sunxyw
afa6411004 add array replace feature 2022-08-23 15:37:31 +08:00
crazywhalecc
67526c30da increment build number (build 617) 2022-08-22 13:39:34 +00:00
Jerry Ma
dc67dbc489 Merge pull request #152 from zhamao-robot/more-windows-support
add phpunit windows support
2022-08-22 21:38:21 +08:00
crazywhalecc
05ac2feebd add windows exit code support 2022-08-22 21:32:00 +08:00
crazywhalecc
6f30c04899 fix php 7.4 stuck bug 2022-08-22 21:27:23 +08:00
crazywhalecc
dfce8e9749 remove default mysql host 2022-08-22 21:22:49 +08:00
crazywhalecc
aae326133b cs-fix 2022-08-22 21:03:33 +08:00
crazywhalecc
15383a6b92 add phpunit windows support 2022-08-22 20:54:14 +08:00
sunxyw
5d8a1deb35 add yaml and toml config support 2022-08-22 17:15:10 +08:00
sunxyw
b09d12aad5 add config patch support 2022-08-22 17:02:50 +08:00
sunxyw
488acc3e69 fix incorrect onebot namespace 2022-08-22 16:30:45 +08:00
sunxyw
32534c870d add clearer exception 2022-08-22 16:29:27 +08:00
sunxyw
74af1516ac add get file load type test 2022-08-22 16:12:50 +08:00
sunxyw
07b2f175f3 add more test cases 2022-08-22 16:12:49 +08:00
sunxyw
1a1c65afce fix code styles 2022-08-22 16:12:49 +08:00
sunxyw
90282b858e fix inappropriate config group name 2022-08-22 16:12:49 +08:00
sunxyw
f819922d8a add basic usable config 2022-08-22 16:12:48 +08:00
sunxyw
aa8fdf557e add load order to config 2022-08-22 16:12:48 +08:00
sunxyw
4896cf0ad3 simply refactor ZMConfig 2022-08-22 16:12:47 +08:00
crazywhalecc
2e61e2a366 increment build number (build 616) 2022-08-22 07:46:48 +00:00
Jerry Ma
172a7444c9 Merge pull request #151 from zhamao-robot/windows-support
修复对 Windows 环境开发的支持
2022-08-22 15:45:57 +08:00
crazywhalecc
3ea5b16487 increment build number (build 615) 2022-08-22 07:39:45 +00:00
crazywhalecc
e83a169fd6 update api docs 2022-08-22 07:39:44 +00:00
Jerry Ma
53c1c0103c Merge pull request #149 from zhamao-robot/feature/class-alias
添加类别名
2022-08-22 15:38:49 +08:00
crazywhalecc
e467402a15 fix typo 2022-08-22 15:32:29 +08:00
crazywhalecc
d5fc16dccb change arg pass 2022-08-22 15:23:41 +08:00
crazywhalecc
3be84edb5a remove swoole pdo proxy 2022-08-22 13:37:48 +08:00
crazywhalecc
fe3bb22311 add windows development support 2022-08-22 13:35:07 +08:00
sunxyw
86c2cf96a9 fix gendoc incompatibility (#150) 2022-08-22 13:06:48 +08:00
crazywhalecc
67ba8340cc cs fix 2022-08-21 20:17:05 +08:00
crazywhalecc
ac69640253 add alias 2022-08-21 20:15:55 +08:00
crazywhalecc
64965bcc93 increment build number (build 614) 2022-08-21 08:42:32 +00:00
Jerry Ma
2eb73f3746 Merge pull request #148 from zhamao-robot/feature/mysql
完善 MySQL 连接池和组件
2022-08-21 16:41:22 +08:00
crazywhalecc
8f761c31e3 reset PHPDoc 2022-08-21 16:25:05 +08:00
crazywhalecc
528b61862a remove deprecated php version for integration-test 2022-08-21 16:20:21 +08:00
crazywhalecc
c7003a7139 add mysql support 2022-08-21 16:08:20 +08:00
crazywhalecc
75e65b082e fix middleware closure reference not working 2022-08-21 16:07:01 +08:00
crazywhalecc
22d38b783d update function name, add --print-process-pid option 2022-08-21 16:05:58 +08:00
crazywhalecc
ebdada57a6 add bot crafting command 2022-08-21 16:04:20 +08:00
crazywhalecc
28f8850013 increment build number (build 613) 2022-08-20 11:00:45 +00:00
Jerry Ma
540977c637 Merge pull request #147 from zhamao-robot/refactor/phpunit-test-rebuild
Refactor/phpunit test rebuild
2022-08-20 18:59:50 +08:00
crazywhalecc
4ba74e9f3e refactor phpunit-swoole to phpunit-zm and move old test cases 2022-08-20 17:49:33 +08:00
crazywhalecc
cecdb1681c increment build number (build 612) 2022-08-15 07:07:37 +00:00
crazywhalecc
2947da2a00 update api docs 2022-08-15 07:07:36 +00:00
crazywhalecc
da6000b4da fix container and coroutine 2022-08-15 15:06:45 +08:00
crazywhalecc
8be7207c3c increment build number (build 611) 2022-08-14 10:16:55 +00:00
crazywhalecc
0a806a74b1 update api docs 2022-08-14 10:16:53 +00:00
crazywhalecc
d56f9d6e6e fix param for annotation handler 2022-08-14 18:15:45 +08:00
crazywhalecc
dc742763a8 add pipeline feature for middleware 2022-08-14 18:15:45 +08:00
crazywhalecc
0b9b87ba23 upgrade cs-check php version 2022-08-14 18:15:45 +08:00
crazywhalecc
346be22ea9 change comment 2022-08-14 18:15:45 +08:00
crazywhalecc
b2c95d96b1 refactor all base things 2022-08-14 18:15:45 +08:00
crazywhalecc
1c801bb205 remove mkdocs config 2022-08-14 18:15:45 +08:00
crazywhalecc
163d240a9c change LICENSE copyright 2022-08-14 18:15:45 +08:00
crazywhalecc
19fc3a6d40 add PhpStorm meta config 2022-08-14 18:15:45 +08:00
crazywhalecc
4c9bc002f4 update composer.json 2022-08-14 18:15:45 +08:00
crazywhalecc
b3a5d50ba8 rename bin/start to bin/zhamao 2022-08-14 18:15:45 +08:00
crazywhalecc
f7919129b6 patch 2.x new features on 3.0 2022-08-14 18:15:45 +08:00
crazywhalecc
dccb1d91e2 update docs 2022-08-14 18:15:45 +08:00
crazywhalecc
41b058aeaf update to 3.0.0-alpha2 (build 610): refactor driver 2022-08-14 18:15:45 +08:00
sunxyw
f2a12634a4 increment build number (build 609) 2022-07-09 11:51:35 +00:00
sunxyw
8d33f45388 update api docs 2022-07-09 11:51:33 +00:00
sunxyw
cb7e230214 Merge pull request #135 from zhamao-robot/replace-console-with-logger
替换 zhamao/console 为 zhamao/logger
2022-07-09 19:50:18 +08:00
sunxyw
badd05a014 skip unfit tests for now 2022-06-09 00:25:17 +08:00
sunxyw
47ffe9a2ec temporarily fix logger infinite loop 2022-06-09 00:20:58 +08:00
sunxyw
4fe74eb5fe replace console with logger 2022-06-08 23:14:25 +08:00
sunxyw
1c40896dc0 increment build number (build 608) 2022-05-31 08:34:45 +00:00
sunxyw
872b4ce1c6 update api docs 2022-05-31 08:34:43 +00:00
sunxyw
c0fed1a391 Merge pull request #133 from zhamao-robot/fix-adapter-overflow
修复 OneBot11Adapter 无限回调溢出及其他小补丁
2022-05-31 16:33:40 +08:00
sunxyw
d1f584e490 fix phpstan false positive in ModuleUnpacker 2022-05-31 00:58:44 +08:00
sunxyw
79f5011d58 fix adapter overflow 2022-05-31 00:52:15 +08:00
sunxyw
e350edd41f fix container example command not working 2022-05-31 00:51:53 +08:00
sunxyw
23a6e56478 fix logger constructor 2022-05-31 00:51:26 +08:00
sunxyw
80050f11f2 increment build number (build 607) 2022-05-28 09:33:44 +00:00
sunxyw
25c46cc978 update api docs 2022-05-28 09:33:43 +00:00
sunxyw
458c42ae7c optimize container services register (#129)
* optimize container services register

* fix ConnectionObject not exists

* fix phpdoc
2022-05-28 17:33:01 +08:00
sunxyw
febeeadc7b increment build number (build 606) 2022-05-24 06:37:35 +00:00
sunxyw
044643559d Merge pull request #131 from zhamao-robot/refactor-framework-entry
轻量重构 Framework 类
2022-05-24 14:36:35 +08:00
sunxyw
782e668abf improve remote terminal logging 2022-05-23 11:54:07 +08:00
sunxyw
fa6af88566 fix dynamic logger call 2022-05-23 11:52:02 +08:00
sunxyw
c106c4fc2a cleanup framework class logging 2022-05-23 11:52:01 +08:00
sunxyw
09780f64de refactor framework class logging 2022-05-23 11:52:01 +08:00
sunxyw
81d4558b2f add master support for logger 2022-05-23 11:52:01 +08:00
sunxyw
3de0e37fd5 increment build number (build 605) 2022-05-23 01:52:21 +00:00
sunxyw
fcfd2f8ba5 update api docs 2022-05-23 01:52:19 +00:00
sunxyw
7e7e461237 remove deprecated global functions (#130) 2022-05-23 09:51:26 +08:00
sunxyw
2afab030bd increment build number (build 604) 2022-05-16 15:28:58 +00:00
sunxyw
5cbeee6e86 add logging config (#127) 2022-05-16 23:28:02 +08:00
sunxyw
87bbffefc3 increment build number (build 603) 2022-05-15 17:53:12 +00:00
sunxyw
a2877cab70 Merge pull request #126 from zhamao-robot/add-phpstan-extensions
添加 PHPStan 相关扩展
2022-05-16 01:52:30 +08:00
sunxyw
4f10b6dbc3 fix use of deprecated methods 2022-05-15 16:40:12 +08:00
sunxyw
24a213a8ff drop use of deprecated DBAL iterator 2022-05-15 16:39:26 +08:00
sunxyw
cf21044cf7 add phpunit extensions 2022-05-15 16:38:37 +08:00
crazywhalecc
289a5d7051 increment build number (build 602) 2022-05-14 17:17:29 +00:00
crazywhalecc
b5ae76d298 update api docs 2022-05-14 17:17:27 +00:00
Jerry Ma
598cf60e10 Merge pull request #125 from zhamao-robot/v3-refactor-command
框架V3部分重构
2022-05-15 01:16:39 +08:00
crazywhalecc
c4ca2103e4 fix phpunit-swoole class name 2022-05-15 00:16:01 +08:00
crazywhalecc
4b55a3e525 add $ZM_CUSTOM_PHP_PATH env support 2022-05-14 23:52:37 +08:00
crazywhalecc
376b81f841 change another table printer 2022-05-14 23:51:47 +08:00
crazywhalecc
ee6035c59a add openswoole support 2022-05-14 23:51:17 +08:00
crazywhalecc
a757330788 move process state related function to ProcessManager 2022-05-14 23:43:15 +08:00
crazywhalecc
bf141202f8 change worker start message 2022-05-14 23:42:15 +08:00
crazywhalecc
1be3127177 use zhamao/logger table printer instead 2022-05-14 23:41:24 +08:00
crazywhalecc
c74a43cd74 remove and refactor daemon/server command, add useful messages 2022-05-14 23:40:22 +08:00
crazywhalecc
1b520d3c96 add zhamao/logger dependency 2022-05-14 23:20:58 +08:00
sunxyw
b7418a2a3a fix increment build number wrong branch 2022-05-10 17:55:06 +08:00
Jerry Ma
eee67cdb53 Merge pull request #124 from zhamao-robot/refactor-zmconfig
重构 ZMConfig
2022-05-10 17:04:20 +08:00
crazywhalecc
1d70bc4ed7 change risky test 2022-05-10 16:03:37 +08:00
crazywhalecc
d06b0dd6d6 change include_once to require 2022-05-10 14:53:23 +08:00
crazywhalecc
cbbac0554e fix Console debug for ZMConfig get 2022-05-10 01:04:18 +08:00
crazywhalecc
5f16766997 update errcode docs 2022-05-10 00:32:42 +08:00
crazywhalecc
dcd6cae0f6 add global function is_assoc_array 2022-05-10 00:32:20 +08:00
crazywhalecc
cc43993d5b MessageUtilTest use smaller image to boost 2022-05-10 00:31:40 +08:00
crazywhalecc
2478ffe331 fix WorkerStop read global config bug 2022-05-10 00:31:03 +08:00
crazywhalecc
18ae960f86 refactor ZMConfig 2022-05-10 00:30:33 +08:00
sunxyw
fcb226e357 increment build number (build 601) 2022-05-09 16:53:51 +08:00
sunxyw
58c04b7a7b fix incorrect build branch 2022-05-09 16:42:34 +08:00
sunxyw
a6401fa9ef add adapter feature (#121) 2022-05-09 16:39:09 +08:00
sunxyw
2481124ada update workflows for future develop (#123)
* update workflows for future develop

* fix updated build id path
2022-05-09 16:36:32 +08:00
crazywhalecc
488fde47e5 create 3.x main branch and move VERSION constants 2022-05-08 21:15:16 +08:00
crazywhalecc
e7e77c99d0 update update docs 2022-05-07 17:54:16 +08:00
Github Build Bot
6fbd35ed33 increment build number (build 473) 2022-05-06 16:11:08 +00:00
Jerry Ma
fba2339280 Merge pull request #122 from zhamao-robot/command-enhancement
安装命令、操作命令强化
2022-05-07 00:10:26 +08:00
crazywhalecc
bd8270a4ae add script file auto-deploy action 2022-05-06 23:58:30 +08:00
crazywhalecc
5299061c87 change one-step installation method 2022-05-06 23:49:38 +08:00
crazywhalecc
e843aeac55 prevent server:stop command error when daemon file not exists 2022-05-06 23:36:29 +08:00
crazywhalecc
19c792209b add go.sh one-step installing script 2022-05-06 23:35:24 +08:00
crazywhalecc
277d442634 move all scripts to ext/ dir 2022-05-06 23:34:33 +08:00
Github Build Bot
51bec043e3 increment build number (build 472) 2022-05-06 13:09:23 +00:00
Github Build Bot
b7595f6f22 update api docs 2022-05-06 13:09:22 +00:00
sunxyw
55181d583f Merge pull request #120 from zhamao-robot/fix-container-object-inherit
修复容器静态属性及对象继承
2022-05-06 21:08:36 +08:00
sunxyw
b5a5a4f32e add container independence tests 2022-05-06 20:11:47 +08:00
sunxyw
a746779efa fix container object inherit 2022-05-06 19:55:45 +08:00
sunxyw
736b6ea0a5 add light cache tests (#119) 2022-05-05 22:32:51 +08:00
sunxyw
884f07baa6 add reflection util tests (#116) 2022-05-05 22:32:33 +08:00
sunxyw
b496c3136e add macroable test (#115) 2022-05-05 14:37:26 +08:00
Github Build Bot
bbfb40f973 increment build number (build 471) 2022-05-05 01:05:51 +00:00
Github Build Bot
a73e1fc164 update api docs 2022-05-05 01:05:50 +00:00
Jerry Ma
ef7acb7fa0 2.8 补充特性更新 #114 2022-05-05 09:05:05 +08:00
crazywhalecc
fcd108adbe cs-fix code 2022-05-04 23:28:21 +08:00
crazywhalecc
c9c76bfd10 refactor CQ 2022-05-04 23:24:55 +08:00
crazywhalecc
d9302a3120 remove redundant Console setlevel 2022-05-04 22:44:21 +08:00
crazywhalecc
0cb3308dd1 fix compatibility for PHP 8.1 2022-05-04 22:43:23 +08:00
crazywhalecc
583b9d7cf7 reset Console level in test 2022-05-04 22:30:56 +08:00
crazywhalecc
d7728ebc25 change test and PHPDoc 2022-05-04 22:25:42 +08:00
crazywhalecc
b6742526aa add Terminal related test 2022-05-04 21:31:38 +08:00
crazywhalecc
4defd8ac1b fix non-input environment bug #95 2022-05-04 21:31:10 +08:00
crazywhalecc
d28672e2ad add --audit-mode option 2022-05-04 21:14:56 +08:00
crazywhalecc
94d6a51358 fix EventMapIterator bug and add tests 2022-05-04 21:05:10 +08:00
crazywhalecc
54eabc948f fix instant mode related files 2022-05-04 21:03:59 +08:00
crazywhalecc
6c9e26ce83 fix bug #113 2022-05-04 17:53:49 +08:00
crazywhalecc
a934037179 prevent user from executing phar stub file directly 2022-05-04 17:43:15 +08:00
crazywhalecc
396444a089 add Windows and macOS installation tips 2022-05-04 17:42:07 +08:00
Github Build Bot
699444abdd increment build number (build 470) 2022-05-04 09:05:14 +00:00
Github Build Bot
088031f807 update api docs 2022-05-04 09:05:13 +00:00
sunxyw
8ce6e2c111 Merge pull request #110 from zhamao-robot/refactor-command-help-generator
重构 CommandHelpGenerator 至 CommandInfoUtil
2022-05-04 17:04:21 +08:00
sunxyw
e7f36b9fcf add CommandInfoUtil tests 2022-05-03 16:57:57 +08:00
sunxyw
dab91f526e fix command help format 2022-05-03 16:56:04 +08:00
sunxyw
35e23a7cbc simplify command help example 2022-05-03 16:13:13 +08:00
sunxyw
7df05df48f fix generate command list events not exists 2022-05-03 16:11:15 +08:00
sunxyw
707a1ae628 fix attribute php74 compatibility 2022-05-03 13:18:09 +08:00
sunxyw
a65fc4076b update MessageUtilTest 2022-05-03 13:09:58 +08:00
sunxyw
f487897cf2 add arguments list to command info util 2022-05-03 13:06:58 +08:00
sunxyw
869d9ed543 fix message util test 2022-05-03 13:06:58 +08:00
sunxyw
8f61ed7561 add jetbrains/phpstorm-attributes package 2022-05-03 13:06:57 +08:00
sunxyw
8cb6a32341 refactor CommandHelpGenerator to CommandInfoUtil 2022-05-03 13:06:55 +08:00
Github Build Bot
687260e53c increment build number (build 469) 2022-05-03 02:07:42 +00:00
Github Build Bot
a919ce4554 update api docs 2022-05-03 02:07:42 +00:00
Jerry Ma
d19d7acedd add @CommandArgument annotation
* add @CommandArgument and relevant event changes

* fix unknown bug

* remove relative constant for CommandArgument
2022-05-03 10:06:57 +08:00
sunxyw
a393b3aff5 fix phpunit printer (#112) 2022-05-02 17:02:39 +08:00
Github Build Bot
8c2036b6b4 increment build number (build 468) 2022-04-30 13:13:23 +00:00
Jerry Ma
dc081861ad Merge pull request #107 from zhamao-robot/optimize-phpunit
PHPUnit 及部分结构优化
2022-04-30 21:12:42 +08:00
crazywhalecc
ec76d2ba7d change @sunxyw email 2022-04-30 20:43:19 +08:00
Jerry Ma
47ce0a8e9c fix action runner stty issue for phpunit (#109) 2022-04-30 20:34:32 +08:00
Jerry Ma
f1c730962b Fix ZM_TEST_LOG_DEBUG bug, remove redundant code 2022-04-30 17:24:26 +08:00
crazywhalecc
d95a5131f6 remove ctx function throw exception 2022-04-30 13:38:15 +08:00
crazywhalecc
69637cf482 update composer.json, docs and tests 2022-04-30 13:36:40 +08:00
crazywhalecc
25d6ec3a92 private-mode output nothing 2022-04-30 13:35:45 +08:00
crazywhalecc
8bf5ff4e7f fix swoole exit error dumped 2022-04-30 13:34:48 +08:00
crazywhalecc
fd4e4be3a8 try to remove irrelevant information for phpunit 2022-04-30 13:33:38 +08:00
crazywhalecc
e0a01ea2ca simplify home command 2022-04-29 18:39:07 +08:00
sunxyw
256ccb96a6 increment build number (build 467) 2022-04-29 15:42:33 +08:00
sunxyw
bfffdc7d21 fix api docs generate breaks 2022-04-29 15:42:33 +08:00
sunxyw
3bbe21268b add auto response serialize for http request (#104)
* add auto response serialize for http request

* fix possible duplicate response end
2022-04-29 15:36:48 +08:00
sunxyw
1537e88a74 increment build number (build 466) 2022-04-29 12:36:23 +08:00
sunxyw
0d9711e62d fix build number cannot increment when api docs not modified 2022-04-29 12:35:02 +08:00
sunxyw
0a7c5f06c6 refactor RouteManager static file routing (#105) 2022-04-29 12:23:06 +08:00
sunxyw
e7a8a32b73 support container call with unnamed parameters (#103) 2022-04-29 12:22:34 +08:00
Github Build Bot
62b703f2e4 increment build number (build 464) 2022-04-28 13:51:33 +00:00
Github Build Bot
f44921d136 update api docs 2022-04-28 13:51:31 +00:00
sunxyw
cd42545c7d refactor match_pattern implementation (#102)
* refactor match_pattern implementation

* add match_pattern escaped wildcards support

* add match_pattern global function test
2022-04-28 21:50:48 +08:00
Github Build Bot
0df3fd7bed increment build number (build 463) 2022-04-15 16:00:58 +00:00
Github Build Bot
56241da281 update api docs 2022-04-15 16:00:57 +00:00
sunxyw
05a04104dd bump version to 2.8.0 (#100) 2022-04-15 23:59:59 +08:00
sunxyw
50d27ee186 add show-debug option to api docs generator 2022-04-15 23:43:21 +08:00
sunxyw
371926b5a6 improve api docs generator class discrimination 2022-04-15 23:37:54 +08:00
sunxyw
97face2406 add chain and stopwatch helper functions (#99)
* add chain helper function

* add stopwatch helper function
2022-04-15 23:10:29 +08:00
Github Build Bot
ea64b40011 increment build number (build 462) 2022-04-15 15:08:35 +00:00
Github Build Bot
6d23e489aa update api docs 2022-04-15 15:08:34 +00:00
sunxyw
f4d75e211f Merge pull request #97 from zhamao-robot/add-di
增加 IoC 容器 & 依赖注入支持
2022-04-15 23:07:52 +08:00
sunxyw
48f6cc644d abstract reflection utils 2022-04-12 17:52:51 +08:00
sunxyw
33f517333f fix unhandled exception 2022-04-12 17:13:17 +08:00
sunxyw
7253a309c7 refactor container injection 2022-04-11 23:42:00 +08:00
sunxyw
f2aff5882d use accurate property name 2022-04-11 23:39:42 +08:00
sunxyw
0dd61a7270 add di support for event handlers 2022-04-11 23:39:41 +08:00
sunxyw
420b8e6d67 add container debug log 2022-04-11 23:39:11 +08:00
sunxyw
9e08919ce0 fix read config before loaded 2022-04-11 23:39:11 +08:00
sunxyw
a7324f6c49 fix module config dir not exists 2022-04-11 23:39:10 +08:00
sunxyw
721c0834db inject container into framework 2022-04-11 23:39:10 +08:00
sunxyw
e37629aaea add container call test 2022-04-11 23:39:10 +08:00
sunxyw
a43a4a429e add reflection util 2022-04-11 23:39:09 +08:00
sunxyw
f5d34198e7 add container call method 2022-04-11 23:39:09 +08:00
sunxyw
46604293e9 remove unnecessary exceptions hint 2022-04-11 23:39:08 +08:00
sunxyw
58e405cccd Revert "add basic container usage example"
This reverts commit 86e379c6bd8eb829a947bce463ff68c9de2d4200.
2022-04-11 23:39:06 +08:00
sunxyw
1deea5bebc refactor container type hint 2022-04-11 23:38:29 +08:00
sunxyw
cad5636f92 add basic container usage example 2022-04-11 23:38:28 +08:00
sunxyw
90290bee94 add container generics type hint 2022-04-11 23:37:21 +08:00
sunxyw
9f7ebceeb9 add phpdoc to ZMBuf 2022-04-11 23:37:21 +08:00
sunxyw
60ea2c7e12 add container helper functions 2022-04-11 23:37:16 +08:00
sunxyw
441c866160 improve SingletonTrait compatibility 2022-04-11 23:35:36 +08:00
sunxyw
33d3341bb3 add request container 2022-04-11 23:35:36 +08:00
sunxyw
1d778fd78e add worker container 2022-04-11 23:35:36 +08:00
Github Build Bot
0cd73a6304 increment build number (build 461) 2022-04-11 14:03:48 +00:00
Github Build Bot
2fedfe5b18 update api docs 2022-04-11 14:03:47 +00:00
Jerry Ma
77c140bee6 Merge pull request #96 from zhamao-robot/qol-proxy
实现 ZMRobot 内置 AllBots & AllGroups 代理类
2022-04-11 22:03:06 +08:00
sunxyw
c06e38d71f add ZMRobot proxies usage example 2022-04-04 00:33:23 +08:00
sunxyw
9b59cec22a add all groups proxy for ZMRobot 2022-04-04 00:14:27 +08:00
sunxyw
306e992789 add all bots proxy for ZMRobot 2022-04-04 00:11:58 +08:00
sunxyw
8335cfed69 add implode_when_necessary global function 2022-04-04 00:10:42 +08:00
crazywhalecc
4702aa1987 update version docs 2022-04-03 21:47:02 +08:00
sunxyw
145e1b31a0 use https asset in vuepress component (#94) 2022-04-03 21:06:09 +08:00
Github Build Bot
f2e28de20c increment build number (build 460) 2022-04-02 18:25:07 +00:00
Github Build Bot
bcaaf88edb update api docs 2022-04-02 18:25:06 +00:00
Jerry Ma
120698fb43 Merge pull request #91 from zhamao-robot/phpstan-level-4
PHPStan Level 4
2022-04-03 02:24:27 +08:00
crazywhalecc
dd88585ffa local rebase for merging into master 2022-04-03 02:17:58 +08:00
crazywhalecc
93a8c450ad Fix MySQLWrapper related PHPDoc and variables 2022-04-03 02:17:58 +08:00
crazywhalecc
3451434997 strict to phpstan-level-4 2022-04-03 02:17:58 +08:00
Github Build Bot
0bab2e74b0 increment build number (build 459) 2022-04-02 17:31:49 +00:00
Github Build Bot
c1a877489b update api docs 2022-04-02 17:31:48 +00:00
crazywhalecc
520099aaba change description for return value in TaskManager 2022-04-03 01:31:04 +08:00
crazywhalecc
9bd02b3dd2 strict SignalListener param type 2022-04-03 01:31:04 +08:00
crazywhalecc
ba64f2c189 Fix typo 2022-04-03 01:31:04 +08:00
crazywhalecc
fbb194a6c5 Fix MySQLWrapper related PHPDoc and variables 2022-04-03 01:31:04 +08:00
crazywhalecc
30b2d2134b Fix MySQLWrapper related PHPDoc and variables 2022-04-03 01:31:04 +08:00
crazywhalecc
7eea71e282 Fix MySQLWrapper variable name 2022-04-03 01:31:04 +08:00
crazywhalecc
e40b3029e0 Fix context PHPDoc return type 2022-04-03 01:31:04 +08:00
crazywhalecc
17492c78fa Fix context PHPDoc return type 2022-04-03 01:31:04 +08:00
crazywhalecc
a9276d3f72 fix argument type error 2022-04-03 01:31:04 +08:00
crazywhalecc
eecbe49955 fix code to phpstan-level-2 2022-04-03 01:31:04 +08:00
sunxyw
be9874a9ad Merge pull request #89 from zhamao-robot/update-readme
更新 README Badges 及优化工作流触发路径
2022-04-02 22:32:38 +08:00
sunxyw
b4fcc057c5 update readme badge 2022-04-02 21:19:27 +08:00
sunxyw
d9499dc56b restrict workflows trigger path 2022-04-02 21:04:51 +08:00
sunxyw
f6806c88ab update readme badges 2022-04-02 20:58:32 +08:00
Github Build Bot
2caca545ad increment build number (build 458) 2022-04-02 11:37:16 +00:00
Github Build Bot
ff0f11da7f update api docs 2022-04-02 11:37:16 +00:00
crazywhalecc
daa1822bc5 fix the rest problem code to phpstan-level-1 2022-04-02 19:36:32 +08:00
crazywhalecc
d490892092 refactor module command to phpstan-level-1 2022-04-02 19:36:32 +08:00
sunxyw
182a4e7b06 Merge pull request #87 from zhamao-robot/doc-regenerate
API 文档重新生成并加入Workflow
2022-04-02 19:15:25 +08:00
crazywhalecc
e9beed03ea update docs 2022-04-02 19:06:52 +08:00
Jerry Ma
8351527aea add build id to auto-increment commit message 2022-04-02 18:45:17 +08:00
crazywhalecc
ddff663b0b update docs 2022-04-02 18:01:17 +08:00
sunxyw
31b4fb9201 fix api docs generate no dependencies 2022-04-02 17:37:00 +08:00
sunxyw
1f7f0da383 add generate api docs step to build workflow 2022-04-02 17:37:00 +08:00
crazywhalecc
9fa1079248 Re-generate API docs 2022-04-02 17:36:59 +08:00
Github Build Bot
ae0cf5e3d7 increment build number 2022-04-02 09:28:10 +00:00
Jerry Ma
672369c598 Merge pull request #86 from zhamao-robot/phpstan-level-2
PHPStan 升级到 level 2
2022-04-02 17:27:57 +08:00
Jerry Ma
73687f248b Merge branch 'master' into phpstan-level-2 2022-04-02 17:22:38 +08:00
crazywhalecc
65cc2a948a Update hooks 2022-04-02 17:07:24 +08:00
crazywhalecc
299f36dcc0 test --enable-openssl option for skipped 2022-04-02 02:45:24 +08:00
crazywhalecc
f5cbce5195 test --enable-openssl option 2022-04-02 02:18:31 +08:00
crazywhalecc
a3780667b2 change https to http 2022-04-02 02:13:08 +08:00
crazywhalecc
a21742a326 Enhancement for integration-test.yml
let commandline cs-fixer follow the configuration
2022-04-02 02:03:46 +08:00
sunxyw
40aacb2e61 refactor git hooks config 2022-04-01 19:32:55 +08:00
crazywhalecc
ba18869c85 fix cs 2022-04-01 19:25:25 +08:00
crazywhalecc
a454f2c523 change test to provider mode 2022-04-01 19:20:10 +08:00
crazywhalecc
7caebaa6ba Add CQ PHPUnit test 2022-03-31 02:25:03 +08:00
crazywhalecc
580abd7317 Fix partial code to level 2 2022-03-31 02:24:38 +08:00
crazywhalecc
3187431611 PHPStan: ignore Constant error bugs 2022-03-31 02:22:30 +08:00
crazywhalecc
81c37c9a0a Let command level follow phpstan.neon 2022-03-31 02:21:48 +08:00
Github Build Bot
ba5bca20da increment build number 2022-03-30 09:50:06 +00:00
sunxyw
533fe187bd fix cs 2022-03-30 17:49:53 +08:00
sunxyw
c4da26c19d remove the nasty catch 2022-03-30 17:49:53 +08:00
sunxyw
ca7bfcc8c6 fix php7.2 compatibility 2022-03-30 17:49:53 +08:00
sunxyw
6c7b582faf add http util test 2022-03-30 17:49:53 +08:00
sunxyw
6f2e6135f1 add singleton trait test 2022-03-30 17:49:53 +08:00
sunxyw
37a92e03c1 refactor generate command help test 2022-03-30 17:49:53 +08:00
sunxyw
35385f8916 adjust cs-fixer config 2022-03-30 17:49:53 +08:00
crazywhalecc
a2fbdd8e0a Enhancement for phpunit-swoole 2022-03-30 17:49:53 +08:00
crazywhalecc
bab610722f Add error exit code 2022-03-30 17:49:53 +08:00
crazywhalecc
4cabc8d132 Remove block line from script_setup_loader.php 2022-03-30 17:49:53 +08:00
crazywhalecc
e8bd381907 Add private-mode option for server command 2022-03-30 17:49:53 +08:00
crazywhalecc
42aac802dd Fix exclude-annotation-path not working bug 2022-03-30 17:49:53 +08:00
crazywhalecc
d748a20445 Update the test instance 2022-03-30 17:49:53 +08:00
crazywhalecc
5db3ff934d Fix pre-loaded events overwritten bug 2022-03-30 17:49:53 +08:00
crazywhalecc
9bfa3ede20 Fix isRelativePath() bug 2022-03-30 17:49:53 +08:00
crazywhalecc
127466e546 Fix DataProvider warning bug 2022-03-30 17:49:53 +08:00
crazywhalecc
16aa30cac7 Add tests to Annotation exclusion 2022-03-30 17:49:53 +08:00
sunxyw
05a3d0111b make phpunit run inside framework 2022-03-30 17:49:53 +08:00
sunxyw
9f4b5fb14a add data provider test 2022-03-30 17:49:53 +08:00
sunxyw
a716e68f87 add message util test 2022-03-30 17:49:53 +08:00
sunxyw
2e127771ed add test coverage config 2022-03-30 17:49:53 +08:00
sunxyw
c6bbba6051 remove old tests 2022-03-30 17:49:53 +08:00
Jerry Ma
443ed115b0 Merge pull request #83 from zhamao-robot/add-phpunit-framework
添加 PHPUnit 单元测试框架
2022-03-28 20:28:39 +08:00
sunxyw
f450b8d863 change phpunit default timezone to Asia/Shanghai 2022-03-28 18:19:48 +08:00
sunxyw
acf570e652 add .editorconfig to unify coding style 2022-03-28 18:18:59 +08:00
sunxyw
4e9199c68e refactor phpunit-swoole 2022-03-28 17:27:36 +08:00
sunxyw
6f5575b155 adjust phpunit config 2022-03-28 16:45:32 +08:00
sunxyw
700b854434 rename test folder 2022-03-28 16:42:13 +08:00
sunxyw
37b5d954e9 add phpunit config 2022-03-28 16:34:26 +08:00
sunxyw
ac50e96568 update .gitignore 2022-03-28 16:33:48 +08:00
sunxyw
86174c2e9f normalize composer 2022-03-28 16:09:16 +08:00
Jerry Ma
c1ae1dee06 Merge pull request #81 from zhamao-robot/add-auto-api-docs-generator
添加 API 文档生成器
2022-03-27 21:52:15 +08:00
Jerry Ma
c4aedf2958 Add gendoc to composer 2022-03-27 21:51:38 +08:00
Github Build Bot
736c8f2fc0 increment build number 2022-03-27 13:44:26 +00:00
Jerry Ma
294084299e Merge pull request #82 from zhamao-robot/bugfix/not-response
再次修复无法处理消息的 Bug
2022-03-27 21:44:10 +08:00
crazywhalecc
b1d30da4bc Re-fix the last no-message-response bug 2022-03-27 21:34:49 +08:00
sunxyw
506f2e7c0c add api docs generator 2022-03-27 19:19:05 +08:00
sunxyw
e13660dcdc add nav for api docs 2022-03-27 16:51:28 +08:00
sunxyw
4fbe2aa5af add api docs (#80) 2022-03-27 16:42:36 +08:00
crazywhalecc
5ddc514545 update docs 2022-03-27 01:27:50 +08:00
sunxyw
3cfcbaec16 fix mb_strpos empty delimiter 2022-03-27 01:16:44 +08:00
sunxyw
50f06e6a4f add middleware params docs (#78) 2022-03-26 22:46:24 +08:00
Github Build Bot
c7e2b15629 increment build number 2022-03-26 07:44:43 +00:00
Jerry Ma
8e81f72584 Merge pull request #76 from zhamao-robot/feature/cron
新增 Cron 注解及修复部分 Bug
2022-03-26 15:44:29 +08:00
crazywhalecc
0fb5ed00f6 update docs 2022-03-26 14:59:13 +08:00
crazywhalecc
bf7920cc15 Add Cron annotation event 2022-03-26 14:51:57 +08:00
crazywhalecc
971f03ae0f Fix type convert error 2022-03-26 14:51:25 +08:00
Jerry Ma
24b9d93920 Merge pull request #75 from zhamao-robot/add-auto-build-number-workflow
添加构建工作流以自增构建编号
2022-03-26 01:49:43 +08:00
sunxyw
8d81f4d5df add build workflow to increment build number 2022-03-25 23:40:41 +08:00
Jerry Ma
b6e135a642 Merge pull request #74 from zhamao-robot/fix-onsetup-attribute-exec
Fix OnSetup Attribute execution bug (release 2.7.3)
2022-03-25 19:21:07 +08:00
crazywhalecc
d3f4ade215 Add Attribute and property (build 453, release 2.7.3) 2022-03-25 19:15:58 +08:00
crazywhalecc
56d2a52706 Fix OnSetup Attribute execution bug (build 452, release 2.7.3) 2022-03-25 19:02:43 +08:00
Jerry Ma
b40dc1e05e Merge pull request #71 from zhamao-robot/add-help-generator-docs
增加命令帮助生成器文档
2022-03-24 16:54:50 +08:00
Jerry Ma
bed3337866 Merge pull request #73 from zhamao-robot/integration-test-ignore-docs
修改集成测试配置以忽略文档变更
2022-03-24 16:40:48 +08:00
sunxyw
28dc73d060 Update integration-test.yml 2022-03-24 15:36:36 +08:00
sunxyw
5ea1226ad0 add help generator docs 2022-03-23 20:03:47 +08:00
sunxyw
e43f2a4158 update readme about php8 attribute (#70)
* update readme

* add docs about php8 attribute
2022-03-23 19:45:07 +08:00
sunxyw
d73e771ef3 fix help generator not working with alias (#69) 2022-03-23 19:44:16 +08:00
crazywhalecc
c077e9418c revert changes 2022-03-22 12:01:21 +08:00
crazywhalecc
2ce888c84c add robots.txt 2022-03-22 12:00:37 +08:00
crazywhalecc
b4d175ff98 fix docs problem 2022-03-22 11:52:12 +08:00
crazywhalecc
35e18d0481 add some irrelevant docs to expand white border 2022-03-22 01:26:53 +08:00
Jerry Ma
f6cccb00e3 Merge pull request #68 from zhamao-robot/document-upgrade
将文档重新部署和重构为 VuePress
2022-03-22 01:00:43 +08:00
Jerry Ma
2a82c82039 update to build 451
重构全局函数,统一函数命名,并补全注释
2022-03-22 01:00:20 +08:00
Jerry Ma
a2e8a1b582 update to build 451 2022-03-22 00:55:34 +08:00
crazywhalecc
dbd78d4b86 change ALL docs from MkDocs to VuePress!! 2022-03-22 00:51:03 +08:00
sunxyw
8105892b6e fix review 2022-03-21 23:28:57 +08:00
sunxyw
bc7d5871e4 replace deprecated functions 2022-03-21 20:49:09 +08:00
sunxyw
680e6a8c5f refactor global functions 2022-03-21 20:09:28 +08:00
Jerry Ma
c364084cb2 add command help generator (build 450)
增加命令帮助生成器 by @sunxyw
2022-03-21 14:13:56 +08:00
Jerry Ma
63f8042746 update to build 450 2022-03-21 12:52:48 +08:00
Jerry Ma
48e6b2cea0 update README.md [skip ci] 2022-03-21 05:04:37 +08:00
sunxyw
228309c571 fix cs 2022-03-21 04:46:54 +08:00
sunxyw
ca3a3df3ba add command help generator 2022-03-21 04:43:27 +08:00
crazywhalecc
c7df37b17c update install-runtime.sh 2022-03-21 02:58:59 +08:00
crazywhalecc
41f03fbba4 update docs 2022-03-21 01:25:26 +08:00
crazywhalecc
b3089c1bba add composer module support (build 449, 2.7.2) 2022-03-21 01:24:07 +08:00
crazywhalecc
c5a6f1fea4 update docs 2022-03-20 23:28:20 +08:00
crazywhalecc
ba2777137b let build command faster (build 448, 2.7.1) 2022-03-20 23:26:42 +08:00
crazywhalecc
6d90be164a update docs 2022-03-20 22:16:34 +08:00
crazywhalecc
4da6f5859a update to 2.7.0 release (build 447) 2022-03-20 22:12:58 +08:00
crazywhalecc
15d4ea710a add --no-state-check option (build 446) 2022-03-20 21:04:07 +08:00
crazywhalecc
f0541c1f32 Merge remote-tracking branch 'origin/master' 2022-03-20 19:05:54 +08:00
crazywhalecc
2b8cab1824 add AnnotationReader ignore name config (build 445, 2.7.0-beta5) 2022-03-20 19:05:13 +08:00
Jerry Ma
61c7972915 Update README.md 2022-03-20 17:09:24 +08:00
crazywhalecc
44a0eec74c change to integration-test 2022-03-20 17:00:37 +08:00
crazywhalecc
e57753e44b change to integration-test 2022-03-20 16:58:53 +08:00
crazywhalecc
74e91a2950 fix unpack autoload not working, change exclude_annotate to another name (build 444) 2022-03-20 16:51:48 +08:00
crazywhalecc
7ce3ef41df fix comment spacing problem (build 443) 2022-03-20 16:23:07 +08:00
crazywhalecc
444a77933a change autoload to hotload for phar hotload mode (build 442) 2022-03-20 16:20:14 +08:00
crazywhalecc
78f78c607d add packer namespace adjust (build 441) 2022-03-20 16:18:33 +08:00
crazywhalecc
69155002dc add site to gitignore 2022-03-20 16:13:51 +08:00
crazywhalecc
475d14fab7 update composer.json 2022-03-20 16:13:33 +08:00
crazywhalecc
f4d7e63358 update php cs fixer 2022-03-20 15:48:14 +08:00
crazywhalecc
f222d2b45b update composer requirement version 2022-03-20 15:43:31 +08:00
Jerry Ma
d0155fe1da Create code-style-analysis.yml 2022-03-20 15:35:10 +08:00
Jerry Ma
4737d0b507 Update and rename main.yml to mkdocs-deploy.yml 2022-03-20 15:23:05 +08:00
Jerry Ma
09bd0197bb Merge pull request #64 from sunxyw/patch-1
docs: add weather bot example
2022-03-20 15:20:59 +08:00
crazywhalecc
f0f120bd32 add Macroable (build 440) 2022-03-20 01:54:14 +08:00
crazywhalecc
c897da29c6 add PHP8 Attribute compatibility (build 439, 2.7.0-beta4) 2022-03-20 01:53:36 +08:00
sunxyw
e347e254e8 update docs index 2022-03-20 00:11:45 +08:00
crazywhalecc
12363aebf0 Merge remote-tracking branch 'origin/master' 2022-03-19 23:23:54 +08:00
crazywhalecc
ff0b925313 update docs 2022-03-19 23:23:14 +08:00
sunxyw
a6b4bd9b80 update weather bot example 2022-03-19 21:35:48 +08:00
sunxyw
485fa5476c add weather bot example 2022-03-19 21:25:10 +08:00
Jerry Ma
689076d97c Update mkdocs.yml 2022-03-19 20:33:13 +08:00
Jerry Ma
cca6102e91 Update README.md 2022-03-18 16:57:27 +08:00
Jerry Ma
095855162b Update mkdocs.yml 2022-03-18 16:48:30 +08:00
Jerry Ma
326f934013 Update mkdocs.yml 2022-03-18 16:44:04 +08:00
Jerry Ma
35b0c258fe Merge pull request #63 from sunxyw/patch-2
docs: add qingyunke chatbot integration example
2022-03-18 16:01:15 +08:00
sunxyw
6650846b15 update integrate-qingyunke-chatbot.md 2022-03-18 15:19:19 +08:00
sunxyw
a33d320f4c update integrate-qingyunke-chatbot.md 2022-03-18 02:54:23 +08:00
sunxyw
0bcfea6aa4 add qingyunke chatbot integration example 2022-03-18 02:30:45 +08:00
crazywhalecc
db6e63e91c fix Response class null error (build 438) 2022-03-17 20:48:09 +08:00
crazywhalecc
a7f84fb53a Merge remote-tracking branch 'origin/master' 2022-03-17 19:48:38 +08:00
crazywhalecc
ce7f2b1765 change ctx return force to ContextInterface (build 437) 2022-03-17 19:42:59 +08:00
Jerry Ma
abbfb59eff Merge pull request #62 from sunxyw/patch-2
docs: add missing module version example
2022-03-17 18:19:02 +08:00
sunxyw
b57fef16f9 add missing module version example 2022-03-17 01:53:06 +08:00
crazywhalecc
1706afbcd0 add cs fixer and PHPStan and activate it (build 436) 2022-03-15 18:05:33 +08:00
crazywhalecc
d01bd69aa5 update to 2.7.0-beta1 (build 435) 2022-03-13 22:50:32 +08:00
crazywhalecc
e6b9ae3ee1 add --watch function for no-installed-inotify users 2022-03-13 22:50:01 +08:00
crazywhalecc
73b6b8045d enhancement for process state 2022-03-13 22:47:11 +08:00
crazywhalecc
3c87abc6e8 enhancement for process state 2022-03-13 22:46:22 +08:00
crazywhalecc
e95925c129 add compatibility for PHP 8.1 2022-03-13 22:16:02 +08:00
crazywhalecc
82c44d6c40 enhancement for process state 2022-03-13 22:15:27 +08:00
crazywhalecc
e0a268e05e add autoload-dev auto scanner 2022-03-13 22:11:30 +08:00
crazywhalecc
487892e1d9 add force kill framework command --force 2022-03-13 22:05:53 +08:00
crazywhalecc
7ab4e88359 add KILLER PROMPT function 2022-03-13 22:05:23 +08:00
crazywhalecc
4702b6ee75 separate ProcessManager and WorkerManager 2022-03-13 22:04:52 +08:00
crazywhalecc
20cd3aa66d update docs 2022-03-13 22:03:52 +08:00
crazywhalecc
391114bdef update docs 2022-03-13 21:57:41 +08:00
crazywhalecc
ffe1052ecc add gitignore items 2022-03-13 21:54:43 +08:00
crazywhalecc
b4159152a7 add watcher 2022-01-08 20:19:10 +08:00
crazywhalecc
8fc6e4b0f7 update docs 2022-01-08 16:26:47 +08:00
crazywhalecc
c8938b7a4b update docs 2022-01-08 16:23:10 +08:00
crazywhalecc
34db1626a5 update to 2.6.6 (build 434) 2022-01-08 16:19:43 +08:00
crazywhalecc
7f0c97c5b9 update to 2.6.5 (build 433) 2021-12-28 22:40:40 +08:00
crazywhalecc
74050c46e7 update to 2.6.4 (build 432) 2021-12-25 19:21:41 +08:00
3ed1cb665a update to build 431 2021-12-22 14:39:46 +08:00
crazywhalecc
a6f33ba69d update to build 430 2021-12-08 21:29:38 +08:00
Jerry Ma
176b690417 Update v2.md 2021-12-07 13:28:21 +08:00
Jerry Ma
e22b1b90ec Update build-update.md 2021-12-07 13:27:33 +08:00
Jerry Ma
a3c560790c Merge pull request #55 from zhamao-robot/fix/cqafter
update to build 429
2021-12-07 13:25:55 +08:00
570e2108dd - 新增配置项 onebot.message_command_policy
- 新增 CQCommand 阻断策略的自定义配置功能
- 修复 CQAfter 无法正常使用的 bug #53
2021-12-07 13:21:29 +08:00
Jerry Ma
59c0d95e5d Create 2_Feature_request.yaml 2021-12-07 12:34:18 +08:00
Jerry Ma
9ceaecdc02 Update README.md 2021-12-07 12:17:47 +08:00
Jerry Ma
19d50898ef Create 1_Bug_report.yaml 2021-12-07 12:15:49 +08:00
Jerry Ma
5b62ca62ae Update README.md 2021-11-17 00:28:54 +08:00
fb528d30ce update docs 2021-11-16 16:51:05 +08:00
5f2d5ed334 update to build 428 2021-11-16 16:49:32 +08:00
c20e459900 update docs 2021-11-16 15:44:34 +08:00
09220825cf update to build 427 2021-11-16 15:41:01 +08:00
Jerry Ma
3d4db23d27 Update v2.md 2021-11-10 14:10:08 +08:00
Jerry Ma
4496b67dcc Update build-update.md 2021-11-10 14:09:18 +08:00
Jerry Ma
2a13298384 update to 2.5.8 (build 426) 2021-11-10 14:07:21 +08:00
Jerry Ma
d6ec404d76 Merge pull request #52 from YuFengZe/master
Update CQ.php
2021-11-10 14:06:13 +08:00
YuFengZe
3235fd4dc1 Update CQ.php 2021-11-08 22:05:41 +08:00
crazywhalecc
293740fee2 update to 2.5.7 (build 425) 2021-11-03 23:26:43 +08:00
crazywhalecc
d3c420ec84 update to build 424 (2.6.0-alpha1) 2021-11-02 16:01:24 +08:00
crazywhalecc
85ef09d43c Merge remote-tracking branch 'origin/master' 2021-11-01 00:29:11 +08:00
Jerry Ma
e4561d69c4 Merge pull request #45 from YuFengZe/master
Bug Fixed
2021-10-31 22:50:49 +08:00
Jerry Ma
6b4d206099 Update Hello.php 2021-10-31 22:50:12 +08:00
YuFengZe
50843edf6a Bug Fixed
解决发送“我是谁”却返回机器人信息的奇怪问题。
2021-10-31 22:01:14 +08:00
crazywhalecc
3a1686f8da update docs 2021-10-18 22:24:28 +08:00
crazywhalecc
66dd91bb97 update to 2.5.6 (build 423) 2021-10-17 23:55:02 +08:00
crazywhalecc
e020e5d593 update docs 2021-10-17 17:00:33 +08:00
crazywhalecc
3d62663281 update docs 2021-10-17 16:56:52 +08:00
crazywhalecc
8d9485c02e update docs 2021-10-17 15:37:55 +08:00
Jerry Ma
9fb45dd683 Update README.md 2021-10-15 09:38:07 +08:00
Jerry Ma
8a4924dba9 Update light-cache.md 2021-10-08 11:41:40 +08:00
crazywhalecc
beaf7be606 update to version 2.5.5 (buid 422) 2021-10-06 18:01:40 +08:00
Jerry Ma
7dbd21bdf4 Merge pull request #44 from furleywolf/patch-1
更新message-util的文档
2021-09-15 12:46:48 +08:00
furleywolf
9ce3056203 更新message-util的文档
发现漏掉了一个方法,还是补上去吧
2021-09-13 17:35:39 +08:00
crazywhalecc
880b4e847c update to version 2.5.4 (buid 421) 2021-09-11 16:27:16 +08:00
crazywhalecc
71e83d5bc8 update docs 2021-09-11 12:06:22 +08:00
crazywhalecc
432fd92cca update docs 2021-09-11 12:00:48 +08:00
crazywhalecc
907a9cea25 update to build 420 2021-09-11 11:59:02 +08:00
07391810ff update to build 419 2021-09-11 11:07:23 +08:00
5063421364 update docs 2021-09-10 11:28:56 +08:00
2b4d308783 update to build 418 2021-09-10 11:24:32 +08:00
e2f49968b3 Merge remote-tracking branch 'origin/master' 2021-09-01 14:14:13 +08:00
229778ebf9 update to build 417 2021-09-01 14:14:00 +08:00
Jerry Ma
d2c0972c93 Add actions badge [skip ci] 2021-08-31 13:40:29 +08:00
Jerry Ma
d300b6e518 Update main.yml 2021-08-31 13:39:11 +08:00
Jerry Ma
56cb7b2223 Update main.yml 2021-08-30 16:42:47 +08:00
Jerry Ma
2fc42d5d60 Update README.md 2021-08-30 16:40:53 +08:00
Jerry Ma
999e90f709 Update index.md 2021-08-30 16:17:13 +08:00
Jerry Ma
45c6cd7d2a Update main.yml 2021-08-30 16:12:35 +08:00
Jerry Ma
5aa0858021 Update main.yml 2021-08-30 16:05:15 +08:00
Jerry Ma
e981da3932 Update main.yml 2021-08-30 16:00:36 +08:00
Jerry Ma
2685be7306 Create main.yml 2021-08-30 11:27:51 +08:00
Jerry Ma
a13c4628f5 Update README.md 2021-07-15 11:37:35 +08:00
Jerry Ma
b36417454c Update README.md 2021-07-10 15:55:15 +08:00
crazywhalecc
a6f5952dee update to 2.5.1 (build 416) 2021-07-09 12:59:07 +08:00
crazywhalecc
d67dfe46f6 update to 2.5.0 (build 415) 2021-07-09 10:43:00 +08:00
crazywhalecc
e57cc43500 update to 2.5.0-b4 (build 414) 2021-07-09 02:15:04 +08:00
crazywhalecc
481063285b update some Docs and comments 2021-07-09 01:54:58 +08:00
crazywhalecc
d805523dbd update to 2.5.0-b3 (build 413) 2021-07-09 01:44:45 +08:00
crazywhalecc
58267f66fc update to 2.5.0-b3 (build 412) 2021-07-09 01:43:39 +08:00
crazywhalecc
48215f2e5e update to 2.5.0-b3 (build 411) 2021-07-09 01:39:45 +08:00
crazywhalecc
7e0fc1528a update to 2.5.0-b3 (build 410) 2021-07-09 01:38:30 +08:00
crazywhalecc
c185d20a93 update Docs 2021-07-04 18:02:03 +08:00
crazywhalecc
7ec847e576 update to 2.5.0-b2 (build 409) 2021-07-04 15:45:30 +08:00
jerry
4ee16d4fc6 update to 2.5.0-b1 (build 408) 2021-06-16 00:17:30 +08:00
Whale
59d614a24e Merge pull request #40 from sunxyw/patch-1
add latest config file format to quickstart-robot guide
2021-06-15 18:20:12 +08:00
sunxyw
40037b3f4b add highlight to quickstart-robot guide 2021-06-15 17:55:21 +08:00
sunxyw
f91c8b6205 add latest config file format to quickstart-robot guide
After the v1.0.0-beta2 update of go-cqhttp, the config file format has been converted from `hjson` to `yaml`. Update the guide.
See https://github.com/Mrs4s/go-cqhttp/releases/tag/v1.0.0-beta2
2021-06-15 17:46:00 +08:00
Whale
8f73a99ff7 Merge pull request #39 from YiwanGi/patch-1
Update global.php
2021-06-10 23:39:45 +08:00
Wang
e0f07cb396 Update global.php
🙃 强迫症 √
2021-06-10 17:45:27 +08:00
Whale
2950ab7472 Update README.md 2021-05-26 16:56:55 +08:00
Whale
0ab4053dfb Update README.md 2021-05-26 16:32:37 +08:00
Whale
745aa0f268 Update README.md 2021-05-26 16:31:41 +08:00
Whale
12bb93c2f0 Update README.md 2021-05-08 20:45:49 +08:00
95ca175901 Merge remote-tracking branch 'origin/master' 2021-05-08 10:06:17 +08:00
71585ed29d update to build 407
change daemon command from system to Process::kill
add master_pid for motd information
add option --preview
delete server_event_handler_class and use process
go-cqhttp-down.sh script add arm64 support
add ./zhamao support
change build-runtime.sh to install-runtime.sh
add option --disable-safe-exit
adjust some Console output
set start script using /bin/sh for supporting auto searching php and framework
2021-05-08 10:02:41 +08:00
Whale
231a377718 Update README.md 2021-05-08 01:24:27 +08:00
jerry
a80ee902a9 Merge remote-tracking branch 'origin/master' 2021-04-06 01:20:07 +08:00
jerry
c2d3b5f92a update to build 406 version 2021-04-06 01:19:56 +08:00
Whale
64365af124 Update README.md 2021-03-31 00:10:43 +08:00
jerry
60619dbffc update docs 2021-03-29 17:18:19 +08:00
jerry
77e77e9cc3 update to 2.4.4 version (build 405)
change requirements: add pcntl as required extension
update docs
2021-03-29 17:12:09 +08:00
jerry
d72b41a902 update to build 404
fix ./zhamao command
fix warning when first time starting framework
2021-03-29 15:48:47 +08:00
jerry
dfddaaea94 update docs 2021-03-29 15:40:36 +08:00
jerry
6b872c6f74 update to 2.4.3 version (build 403)
add config: swoole.max_wait_time (default 5)
add constant MAIN_WORKER
add getExpireTS() for LightCache
fix savePersistence() bug
add zm_go() to prevent errors
2021-03-29 15:34:24 +08:00
jerry
202c8aee77 update docs 2021-03-27 17:32:43 +08:00
jerry
ba397a1744 update docs and README.md
make image onto image server(for boost)
2021-03-27 17:30:39 +08:00
jerry
d699a152d5 update to 2.4.2 version (build 402)
change WORKING_DIR constant
change logic of savePersistence()
add LightCache addPersistence() and removePersistence() method
add `./zhamao` command
2021-03-27 16:30:15 +08:00
jerry
beef44ea50 update docs: fix picture 2021-03-25 17:22:07 +08:00
jerry
b991a2da7b update docs: fix picture 2021-03-25 17:20:00 +08:00
jerry
bbe4addd83 update to 2.4.1 version (build 401)
fix startup warning bug
2021-03-25 17:11:35 +08:00
jerry
600829645d fix init command 2021-03-25 16:56:08 +08:00
jerry
68280cfe7e fix init command 2021-03-25 16:50:32 +08:00
jerry
c5523aa95d reset global config 2021-03-25 16:19:09 +08:00
jerry
93a68a5582 update to v2.4.0 (build 400)
add systemd:generate command
add check:config command
init command add `--force|-F` option
add MessageUtil function `addShortCommand()`
clear debug message
2021-03-25 16:18:09 +08:00
jerry
6155236d3c update to v2.4.0 (build 399)
add CheckConfigCommand.php
add config update record docs
adjust swoole version to 4.5.0
fix stop and reload bugs
add $_running_annotation
add remote terminal
update global config
add timer tick exception handler
add zm_xxx global functions
add isAtMe(), splitCommand(), matchCommand() function for MessageUtil
add workerAction(), sendActionToWorker(), resumeAllWorkerCoroutines() functions for ProcessManager
optimize CQCommand match function
add custom TerminalCommand annotation
add TuringAPI
add getReloadableFiles() function for ZMUtil
2021-03-24 23:34:46 +08:00
28f7f20728 update docs 2021-03-23 14:51:55 +08:00
235256d679 rollback and correct to 398(v2.3.5) 2021-03-23 14:49:42 +08:00
626d569858 update composer and roll to 397(v2.3.4) 2021-03-23 14:16:56 +08:00
0492179bdd update composer and roll to 396(v2.3.3) 2021-03-23 14:13:04 +08:00
1dfd1de5c1 update composer and roll to 396(v2.3.3) 2021-03-23 14:11:21 +08:00
d15d01c32b update docs 2021-03-23 14:09:11 +08:00
jerry
c9f4278d9b update forgotten docs 2021-03-23 14:04:45 +08:00
jerry
6aa0540c9e Merge branch 'master' of https://github.com/zhamao-robot/zhamao-framework 2021-03-23 14:03:14 +08:00
jerry
9689dc9db1 rename 2021-03-23 14:02:58 +08:00
Whale
c20e3324d4 Merge pull request #35 from zhamao-robot/2.3.x
2.3.x
2021-03-23 13:28:18 +08:00
303f44cd2b update to version 2.3.2 (build 395)
fix overflow bug
2021-03-23 13:11:59 +08:00
66b73973b4 update to version 2.3.2 (build 394)
fix mysql error bugs
2021-03-23 12:47:00 +08:00
jerry
0ff4e52ed3 tmp connect 2021-03-22 07:44:11 +08:00
b6d1f724e9 update to build 389
add various global functions
2021-03-18 16:36:28 +08:00
e77b9d4970 update to 2.3.1 version (build 388)
cleanup code and fix a bug
2021-03-18 14:56:35 +08:00
jerry
456b102c15 update docs 2021-03-16 01:39:55 +08:00
jerry
cc57997abc update to build 387 2021-03-16 01:35:01 +08:00
jerry
19e61c7cc3 update to build 386
fix ZM_DATA equals null
add containsImage, getImageCQFromLocal function for MessageUtil
2021-03-16 01:34:17 +08:00
jerry
f908513dca update to build 385
add CQObject for CQ
add after-stop action(set terminal level 0)
update global.php modules, add http_proxy_server
add MessageUtil.php for message parsing
add RouteManager::addStaticFileRoute() for quick handling static file
finish onTask function finally!!
add TaskManager::runTask()
2021-03-15 02:54:16 +08:00
jerry
7dc39e6ada update to 2.2.11 verion
add build version (start from 384)
make 启动中 log as verbose
remove console input
fix pure http server bug
add error handler for zm_timer_tick and zm_timer_after
2021-03-13 15:16:10 +08:00
jerry
b0be53554d Merge remote-tracking branch 'origin/master' 2021-03-13 03:03:14 +08:00
jerry
b98048bd39 update docs 2021-03-13 03:03:01 +08:00
Whale
fffd3fdc95 Update README.md 2021-03-12 19:45:53 +08:00
jerry
dea9ed2ccd update docs 2021-03-08 00:56:35 +08:00
jerry
de5744c9e4 update to 2.2.10 version
add build-runtime.sh
remove debug msg when stopping
add --show-php-ver argument for server
2021-03-08 00:48:51 +08:00
jerry
a23f3d8f16 update to 2.2.9 version
update reply() to support quick operation
fix reload bug
fix reply() bug
2021-03-06 17:22:42 +08:00
jerry
0c24bfdedd fix a motd bug 2021-03-02 21:31:06 +08:00
jerry
c0b95c6840 delete workflows 2021-03-02 21:27:04 +08:00
jerry
e977b09e20 Merge remote-tracking branch 'origin/master' 2021-03-02 21:24:53 +08:00
jerry
4ff75cf199 update to 2.2.8 version
update motd message
2021-03-02 21:24:31 +08:00
Whale
24e70c70ce Update deploy-docs.yml 2021-03-02 14:27:55 +08:00
Whale
275a7bf00b Update deploy-docs.yml 2021-03-02 14:26:02 +08:00
Whale
455fc79818 Update deploy-docs.yml 2021-03-02 14:22:40 +08:00
Whale
8740c3c255 Update deploy-docs.yml 2021-03-02 14:19:51 +08:00
Whale
98bfca5bb9 Update deploy-docs.yml 2021-03-02 14:18:40 +08:00
Whale
fc8d01ad5f Update deploy-docs.yml 2021-03-02 13:53:12 +08:00
Whale
d9b8df1725 Update deploy-docs.yml 2021-03-02 13:50:52 +08:00
Whale
9b7802ac04 Update deploy-docs.yml 2021-03-02 13:50:39 +08:00
Whale
6e1f3e0406 Update deploy-docs.yml 2021-03-02 13:43:45 +08:00
Whale
a2d4bab062 Update index.md 2021-03-02 13:40:21 +08:00
Whale
f1cefad910 Create deploy-docs.yml 2021-03-02 13:37:07 +08:00
jerry
957c69bd1e update to 2.2.7 version
fix reply() bug
fix access_token bug
2021-02-27 16:19:18 +08:00
Whale
2902c5e805 Merge pull request #33 from YiwanGi/master
Update ServerEventHandler.php
2021-02-27 16:13:46 +08:00
Wang
faf9f5d988 Update ServerEventHandler.php
-When the token is incorrect, repeated connection events occur in the framework
2021-02-27 00:04:02 +08:00
Whale
874f061468 Update README.md 2021-02-26 11:05:04 +08:00
jerry
69521a1f1f cleanup code, update some features
add Hitokoto API
add Closure for access_token
add working_dir() global function
adjust reply() method to .handle_quick_operation
2021-02-24 23:37:00 +08:00
Whale
fb9dbed306 Merge pull request #32 from wen1014/master
warning bug fix
2021-02-23 23:24:45 +08:00
Whale
d42158ac90 Merge branch 'master' into master 2021-02-23 23:24:24 +08:00
Whale
ff3ebec562 Merge pull request #31 from YiwanGi/patch-8
Update spin-lock.md
2021-02-23 23:22:01 +08:00
wenhao
ea79de617e warning bug fix 2021-02-23 17:04:10 +08:00
Wang
9e1ad6a983 Update spin-lock.md
-Forgotten data content
2021-02-22 19:34:06 +08:00
Whale
c17248df31 Merge pull request #30 from YiwanGi/patch-7
Update light-cache.md
2021-02-22 11:33:52 +08:00
Whale
4c116ebd86 Merge pull request #29 from YiwanGi/patch-5
Update console.md
2021-02-22 11:33:29 +08:00
Whale
c490fe0c1c Merge pull request #28 from YiwanGi/patch-6
Update route-annotations.md
2021-02-22 11:32:46 +08:00
Whale
cefdf23799 Merge pull request #27 from YiwanGi/patch-4
Update README.md
2021-02-22 11:32:06 +08:00
Wang
7f70642606 Update light-cache.md
-Follow up the latest configuration data
2021-02-22 02:51:35 +08:00
Wang
1d5b2609f9 Update console.md 2021-02-22 02:03:22 +08:00
Wang
a206fe8b87 Update route-annotations.md
-Correction of typos
2021-02-22 01:18:12 +08:00
Wang
fb4f6c45ce Update README.md
-Detail optimization
2021-02-22 01:07:35 +08:00
jerry
c50ae245bd commitment, nothing 2021-02-21 22:17:34 +08:00
Whale
f6c2131ebf Merge pull request #26 from YiwanGi/patch-3
Update README.md
2021-02-21 22:15:39 +08:00
Whale
543d1d2922 Merge pull request #25 from YiwanGi/patch-2
Update basic-config.md
2021-02-21 22:14:27 +08:00
Whale
bb61e6f6a2 Merge pull request #24 from YiwanGi/patch-1
Update quickstart-robot.md
2021-02-21 22:13:06 +08:00
YiwanGi
2d1bbf6b48 Update README.md
-Adjust the display format appropriately
-Solve the problem of no access to images in China
2021-02-21 12:48:54 +08:00
YiwanGi
67e42cfe3e Update basic-config.md
-Better display
2021-02-21 11:28:01 +08:00
YiwanGi
429a2cf230 Update quickstart-robot.md
-Better display
2021-02-21 10:48:23 +08:00
jerry
9ace85e604 update to 2.2.5 version again
add transaction for SpinLock.php
add getAllCQ() for CQ.php
fix CQ bug
update docs
2021-02-20 16:57:19 +08:00
jerry
f677b0e132 update to 2.2.5 version
add saveToJson and loadFromJson function for DataProvider.php
fix @OnSave annotation not working
adjust swoole timer tick
add hasKey() for WorkerCache.php
2021-02-15 15:15:26 +08:00
jerry
f137f044d0 Merge remote-tracking branch 'origin/master' 2021-02-09 17:09:26 +08:00
jerry
77c12db31a reformat code 2021-02-09 17:09:09 +08:00
Whale
b670cb29fe Update README.md 2021-02-09 11:12:29 +08:00
Whale
95d7bb071d Update README.md 2021-02-09 10:54:59 +08:00
Whale
eadb4c1dee Update README.md 2021-02-09 10:54:05 +08:00
Whale
6672a6c852 Update README.md 2021-02-09 10:53:52 +08:00
Whale
094feddda4 Update README.md 2021-02-09 10:53:15 +08:00
Whale
f86eddb298 Update README.md 2021-02-09 10:48:05 +08:00
Whale
a93b4917cd Update README.md 2021-02-09 10:47:40 +08:00
jerry
0f9767aa16 update docs 2021-02-07 11:48:55 +08:00
jerry
0c9f246690 update to 2.2.4 version
update docs
fix broken ssh caused cpu overloading
fix WorkerCache bug when no global config
add global function zm_atomic
2021-02-07 11:46:42 +08:00
jerry
517d258d61 update to 2.2.3 version, I am tired
fix access_token not working
fix waitMessage() not working in v2.2.2
2021-01-30 00:06:42 +08:00
jerry
61e3818563 update to 2.2.2 version finally
clean redundant code
fix API reply in @OnTick for multi-process
fix loop error reporting
2021-01-29 23:34:34 +08:00
jerry
776ec98a3e fix waitMessage timeout bug 2021-01-29 22:32:29 +08:00
jerry
f3e844bb0a update to 2.2.2 version
fix QQBot error
clean code
2021-01-29 22:27:10 +08:00
jerry
a55cd4ed05 update docs 2021-01-29 21:37:02 +08:00
jerry
8a985620f9 update to 2.2.1 version
fix a compatibility bug
2021-01-29 21:36:14 +08:00
jerry
484ddf9dfa update Hello.php
update docs
2021-01-29 21:30:19 +08:00
jerry
b611b4aad6 add DaemonCommand for daemon players
adjust http_header available
2021-01-29 20:47:00 +08:00
jerry
b9f973c718 add unset for WorkerCache.php 2021-01-20 18:43:22 +08:00
jerry
cd6c971547 update Singleton 2021-01-20 16:45:50 +08:00
jerry
c68083484a update to 2.2.0 version
add OnPipeMessageEvent.php
add ProcessManager.php
add WorkerCache component
fix route bug
correct Exception to ZMException
2021-01-20 16:11:04 +08:00
jerry
f999e689bf update docs 2021-01-18 18:09:33 +08:00
jerry
187a08a621 update to 2.1.6 version
优化代码结构
增加更多提示语
修复处理空格消息时的报错
修复上下文的bug
2021-01-18 18:08:29 +08:00
Whale
c208298937 Update README.md 2021-01-14 18:32:54 +08:00
crazywhalecc
e9e3e5e129 update docs 2021-01-13 15:46:55 +08:00
crazywhalecc
1ef8225d10 update to 2.1.5 version
change route to Symfony routing
2021-01-13 15:40:27 +08:00
crazywhalecc
ccadec23e4 update docs and change console command suitable 2021-01-07 16:01:01 +08:00
jerry
0972a1959e update README.md 2021-01-05 23:35:49 +08:00
crazywhalecc
ce74191947 update docs 2021-01-05 16:19:35 +08:00
crazywhalecc
4feeb9519c update docs 2021-01-04 16:59:19 +08:00
crazywhalecc
efee146215 update docs 2021-01-04 16:45:06 +08:00
jerry
96ce7b30d0 add InterruptException catcher to onRequest 2021-01-04 01:35:54 +08:00
jerry
076339baec move warning to framework 2021-01-03 18:16:35 +08:00
jerry
50026be73d fix a bug 2021-01-03 18:13:44 +08:00
jerry
a1ad634926 fix a bug 2021-01-02 20:00:33 +08:00
jerry
0a5defaf29 fix a bug 2021-01-02 19:44:19 +08:00
jerry
557efc47a8 update to 2.1.4 version 2021-01-02 19:40:13 +08:00
jerry
c566f940e0 add custom app version 2021-01-02 18:10:20 +08:00
jerry
381062c6c5 update to 2.1.3 version
fix an AnnotationParser bug which is stupid
2021-01-02 16:36:25 +08:00
jerry
b31876025e update composer.json 2021-01-02 13:35:45 +08:00
jerry
ae8b0acdaa update to 2.1.2 version 2021-01-02 13:35:24 +08:00
jerry
20ca3e7416 update docs 2021-01-02 13:28:26 +08:00
jerry
a1bfc031b8 update to 2.1.1 version 2021-01-02 13:20:16 +08:00
jerry
8a6f8f54a5 update composer.json path 2021-01-02 13:19:39 +08:00
jerry
19f0bffcd8 update composer.json 2021-01-02 13:16:22 +08:00
jerry
6337b626d6 update to 2.1.0 version
add @OnCloseEvent, @OnOpenEvent, @OnMessageEvent, @OnRequestEvent
update EventDispatcher.php and change it to status-based schema
fix @CQBefore bugs
2021-01-02 13:15:50 +08:00
crazywhalecc
7434bac94e update to 2.0.3 version 2020-12-31 16:26:51 +08:00
crazywhalecc
ac45ab0dec update to 2.0.2 version 2020-12-31 13:58:59 +08:00
crazywhalecc
8d248f301e update to 2.0.2 version 2020-12-31 13:56:59 +08:00
jerry
937d31ccd9 update docs 2020-12-31 01:44:09 +08:00
crazywhalecc
ef263a5d1e update docs 2020-12-31 00:35:40 +08:00
jerry
bf03dfda38 Merge remote-tracking branch 'origin/master' 2020-12-31 00:28:36 +08:00
jerry
6ba209c4c7 update docs 2020-12-31 00:28:16 +08:00
Whale
e7d86537be Update README.md 2020-12-26 21:04:48 +08:00
crazywhalecc
44979c670f update docs 2020-12-25 16:53:44 +08:00
Whale
747ecf28ea Merge pull request #23 from 854854321/master
[MOD] add global function -> getAllFdByConnectType  根据连接类型获取所有fd.
2020-12-25 16:41:48 +08:00
Whale
f5d5929cb9 Update global_functions.php 2020-12-25 16:41:14 +08:00
Whale
6e866001d6 Update global_functions.php 2020-12-25 16:40:02 +08:00
wenhao
775c275288 [MOD] 解决php Notice <PHP Notice: Undefined index: x-self-id> 2020-12-25 16:28:21 +08:00
wenhao
86a0e1a2ca [MOD] add global function -> getAllFdByConnectType 根据连接类型获取所有fd. 2020-12-25 15:48:41 +08:00
Whale
aae79aacb5 Update README.md 2020-12-25 01:42:23 +08:00
Whale
991af3d728 Update README.md 2020-12-25 01:41:23 +08:00
Whale
25ae4e02c2 Update README.md 2020-12-25 01:40:45 +08:00
Whale
5a6642e217 Update README.md 2020-12-25 01:40:24 +08:00
Whale
d00f6ee3a2 Update README.md 2020-12-25 01:27:19 +08:00
crazywhalecc
1e6cc9cd84 update docs 2020-12-23 16:20:35 +08:00
crazywhalecc
b7b94db5ea Merge remote-tracking branch 'origin/master' into master 2020-12-23 16:15:18 +08:00
crazywhalecc
b0054d7884 update docs 2020-12-23 16:14:59 +08:00
Whale
22942c33cf Update README.md 2020-12-23 11:27:23 +08:00
crazywhalecc
1f9c5eeeb4 add CNAME 2020-12-23 11:23:57 +08:00
crazywhalecc
44337d2ad4 update to 2.0.1 version
fix swoole log file "no such file or directory" error
2020-12-23 11:16:24 +08:00
crazywhalecc
d80de2a552 initial commit for v2 2020-12-23 10:35:25 +08:00
crazywhalecc
5b85ec15e9 Merge remote-tracking branch 'origin/2.0-dev' into master
# Conflicts:
#	README.md
#	SECURITY.md
#	composer.json
#	src/Framework/FrameworkLoader.php
#	src/ZM/Event/Swoole/RequestEvent.php
#	src/ZM/Http/Response.php
2020-12-23 10:33:25 +08:00
crazywhalecc
420f326f11 update README.md 2020-12-23 10:28:20 +08:00
crazywhalecc
f361a675af update README.md 2020-12-23 10:21:48 +08:00
jerry
18c09beacb update docs 2020-12-23 01:21:51 +08:00
crazywhalecc
c15d320ef6 update docs 2020-12-22 16:46:59 +08:00
crazywhalecc
58da612121 update docs 2020-12-22 16:39:37 +08:00
crazywhalecc
64ec34d54d update docs 2020-12-22 16:35:22 +08:00
crazywhalecc
eeb952035a update docs 2020-12-22 16:31:16 +08:00
crazywhalecc
e78485273d update docs 2020-12-22 16:28:34 +08:00
crazywhalecc
9bd07e5a66 update docs 2020-12-21 16:56:36 +08:00
jerry
4deb814ff2 fix a little bug 2020-12-21 01:43:40 +08:00
jerry
619baf1691 update to 2.0.0-b9 version
fix a little bug
2020-12-20 19:15:28 +08:00
jerry
bc0bb9b6b0 update to 2.0.0-b8 version
fix environment conflict and remove custom commands
2020-12-20 18:49:03 +08:00
jerry
42d9c97711 update to 2.0.0-b7 version
fix environment getter
2020-12-20 18:40:26 +08:00
jerry
81365173d2 update to 2.0.0-b6 version
add interrupt return_value to InterruptException
2020-12-20 18:08:34 +08:00
jerry
ba5b793db7 update to 2.0.0-b5 version
set modules config to array
add subdir index.html
update Example of Hello.php
add Exception tester for TimerMiddleware.php
add keyword for @CQCommand
rename OnWorkerStart.php to OnStart.php
remove SwooleEventAfter.php
rename HandleEvent.php to SwooleHandler.php
set ZMRobot callback mode default to true
add getNextArg() and getFullArg()
add EventDispatcher.php logger
set Exception all based from ZMException
fix recursive bug for Response.php
add single_bot_mode
add SingletonTrait.php
add bot() function
2020-12-14 01:24:34 +08:00
crazywhalecc
1ffb30a471 update to v2.0.0-b4 version
change global.php config load time and logic
set context get server function available more time
delete unused comment and @CQAPISend
@CQCommand add start_with and end_with
set exceptions extended by ZMException
rename @SwooleSetup to @ZMSetup
fix quotes for global.php
fix LightCache empty presistence_path error
remove RemoteShell
2020-12-10 16:37:04 +08:00
crazywhalecc
cc31a1654d update to v1.6.5 version
correct version name
update dependencies
2020-12-09 14:06:58 +08:00
crazywhalecc
dfca486b64 update to v1.6.5 version
correct version name
2020-12-09 13:57:51 +08:00
crazywhalecc
754c2846fe update to v1.6.5 version
fix composer.json bug
2020-12-09 13:53:16 +08:00
crazywhalecc
eed670cb50 update to v1.6.4 version
fix LOAD_MODE = 1 autoload bug
remove unnecessary dependencies
2020-12-09 13:43:25 +08:00
Whale
9e824d960f Update README.md 2020-12-08 02:07:08 +08:00
Whale
992b6020a5 Update README.md 2020-12-08 02:06:48 +08:00
Whale
d51dbef437 Update README.md 2020-11-28 09:32:11 +08:00
jerry
944a9e849b update documents 2020-11-23 01:47:37 +08:00
jerry
09a11821b2 update documents 2020-11-23 01:09:57 +08:00
jerry
dbfe2c9c17 update documents 2020-11-23 00:24:33 +08:00
Whale
7f058638bd Update README.md 2020-11-23 00:07:17 +08:00
jerry
63e0594199 update README.md 2020-11-22 19:26:35 +08:00
jerry
4a4bc697d6 update docs 2020-11-22 19:21:29 +08:00
jerry
8edc3f337b update to 2.0.0-b3 2020-11-22 19:18:23 +08:00
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
jerry
c460b37d14 add mkdocs documents 2020-11-10 23:16:55 +08:00
jerry
7fe405d0af initial 2.0.0-b2 commit 2020-11-08 20:14:08 +08:00
jerry
3b90bf6245 initial 2.0.0-b1 commit 2020-11-08 19:40:16 +08:00
jerry
deab5fd921 initial 2.0.0-a5 commit
fix waitMessage function
fix CQCommand regexMatch and fullMatch
it just works
2020-11-04 18:43:50 +08:00
jerry
29fa9d8662 initial 2.0.0-a4 commit 2020-11-03 21:02:24 +08:00
jerry
da584e0542 initial 2.0.0-a3 commit 2020-10-03 23:00:18 +08:00
Whale
13a32bec79 Update README.md 2020-10-03 09:29:17 +08:00
jerry
f91d24aaaa initial 2.0.0-a2 commit 2020-09-29 15:07:43 +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
jerry
1510e2f0d0 initial 2.0 commit 2020-08-31 10:15:25 +08:00
jerry
82896ee4a1 initial 2.0 commit 2020-08-31 10:14:48 +08:00
jerry
beb1f5f063 initial 2.0 commit 2020-08-31 10:11:06 +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
jerry
5de283d30c fix issue #15 at version 1.6.2 2020-07-27 09:52:52 +08:00
jerry
7513fd1a1d add downloadFile option for version 1.6.1 2020-07-26 13:43:52 +08:00
326 changed files with 16934 additions and 7966 deletions

15
.editorconfig Normal file
View File

@@ -0,0 +1,15 @@
root = true
[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 4
trim_trailing_whitespace = true
[*.md]
trim_trailing_whitespace = false
[*.{yml,yaml}]
indent_size = 2

View File

@@ -1,5 +0,0 @@
#!/bin/bash
if [ ! -d "/app/zhamao-framework/bin" ]; then
cp -r /app/zhamao-framework-bak/* /app/zhamao-framework/
fi
php /app/zhamao-framework/bin/start

21
.gitattributes vendored Normal file
View File

@@ -0,0 +1,21 @@
# Exclude build/test files from archive (reduce package size)
/.github export-ignore
/.phive export-ignore
/build export-ignore
/docs export-ignore
/ext export-ignore
/resources export-ignore
/tests export-ignore
/tests_old export-ignore
/.editorconfig export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
/.php-cs-fixer.php export-ignore
/captainhook.json export-ignore
/install-runtime.sh export-ignore
/package.json export-ignore
/phpstan.neon export-ignore
/phpunit.xml.dist export-ignore
# Configure diff output
*.php diff=php

View File

@@ -0,0 +1,38 @@
name: 🐛 漏洞BUG报告
description: ⚠️ 请不要直接在此提交安全漏洞
labels: bug
body:
- type: input
id: affected-versions
attributes:
label: 受影响版本
placeholder: x.y.z
validations:
required: true
- type: textarea
id: description
attributes:
label: 描述
description: 请详细地描述您的问题
validations:
required: true
- type: textarea
id: reproduce-steps
attributes:
label: 复现步骤
description: |
请尽可能地提供可以复现此步骤的漏洞。
如果步骤过长或难以描述,您可以自行建立一个用于复现漏洞的仓库。
validations:
required: true
- type: textarea
id: possible-solution
attributes:
label: 解决方案
description: 如果您对这个漏洞的成因或修复有任何意见的话,请在此提出
- type: textarea
id: additional-context
attributes:
label: 附加信息
description: 其他可能有帮助的信息,如日志、截图等

View File

@@ -0,0 +1,19 @@
name: 🚀 功能建议
description: 新功能、改进的意见、草案
labels: enhancement
body:
- type: textarea
id: description
attributes:
label: 描述
description: 请提供简洁清楚的描述
validations:
required: true
- type: textarea
id: example
attributes:
label: 例子
description: |
一个简单的例子,展示该功能将如何被使用(包括代码、配置文件等)
如果这是针对已有功能的改进,请展示改进前后使用方式(或效能)的对比

43
.github/workflows/coding-style.yml vendored Normal file
View File

@@ -0,0 +1,43 @@
name: Code Style
on:
push:
pull_request:
workflow_dispatch:
jobs:
pre_job:
runs-on: ubuntu-latest
outputs:
should_skip: ${{ steps.skip_check.outputs.should_skip }}
steps:
- id: skip_check
uses: fkirc/skip-duplicate-actions@v5
with:
concurrent_skipping: same_content_newer
skip_after_successful_duplicate: true
paths: '["src/**", "tests/**"]'
do_not_skip: '["workflow_dispatch", "schedule"]'
cs-fix:
needs: pre_job
if: ${{ needs.pre_job.outputs.should_skip != 'true' }}
name: Code Style
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup PHP
uses: sunxyw/workflows/setup-environment@main
with:
php-version: 8.0
php-extensions: swoole, posix, json
operating-system: ubuntu-latest
use-cache: true
- name: Code Style
uses: sunxyw/workflows/coding-style@main

View File

@@ -0,0 +1,61 @@
name: Increment Build Number
on:
pull_request:
branches:
- main
types:
- closed
paths:
- 'src/**.php'
jobs:
incremental-build-number:
if: github.event.pull_request.merged == true
name: Incremental Build Number
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
ref: ${{ github.base_ref }}
- name: Setup PHP
uses: sunxyw/workflows/setup-environment@main
with:
php-version: 8.1
php-extensions: swoole, posix, json
operating-system: ubuntu-latest
use-cache: true
- name: Prepare Doxygen
id: prepare-doxygen
continue-on-error: true
run: bin/prepare-doxygen before
- name: Generate Doxygen
if: steps.prepare-doxygen.outcome == 'success'
uses: mattnotmitt/doxygen-action@v1.9.5
- name: Finishing Doxygen
if: steps.prepare-doxygen.outcome == 'success'
run: bin/prepare-doxygen after
- name: Commit API Docs
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: update api docs
branch: ${{ github.base_ref }}
- name: Increment build number
id: increment-build-number
run: |
sed -i -r 's/(.*)(\VERSION_ID\s=\s)([0-9]+)(.*)/echo "\1\2$((\3+1))\4"/ge' src/ZM/Framework.php
BUILD_ID=$(cat src/ZM/Framework.php | grep "VERSION_ID = " | sed 's/[^0-9]//g')
echo "::set-output name=build_id::$BUILD_ID"
- name: Commit build number
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: increment build number (build ${{ steps.increment-build-number.outputs.build_id }})
branch: ${{ github.base_ref }}

43
.github/workflows/static-analysis.yml vendored Normal file
View File

@@ -0,0 +1,43 @@
name: Static Analysis
on:
push:
pull_request:
workflow_dispatch:
jobs:
pre_job:
runs-on: ubuntu-latest
outputs:
should_skip: ${{ steps.skip_check.outputs.should_skip }}
steps:
- id: skip_check
uses: fkirc/skip-duplicate-actions@v5
with:
concurrent_skipping: same_content_newer
skip_after_successful_duplicate: true
paths: '["src/**", "tests/**"]'
do_not_skip: '["workflow_dispatch", "schedule"]'
analyse:
needs: pre_job
if: ${{ needs.pre_job.outputs.should_skip != 'true' }}
name: Static Analysis
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup PHP
uses: sunxyw/workflows/setup-environment@main
with:
php-version: 8.0
php-extensions: swoole, posix, json
operating-system: ubuntu-latest
use-cache: true
- name: Static Analysis
uses: sunxyw/workflows/static-analysis@main

55
.github/workflows/test.yml vendored Normal file
View File

@@ -0,0 +1,55 @@
name: Test
on:
push:
branches:
- main
- develop
- '*-dev*'
pull_request:
types:
- opened
- reopened
- review_requested
workflow_dispatch:
jobs:
pre_job:
runs-on: ubuntu-latest
outputs:
should_skip: ${{ steps.skip_check.outputs.should_skip }}
steps:
- id: skip_check
uses: fkirc/skip-duplicate-actions@v5
with:
concurrent_skipping: same_content_newer
skip_after_successful_duplicate: true
paths: '["src/**", "tests/**", "bin/phpunit-zm"]'
do_not_skip: '["workflow_dispatch", "schedule"]'
test:
needs: pre_job
if: ${{ needs.pre_job.outputs.should_skip != 'true' }}
strategy:
matrix:
operating-system: [ ubuntu-latest, windows-latest, macos-latest ]
php-version: [ 8.0, 8.1, 8.2 ]
name: PHP ${{ matrix.php-version }} Test (${{ matrix.operating-system }})
runs-on: ${{ matrix.operating-system }}
timeout-minutes: 10
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup PHP
uses: sunxyw/workflows/setup-environment@main
with:
php-version: ${{ matrix.php-version }}
php-extensions: swoole, posix, json
operating-system: ${{ matrix.operating-system }}
use-cache: true
- name: Test
uses: sunxyw/workflows/test@main

51
.github/workflows/vuepress-deploy.yml vendored Normal file
View File

@@ -0,0 +1,51 @@
name: Docs and Script Auto Deploy
on:
push:
branches:
- main
paths:
- 'docs/**'
- 'ext/**'
jobs:
build:
name: Deploy docs
runs-on: ubuntu-latest
steps:
- name: Checkout master
uses: actions/checkout@v3
- name: Deploy docs to GitHub Pages
uses: jenkey2011/vuepress-deploy@master
env:
ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BUILD_SCRIPT: yarn && yarn docs:build
BUILD_DIR: docs/.vuepress/dist/
- name: Copy deployment to current folder
run: |
cp -r "${GITHUB_WORKSPACE}/docs/.vuepress/dist" "./deploy"
- name: Deploy to Zhamao Server
uses: easingthemes/ssh-deploy@main
env:
SSH_PRIVATE_KEY: ${{ secrets.ZHAMAO_XIN_PRIVATE_KEY }}
ARGS: "-rltgoDzvO --delete"
SOURCE: "deploy/"
REMOTE_HOST: ${{ secrets.ZHAMAO_XIN_HOST }}
REMOTE_USER: ${{ secrets.ZHAMAO_XIN_USER }}
TARGET: ${{ secrets.FRAMEWORK_ZHAMAO_XIN_TARGET }}
- name: deploy script file
uses: wlixcc/SFTP-Deploy-Action@v1.2
with:
username: ${{ secrets.ZHAMAO_XIN_USER }}
server: ${{ secrets.ZHAMAO_XIN_HOST }}
ssh_private_key: ${{ secrets.ZHAMAO_XIN_PRIVATE_KEY }}
local_path: './ext/go.sh'
remote_path: ${{ secrets.ZHAMAO_XIN_MAIN_TARGET }}
- name: deploy script file
uses: wlixcc/SFTP-Deploy-Action@v1.2
with:
username: ${{ secrets.ZHAMAO_XIN_USER }}
server: ${{ secrets.ZHAMAO_XIN_HOST }}
ssh_private_key: ${{ secrets.ZHAMAO_XIN_PRIVATE_KEY }}
local_path: './ext/v3.sh'
remote_path: ${{ secrets.ZHAMAO_XIN_MAIN_TARGET }}

91
.gitignore vendored
View File

@@ -1,8 +1,87 @@
.idea/
/src/test/
/src/webconsole/config/
/vendor/
zm.json
### Zhamao Framework ###
/zm_data/
composer.lock
/resources/server.phar
/distribute/
/resources/zhamao.service
/runtime/
/tmp/
/temp/
/site/
/plugins/
/doxy/
/walle/
# 框架审计文件
audit.log
# 进程锁文件
.daemon_pid
.zm_worker_*.pid
### Composer ###
composer.phar
/vendor/
composer.lock
### Go CQHTTP ###
/ext/go-cqhttp/data/
/ext/go-cqhttp/logs/
/ext/go-cqhttp/config.hjson
/ext/go-cqhttp/device.json
/ext/go-cqhttp/go-cqhttp
/ext/go-cqhttp/session.token
### Git ###
# 备份文件
*.orig
# 解决 Merge 冲突时可能会自动生成的文件
*.BACKUP.*
*.BASE.*
*.LOCAL.*
*.REMOTE.*
*_BACKUP_*.txt
*_BASE_*.txt
*_LOCAL_*.txt
*_REMOTE_*.txt
# Git Hooks
cghooks.lock
### VuePress ###
/node_modules/
/docs/.vuepress/dist/
package-lock.json
### PHPUnit ###
# 生成的文件
/bin/.phpunit.result.cache
.phpunit.result.cache
.phpunit.cache
# 本地配置
/phpunit.xml
# 构建目录
/build/
### PhpStorm ###
# 兼容 PHPStorm 及其他 Jetbrains IDE
# 除了代码格式配置和运行配置之外的所有文件
.idea/*
!.idea/codeStyles
!.idea/runConfigurations
### Phive ###
/.phive/
/tools/
### ASDF ###
/.tool-version
.DS_Store
### PHP CS Fixer ###
.php-cs-fixer.cache

76
.php-cs-fixer.php Normal file
View File

@@ -0,0 +1,76 @@
<?php
declare(strict_types=1);
/**
* @since 2.7.0
*/
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,
])
->setFinder(
PhpCsFixer\Finder::create()
->in(__DIR__ . '/src')
->in(__DIR__ . '/tests')
->in(__DIR__ . '/config')
->in(__DIR__ . '/bin')
);

11
.phpstorm.meta.php Normal file
View File

@@ -0,0 +1,11 @@
<?php
namespace PHPSTORM_META {
use OneBot\V12\Object\Event\OneBotEvent;
use ZM\Context\Context;
override(Context::__call(0), map([
'getBotEvent' => OneBotEvent::class,
]));
}

68
CONTRIBUTING.md Normal file
View File

@@ -0,0 +1,68 @@
# 炸毛框架贡献指南
首先很高兴你愿意读这篇文章,因为我们需要更多的开发者来帮助我们开发和维护。
如果你还没加入我们的 [QQ 群670821194][qq-group],我们建议你加入一下,以便和其他开发者实时交流和协作。
## 测试
我们目前采用 PHPUnit 作为测试框架,如果你编写了新的功能或改变了现有的行为,我们希望你可以编写相应的测试代码。
## 提交变更
请使用 [GitHub Pull Request][new-pr] 提交你的更改,并附上恰当的说明(例如一个简明的列表列出所作的改动)。
同时,请不要忘记在提交前执行代码格式检查 `composer cs-fix` 和静态分析检查 `composer analyse`
。虽然我们的自动化流程会在你推送到仓库后自动运行检查,但我仍然建议你提前在本地运行,以节省可能的修改成本。
对了,请尽量为你的每个函数、方法加上 PHPDoc 注释。
## 具体贡献流程
#### **你发现了个 BUG**
- **如果你发现的是安全漏洞,请不要在 GitHub 上回报!** 请直接联系 [@crazywhalecc](https://github.com/crazywhalecc)。
- **确保该问题还没被其他人回报。** 你可以在 [Issue 列表][issues] 中搜索相关关键词来检查。
- 如果你没能找到一个已有的 Issue 来描述你遇到的问题,[请新建一个 Issue][new-issue]。请务必包含**标题和清晰的描述**
,尽可能多的相关信息,以及一个**代码示例**或者一个**可执行的测试用例**,来描述你遇到的问题。
- 如果可以的话,请使用相关的 Issue 模板来创建 Issue。
#### **你修复了个 BUG**
- 在 GitHub 上提交一个 Pull Request。
- 确保 PR 的描述清楚地描述了问题和解决方案。如果有相关的 Issue请在 PR 描述中包含 Issue 编号。
#### **你想添加新功能或改变现有功能?**
- 虽然你可以直接提交 PR但我们建议你先与我们的开发者讨论你的想法以避免你的努力白费。你可以在 [QQ 群][qq-group]
中与我们的开发者交流,或者在 [GitHub Issue][issues] 中提出你的想法。
- 如果你的想法被采纳,你可以在 GitHub 上[提交一个 Pull Request][new-pr]。
#### **你对源码有疑问?**
- 你可以在 [QQ 群][qq-group] 中与我们的开发者讨论,或者你也可以在 [GitHub Issue][issues] 中提出你的疑问。
#### **你想为文档做贡献?**
- 非常欢迎^^
- 你可以直接[提交一个 Pull Request][new-pr]。
炸毛框架是由志愿开发者共同维护的项目。我们欢迎你加入我们的开发。
感谢~ :heart: :heart: :heart:
炸毛框架开发团队
[issues]: https://github.com/zhamao-robot/zhamao-framework/issues
[new-pr]: https://github.com/zhamao-robot/zhamao-framework/pull/new/master
[new-issue]: https://github.com/zhamao-robot/zhamao-framework/issues/new
[qq-group]: https://jq.qq.com/?_wv=1027&k=KdIGy0UK

View File

@@ -1,29 +0,0 @@
FROM ubuntu:18.04
WORKDIR /app/
RUN echo "Asia/Shanghai" > /etc/timezone
ENV LANG C.UTF_8
ENV LC_ALL C.UTF-8
ENV LANGUAGE C.UTF-8
RUN apt-get update && apt-get install -y software-properties-common tzdata
RUN dpkg-reconfigure -f noninteractive tzdata
VOLUME ["/app/zhamao-framework/"]
RUN add-apt-repository ppa:ondrej/php && \
apt-get update && \
apt-get install php php-dev php-mbstring gcc make openssl \
php-mbstring php-json php-curl php-mysql -y && \
apt-get install wget composer -y && \
wget https://github.com/swoole/swoole-src/archive/v4.5.0.tar.gz && \
tar -zxvf v4.5.0.tar.gz && \
cd swoole-src-4.5.0/ && \
phpize && ./configure --enable-openssl --enable-mysqlnd && make -j2 && make install && \
(echo "extension=swoole.so" >> $(php -i | grep "Loaded Configuration File" | awk '{print $5}'))
ADD . /app/zhamao-framework
ADD . /app/zhamao-framework-bak
#RUN cd /app/zhamao-framework && composer update && composer clearcache
#RUN mv zhamao-framework-master zhamao-framework
WORKDIR /app/zhamao-framework
CMD ["/bin/bash", "-i", "/app/zhamao-framework-bak/.entry.sh"]

View File

@@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Copyright 2022 CrazyBot Developer Team
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.

179
README.md
View File

@@ -1,89 +1,146 @@
# zhamao-framework
<div align="center">
<img src="https://cdn.jsdelivr.net/gh/zhamao-robot/zhamao-framework/resources/images/logo_trans.png" width = "150" height = "150" alt="炸毛框架"><br>
<h2>炸毛框架</h2>
炸毛框架 (zhamao-framework) 是一个高性能的聊天机器人 + 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)
<p align="center">
<a href="https://onebot.dev/">
<img src="https://img.shields.io/badge/OneBot-12-black?style=flat-square" alt="OneBot">
</a>
[![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)
<a href="https://github.com/zhamao-robot/zhamao-framework/actions">
<img src="https://img.shields.io/github/actions/workflow/status/zhamao-robot/zhamao-framework/test.yml?branch=v3-develop&label=Test&style=flat-square" alt="Integration Test">
</a>
协程高性能的 **QQ 机器人 + Web 服务器** 开发框架(炸毛框架)。
<a href="https://packagist.org/packages/zhamao/framework">
<img src="https://img.shields.io/packagist/dt/zhamao/framework?label=Downloads&style=flat-square" alt="下载数">
</a>
<img src="https://avatars0.githubusercontent.com/u/48620312" height = "200" alt="炸毛框架" align=center/>
<a href="https://github.com/zhamao-robot/zhamao-framework/releases">
<img src="https://img.shields.io/packagist/v/zhamao/framework?include_prereleases&label=Release&style=flat-square" alt="最新版本">
</a>
<a href="https://github.com/zhamao-robot/zhamao-framework/blob/master/LICENSE">
<img src="https://img.shields.io/github/license/zhamao-robot/zhamao-framework?label=License&style=flat-square" alt="开源协议">
</a>
<a href="https://github.com/zhamao-robot/zhamao-framework/search?q=TODO">
<img src="https://img.shields.io/github/search/zhamao-robot/zhamao-framework/TODO?label=TODO%20Counter&style=flat-square" alt="TODO">
</a>
</p>
</div>
开发者 QQ 群:**670821194** [点击加入群聊](https://jq.qq.com/?_wv=1027&k=YkNI3AIr)
**如果有愿意一起开发框架本身的开发者,请提出 PR 或 Issue 参与开发!如果对框架本身的核心设计有更好的想法,可与作者成立开发组(目前仅 2 人),参与 OneBot V12 生态和框架本身的开发。**
**相关正在进行的版本任务见 Projects 一栏!**
## 简介
zhamao-framework 是一个基于 酷Q 的 PHP Swoole 的机器人框架,它会对 QQ 机器人收到的消息进行解析处理,并以模块化的形式进行开发,来完成机器人的自然语言对话等功能。
框架对接 酷Q 的桥梁是 **CQHTTP** 插件,这里是它的[项目地址](https://github.com/richardchien/coolq-http-api/)。
炸毛框架使用 PHP 编写,主要面向 API 服务,聊天机器人,包含 Websocket、HTTP
等监听和请求库,用户代码采用模块化处理,使用注解可以方便地编写各类功能。
除了起到解析消息的作用,炸毛框架 还提供了完整的 WebSocket + HTTP 服务器,你还能用此框架构建出高性能的 API 接口服务器
框架主要用途为 HTTP 服务器,机器人搭建框架。尤其对于聊天机器人消息处理较为方便和全面,提供了众多会话机制和内部调用机制,可以以各种方式设计你自己的插件
```php
#[\BotCommand('你好')]
public function hello(\BotContext $ctx) {
$ctx->reply("你好,我是炸毛!"); // 简单的命令式回复
}
#[\Route('/index')]
public function index() {
return "<h1>hello!</h1>"; // 快速的 HTTP 服务开发
}
```
## 开始
先安装环境,环境安装见下方文档。
1. `composer create-project zhamao/framework-starter` 从模板新建基础文档结构进行使用
2. 你也可以直接到 **Release** 中下载最新的 phar 包,放入文件夹后 `php server.phar` 快速启动框架
3. 还可以使用 Dockerfile 构建 Docker 容器
框架目前支持 Linux、WSL、macOS、Windows 环境直接运行,其中 Linux、macOS 环境可直接使用下方一键安装脚本。
> 如果你想在其他环境安装部署,可使用 Docker 快速部署或手动安装环境后安装框架,详见文档。
```bash
# Linux、macOS 下一键检测 PHP 环境、安装框架
bash <(curl -fsSL https://zhamao.xin/v3.sh)
# 启动框架
cd zhamao-v3
./zhamao server
```
一键安装脚本还有可以自定义参数的方式,比如:
```bash
# 脚本默认会检测系统的PHP如果想直接跳过检测安装独立的PHP版本则添加此环境变量
export ZM_NO_LOCAL_PHP="yes"
# 脚本如果安装独立版本PHP默认版本为8.1,如果想使用其他版本,则添加此环境变量指定版本
export ZM_DOWN_PHP_VERSION="8.2"
# 脚本默认会将框架在当前目录下的 `zhamao-app` 目录进行安装,如果想使用其他目录,则添加此环境变量
export ZM_CUSTOM_DIR="my-custom-app"
# 脚本默认会对本项目使用阿里云国内加速镜像如果想使用packagist源则添加此环境变量
export ZM_COMPOSER_PACKAGIST="yes"
# 执行完前面的环境变量再执行一键安装脚本,就可以实现自定义参数!
bash <(curl -fsSL https://zhamao.xin/v3.sh)
```
关于其他安装方式,请参阅 [文档](https://framework.zhamao.xin/guide/installation.html) 。
## 文档
Pages托管[https://framework.zhamao.xin/](https://framework.zhamao.xin/)
国内服务器:[https://framework2.zhamao.xin/](https://framework2.zhamao.xin/)
查看文档(国内自建):<https://framework.zhamao.xin/>
备用链接(国外托管):<https://framework.zhamao.me/>
## 特点
- 支持多账号
- 灵活的注解事件绑定机制
- 支持下断点调试Psysh
- 易用的上下文,模块内随处可用
- 采用模块化编写,功能之间高内聚低耦合
- 常驻内存,全局缓存变量随处使用
- 自带 MySQL 查询器、数据库连接池等数据库连接方案
- 自带 HTTP 服务器、WebSocket 服务器可复用,可以构建属于自己的 HTTP API 接口
- 静态文件服务器
- 支持 phar 一键打包
## 炸毛特色模块
| 模块名称 | 说明 | 模块地址 |
| ------------------ | -------------------------------- | ------------------------------------------------------------ |
| 微信公众号兼容模块 | 为框架提供微信公众号订阅号兼容层 | [zhamao-wechat-patch](https://github.com/zhamao-robot/zhamao-wechat-patch) |
| 通用模块 | 图片上传和下载模块 | [zhamao-general-tools](https://github.com/zhamao-robot/zhamao-general-tools) |
## 计划开发内容
- [X] WebSocket测试脚本客户端
- [X] Session 和中间层管理模块
- [X] 常驻服务脚本
- [X] 一些常用的通用 API 例如经济(用户积分、亲密度等)的模块
- [ ] 图灵机器人/腾讯AI 聊天模块
- [ ] 分词模块(可能会放弃计划,因为目前好用的分词都是其他语言的)
- [ ] HTTP 过滤器、Auth 模块、完整的 MVC 兼容(可能会放弃计划,因为框架主打机器人开发)
- [ ] Redis 连接池或开箱即用的相应功能内置
- [X] 1.3 版本使用上下文代替
- [X] 更好的 Logger稳定和漂亮的控制台输出
- [ ] 日志服务
- [X] 框架支持 Phar 打包(可能会比较靠后支持)
- [ ] 完整的单元测试(如果有需求则尽快开发)
- [X] 静态文件服务器
## 从 cqbot-swoole 升级
目前新的框架采用了全新的注解机制,所以旧版的框架上写的模块到新框架需要重新编写。当然为了减少工作量,新的框架也最大限度地保留了旧版框架编写的风格,一般情况下根据新版框架的文档仅需修改少量地方即可完成重写。
旧版框架并入了 `old` 分支,如果想继续使用旧版框架请移步分支。升级过程中如果遇到问题可以找作者。
- 原生支持多个机器人客户端同时连接
- 灵活的注解事件绑定机制,可同时使用 Annotation 和原生 Attribute 注解
- 完善的插件系统,可编写插件后打包或分发,供他人使用
- 采用插件化编写,可自由搭配其他 Composer 组件,也可单文件面向过程编写
- 支持模块打包、热加载,分享模块更方便
- 常驻内存,全局缓存变量随处使用,提供多种缓存方案
- 自带 MySQL、SQLite、Redis 等数据库连接池
- 本身为 HTTP 服务器、WebSocket 服务器,可以构建属于自己的 HTTP API 接口
- 可选自带 PHP 环境无需手动编译安装by [crazywhalecc/static-php-cli](https://github.com/crazywhalecc/static-php-cli)
## 贡献和捐赠
如果你在使用过程中发现任何问题,可以提交 Issue 或自行 Fork 后修改并提交 Pull Request。目前项目仅一人维护耗费精力较大所以非常欢迎对框架的贡献。
如果你在使用过程中发现任何问题,可以提交 Issue 或自行 Fork 后修改并提交 Pull Request。
目前项目仅两人维护,耗费精力较大,所以非常欢迎对框架的贡献。
本项目为作者闲暇时间开发,如果觉得好用,不妨进行捐助~你的捐助会让我更加有动力完善插件,感谢你的支持!
我们会将捐赠的资金用于本项目驱动的炸毛机器人和框架文档的服务器开销上。
我们会将捐赠的资金用于本项目驱动的炸毛机器人和框架文档的服务器开销上。[捐赠列表](https://github.com/zhamao-robot/thanks)
如果您不想直接参与框架的开发,也可以分享你编写的模块,帮助完善框架生态。
### 支付宝
![支付宝二维码](/resources/images/alipay_img.jpg)
![支付宝二维码](https://cdn.jsdelivr.net/gh/zhamao-robot/zhamao-framework/resources/images/alipay_img.jpg)
## 关于
框架和 SDK 是 炸毛机器人 项目的核心框架开源部分。炸毛机器人3276124472是作者写的一个高性能机器人曾获全国计算机设计大赛一等奖。
欢迎随时在 HTTP-API 插件群里提问,当然更好的话可以加作者 QQ627577391或提交 Issue 进行疑难解答
框架和 SDK 是 炸毛机器人 项目的核心框架开源部分。炸毛机器人是作者写的一个高性能机器人,曾获全国计算机设计大赛一等奖
本项目在更新内容时,请及时关注 GitHub 动态,更新前请将自己的模块代码做好备份
作者的炸毛机器人已从2018年初起稳定运行了**五年**,并且持续迭代
项目框架采用 Apache-2.0 协议开源,在分发或重写修改等操作时需遵守协议。项目模块部分(`Module` 文件夹) 在非借鉴框架内代码时可不遵守 Apache-2.0 协议进行分发和修改(声明版权)。
可以提交 [Issue](https://github.com/zhamao-robot/zhamao-framework/issues/new/choose) 或 [加群(670821194)](https://jq.qq.com/?_wv=1027&k=YkNI3AIr) 进行疑难解答。
本项目在更新内容时,请及时关注 GitHub 动态,更新前请将自己的插件或项目代码做好备份。
项目框架采用 Apache-2.0 协议开源,在分发或重写修改等操作时需遵守协议。项目插件部分(除 `src/Globals``src/ZM` 文件夹外的其他文件夹) 在非借鉴框架内代码时可不遵守 Apache-2.0 协议进行分发和修改(声明版权)。
**注意**:在你使用 mirai 等 `AGPL-3.0` 协议的机器人软件与框架连接时,使用本框架需要将你编写或修改的部分使用 `AGPL-3.0` 协议重新分发。
在贡献代码时,请保管好自己的全局配置文件中的敏感信息,请勿将带有个人信息的配置文件上传 GitHub 等网站。
感谢 JetBrains 为此开源项目提供 PhpStorm 开发工具支持:
<img src="https://resources.jetbrains.com/storage/products/company/brand/logos/PhpStorm.svg" width="300">
感谢开发者 @sunxyw 中为项目开发规范化提出的一些建议。
![star](https://starchart.cc/zhamao-robot/zhamao-framework.svg)

View File

@@ -1,13 +0,0 @@
# Security Policy
## Supported Versions
| Version | Supported |
| ------- | ------------------ |
| 1.2.x | :white_check_mark: |
| 1.1.x | :x: |
| 1.0.x | :x: |
## Reporting a Vulnerability
If you find a bug which is safety related, you should post a new issue named **Security Issue**, and I will check it as soon as possible.

View File

@@ -1,60 +0,0 @@
#!/usr/bin/env php
<?php /** @since 1.2.1 */
global $version;
echo "version: " . ($version = json_decode(file_get_contents(__DIR__ . "/../composer.json"), true)["version"]) . PHP_EOL;
switch ($argv[1] ?? '') {
case '--normal':
case '':
build();
break;
case '--help':
case '-h':
default:
echo "\nzhamao-framework Phar builder.\n";
echo "\nUsage: " . $argv[0] . " [OPTION]";
echo "\n\n -h, --help\t\tShow this help menu";
echo "\n --with-wechat-patch\tReplace ModBase with wechat patch version and build your own phar package";
echo "\n --normal\t\tBuild your own phar package as normal options\n\n";
break;
}
function build($with_wechat_patch = false) {
if (ini_get('phar.readonly') == 1) {
die("You need to set \"phar.readonly\" to \"Off\"!\nSee: https://stackoverflow.com/questions/34667606/cant-enable-phar-writing\n");
}
$filename = "server.phar";
@unlink(__DIR__ . '/../resources/' . $filename);
$phar = new Phar(__DIR__ . '/../resources/' . $filename);
$phar->startBuffering();
$src = realpath(__DIR__ . '/../');
$hello = file_get_contents($src . '/src/Module/Example/Hello.php');
$middleware = file_get_contents($src . '/src/Module/Middleware/TimerMiddleware.php');
unlink($src . '/src/Module/Example/Hello.php');
unlink($src . '/src/Module/Middleware/TimerMiddleware.php');
if ($with_wechat_patch) {
global $wechat_patch;
$wechat = base64_decode($wechat_patch);
} else {
$wechat = false;
}
if ($wechat !== false) {
echo "Using wechat patch.\n";
$modbase = file_get_contents($src . '/src/ZM/ModBase.php');
unlink($src . '/src/ZM/ModBase.php');
}
$phar->buildFromDirectory($src);
$phar->addFromString('tmp/Hello.php.bak', $hello);
$phar->addFromString('tmp/TimerMiddleware.php.bak', $middleware);
if ($wechat !== false) {
$phar->addFromString('src/ZM/ModBase.php', $wechat);
file_put_contents($src . '/src/ZM/ModBase.php', $modbase);
}
//$phar->compressFiles(Phar::GZ);
$phar->setStub($phar->createDefaultStub('phar-starter.php'));
$phar->stopBuffering();
file_put_contents($src . '/src/Module/Example/Hello.php', $hello);
file_put_contents($src . '/src/Module/Middleware/TimerMiddleware.php', $middleware);
echo "Successfully built. Location: " . $src . "/resources/$filename\n";
}

65
bin/phpunit-zm Executable file
View File

@@ -0,0 +1,65 @@
#!/usr/bin/env php
<?php
/** For Swoole coroutine tests */
// 如果改成 true则会在终端显示所有炸毛框架的 Log
const ZM_TEST_LOG_DEBUG = false;
use OneBot\Driver\Event\Process\WorkerStartEvent;
use PHPUnit\TextUI\Command;
use Swoole\Atomic;
use Tests\ZMResultPrinter;
use ZM\Command\Server\ServerStartCommand;
use ZM\Event\EventProvider;
use ZM\Framework;
use ZM\Logger\ConsoleLogger;
use ZM\Store\MockAtomic;
// 引入自动加载
require $_composer_autoload_path ?? dirname(__DIR__) . '/vendor/autoload.php';
// 声明一个全局的原子计数,用于保存整个进程的退出状态码
global $_swoole_atomic;
// Windows 没有 Swoole所以就使用了一个假的原子计数器反正 Windows 只有单进程
$_swoole_atomic = class_exists('\\Swoole\\Atomic') ? new Atomic() : new MockAtomic();
// 注册 Logger 等级
ob_logger_register(new ConsoleLogger(ZM_TEST_LOG_DEBUG ? 'debug' : 'error'));
// 使用框架自身的 EventProvider
global $ob_event_provider;
$ob_event_provider = new EventProvider();
// 注册一个最低级别的 WorkerStart 事件,用于在框架的事件初始化之后开始运行 PHPUnit
ob_event_provider()->addEventListener(WorkerStartEvent::getName(), function () {
register_shutdown_function(function () {
$error = error_get_last();
// 下面这段代码的作用就是,不是错误引发的退出时照常退出即可
if (($error['type'] ?? 0) != 0) {
logger()->emergency(zm_internal_errcode('E00027') . 'Internal fatal error: ' . $error['message'] . ' at ' . $error['file'] . "({$error['line']})");
}
Framework::getInstance()->stop();
});
$_SERVER['argv'][] = '--printer';
$_SERVER['argv'][] = ZMResultPrinter::class;
try {
// 不退出,而是返回 code
$retcode = Command::main(false);
} finally {
global $_swoole_atomic;
$_swoole_atomic->set($retcode ?? 0);
Framework::getInstance()->stop($retcode ?? 0);
}
}, 1);
try {
$options = ServerStartCommand::exportOptionArray();
$options['driver'] = 'workerman';
$options['worker-num'] = 1;
$options['private-mode'] = true;
(new Framework($options))->init()->start();
exit($_swoole_atomic->get());
} catch (Throwable $e) {
echo $e->getMessage() . PHP_EOL;
exit(1);
}

3
bin/phpunit-zm.bat Normal file
View File

@@ -0,0 +1,3 @@
@echo off
php %~dp0phpunit-zm %*

76
bin/prepare-doxygen Executable file
View File

@@ -0,0 +1,76 @@
#!/usr/bin/env php
<?php
function find_valid_root(string $current_dir, int $max_loop): string
{
if ($max_loop <= 0) {
return '';
}
if (!file_exists($current_dir . '/composer.json')) {
return find_valid_root(dirname($current_dir), $max_loop - 1);
}
return $current_dir;
}
$root = find_valid_root(getcwd(), 3);
if (empty($root)) {
echo '找不到有效的根目录';
exit(1);
}
chdir($root);
require_once $root . '/vendor/autoload.php';
// 获取参数,可为 before 或 after
$param = $argv[1] ?? 'before';
if ($param === 'before') {
// Doxyfile file source: https://pastebin.com/raw/N8tJ9kWE
// Posted by: sunxyw
// 从剪贴板获取 Doxyfile 内容并保存到临时文件
logger()->info('正在获取 Doxyfile 内容');
$doxyfile = file_get_contents('https://pastebin.com/raw/N8tJ9kWE');
$doxyfile = str_replace('<zm_version>', \ZM\Framework::VERSION, $doxyfile);
file_put_contents('Doxyfile', $doxyfile);
// 应用 Awesome 样式
// 来源https://github.com/jothepro/doxygen-awesome-css.git
// 优先使用本地文件
logger()->info('正在应用 Awesome 样式');
\ZM\Store\FileSystem::createDir('doxy/css');
if (
file_exists('doxy/css/doxygen-awesome.css') &&
(md5_file('doxy/css/doxygen-awesome.css') === '326a1447f9693d1b3876f59de837a7c0')
) {
logger()->info('本地 Awesome 样式文件已存在,跳过下载');
} else {
logger()->info('正在下载 Awesome 样式文件');
$cmd = [
'git clone https://github.com/jothepro/doxygen-awesome-css.git doxy/css',
'cd doxy/css',
'git checkout v2.1.0',
'cd ../..',
];
$cmd = implode(' && ', $cmd);
exec($cmd);
}
} elseif ($param === 'after') {
// 删除临时文件
unlink('Doxyfile');
// 清除旧文档
exec('rm -rf docs/.vuepress/public/doxy');
// 授予目录权限doxy/html
exec('sudo chmod -R 644 doxy/html');
// 移动新文档到 docs 目录
exec('mv doxy/html docs/.vuepress/public/doxy');
logger()->info('文档生成完成');
} else {
logger()->error('参数错误');
exit(1);
}

135
bin/start
View File

@@ -1,135 +0,0 @@
#!/usr/bin/env php
<?php
use Framework\FrameworkLoader;
use Scheduler\Scheduler;
require __DIR__ . '/../src/Framework/FrameworkLoader.php';
require __DIR__ . '/../src/Scheduler/Scheduler.php';
Swoole\Coroutine::set([
'max_coroutine' => 30000,
]);
global $vendor_mode;
$vendor_mode = false;
if (mb_strpos(__DIR__, getcwd()) !== false && substr(str_replace(getcwd(), "", __DIR__), 0, 8) == "/vendor/") {
define("LOAD_MODE", 1); //composer项目模式
define("LOAD_MODE_COMPOSER_PATH", getcwd());
} else {
define("LOAD_MODE", 0); //正常模式
}
date_default_timezone_set("Asia/Shanghai");
switch ($argv[1] ?? '') {
case 'scheduler':
case 'timer':
go(function () {
try {
new Scheduler(Scheduler::REMOTE);
} catch (Exception $e) {
die($e->getMessage());
}
});
break;
case 'phar-build':
array_shift($argv);
require_once 'phar-build';
break;
case 'systemd':
array_shift($argv);
require_once 'systemd';
break;
case 'init':
array_shift($argv);
if (LOAD_MODE != 1) {
echo "initialization must be started with composer-project mode!\n";
exit(1);
}
$cwd = LOAD_MODE_COMPOSER_PATH;
echo "Copying default module file ...";
@mkdir($cwd . "/config");
@mkdir($cwd . "/src");
@mkdir($cwd . "/src/Custom");
@mkdir($cwd . "/src/Module");
@mkdir($cwd . "/src/Module/Example");
@mkdir($cwd . "/src/Module/Middleware");
$ls = [
"/config/global.php",
"/.gitignore",
"/config/file_header.json",
"/config/motd.txt",
"/src/Module/Example/Hello.php",
"/src/Module/Middleware/TimerMiddleware.php",
"/src/Custom/global_function.php"
];
foreach($ls as $v) {
if(!file_exists($cwd.$v)) {
echo "Copying ".$v.PHP_EOL;
copy($cwd."/vendor/zhamao/framework".$v, $cwd.$v);
}
}
$autoload = [
"psr-4" => [
"Module\\" => "src/Module",
"Custom\\" => "src/Custom"
],
"files" => [
"src/Custom/global_function.php"
]
];
$scripts = [
"server" => "vendor/bin/start server",
"server:log-debug" => "vendor/bin/start server --log-debug",
"server:log-verbose" => "vendor/bin/start server --log-verbose",
"server:log-info" => "vendor/bin/start server --log-info",
"server:log-warning" => "vendor/bin/start server --log-warning",
"server:debug-mode" => "vendor/bin/start server --debug-mode",
"systemd" => "vendor/bin/start systemd"
];
echo PHP_EOL;
if (file_exists($cwd . "/composer.json")) {
echo "Updating composer.json ...";
$composer = json_decode(file_get_contents($cwd . "/composer.json"), true);
if (!isset($composer["autoload"])) {
$composer["autoload"] = $autoload;
}
if (!isset($composer["scripts"])) {
$composer["scripts"] = $scripts;
}
file_put_contents($cwd . "/composer.json", json_encode($composer, 64 | 128 | 256));
echo PHP_EOL;
} else {
echo("Error occurred. Please check your updates.\n");
exit(1);
}
echo "success!\n";
break;
case '':
case 'framework':
case 'server':
if (!is_dir(__DIR__ . '/../vendor/') && LOAD_MODE == 0) {
echo "Warning: you have not update composer!\n";
exec("composer update", $out, $var);
if ($var != 0) {
echo "You need to run \"composer update\" at root of zhamao-framework!\n";
die;
}
}
$loader = new FrameworkLoader($argv);
break;
case '--help':
case '-h':
echo "\nUsage: " . $argv[0] . " [OPTION]\n";
echo "\nzhamao-framework start script, provides several startup arguments.";
echo "\n\n -h, --help\t\tShow this help menu";
echo "\n framework, server\tstart main framework, this is default option";
echo "\n phar-build\t\tbuild a new phar archive";
echo "\n init\t\t\tinitialize framework structure in this directory";
echo "\n systemd\t\tgenerate a new systemd \".service\" file to use\n\n";
break;
default:
echo "Unknown option \"{$argv[1]}\"!\n\"--help\" for more information\n";
break;
}

View File

@@ -1,31 +0,0 @@
#!/usr/bin/env php
<?php /** @since 1.2 */
switch ($argv[1] ?? '') {
case '--generate':
case '':
generate($argv);
break;
case '--help':
case '-h':
default:
echo "\nUsage: " . $argv[0] . " [OPTION]\n";
echo "\nzhamao-framework systemd generator.";
echo "\n\n -h, --help\t\tShow this help menu";
echo "\n --generate\tGenerate a systemd service file\n\n";
break;
}
function generate($argv) {
$s = "[Unit]\nDescription=zhamao-framework Daemon\nAfter=rc-local.service\n\n[Service]\nType=simple";
$s .= "\nUser=" . exec("whoami");
$s .= "\nGroup=" . exec("groups | awk '{print $1}'");
$s .= "\nWorkingDirectory=" . getcwd();
if ($argv[0] == "systemd" && !file_exists(getcwd() . '/systemd'))
$s .= "\nExecStart=" . getcwd() . "/vendor/bin/start server --disable-console-input";
else
$s .= "\nExecStart=" . getcwd() . "/bin/start server --disable-console-input";
$s .= "\nRestart=always\n\n[Install]\nWantedBy=multi-user.target\n";
@mkdir(getcwd() . "/resources/");
file_put_contents(getcwd() . "/resources/zhamao.service", $s);
echo "File successfully generated. Path: " . getcwd() . "/resources/zhamao.service\n";
}

118
bin/watcher Executable file
View File

@@ -0,0 +1,118 @@
#!/usr/bin/env bash
_red="\e[33m"
_green="\e[32m"
_reset="\e[0m"
unix_s=$(uname -s)
unix_release=$(
marked_release=""
if [ "$unix_s" = "Linux" ]; then
echo $HOME | grep com.termux >/dev/null
if [ $? == 0 ]; then
marked_release="termux"
elif [ -f "/etc/redhat-release" ]; then
if [ "$(cat /etc/redhat-release | awk '{print $1}' | grep -v '^$')" = "CentOS" ]; then
marked_release="CentOS"
else
marked_release="unknown"
fi
elif [ -f "/etc/os-release" ]; then
cat /etc/os-release | grep Alpine > /dev/null
if [ $? == 0 ]; then
marked_release="Alpine"
fi
fi
if [ "$marked_release" = "" ]; then
if [ -f "/etc/issue" ]; then
marked_release=$(cat /etc/issue | grep -v '^$' | awk '{print $1}')
else
marked_release="unknown"
fi
fi
elif [ "$unix_s" = "Darwin" ]; then
marked_release=$(sw_vers | grep ProductName | awk '{print $2" "$3" "$4}')
fi
echo $marked_release
)
unix_release=$(echo $unix_release | xargs)
function echo_error() {
echo -e "${_red}$1${_reset}"
}
function echo_info() {
echo -e "${_green}$1${_reset}"
}
function install_test() {
which fswatch >/dev/null
if [ $? != 0 ]; then
operate_confirm "fswatch还没有安装是否确认安装" && install_fswatch
fi
}
function install_fswatch() {
if [ "$unix_s" = "Linux" ]; then
case $unix_release in
"Kali" | "Ubuntu" | "Debian" | "Raspbian" | 'Pop!_OS')
sudo apt-get install fswatch -y ;;
#"termux") pkg install $1 -y ;;
"CentOS")
curl -o fswatch.tgz https://download.fastgit.org/emcrisostomo/fswatch/releases/download/1.16.0/fswatch-1.16.0.tar.gz && \
tar -xzf fswatch.tgz && \
cd fswatch-1.16.0 && \
./configure && \
make && \
sudo make install && \
cd .. && \
rm -rf fswatch.tgz fswatch-1.16.0
;;
#"Alpine") apk add $1 ;;
*)
echo_error "不支持的 Linux 发行版:$unix_release"
exit 1
;;
esac
elif [ "$unix_s" = "Darwin" ]; then
brew install fswatch
else
echo_error "不支持的操作系统:$unix_s"
exit 1
fi
}
function operate_confirm() {
echo -n $(echo_info "$1 [Y/n] ")
read operate
operate=$(echo $operate | tr A-Z a-z)
if [[ "$operate" = "y" || "$operate" = "" ]]; then
return 0
else
return 1
fi
}
echo_info "当前系统:$unix_release"
install_test
if [ $? -ne 0 ]; then
exit 1
else
echo_info "程序路径:$(which fswatch)"
fi
watch_dir="./src"
if [ ! -d "$watch_dir" ]; then
echo_error "src目录不存在"
exit 1
else
echo_info "监听目录:$watch_dir"
fi
_pid=$(cat .daemon_pid | awk -F"\"pid\": " '{print $2}' | grep -v ^$ | sed 's/,//g')
if [ "$_pid" = "" ]; then
echo_error "未检测到框架进程"
exit 1
fi
fswatch $watch_dir | while read file
do
echo "Detect file change: $file"
kill -USR1 $_pid
done

31
bin/zhamao Executable file
View File

@@ -0,0 +1,31 @@
#!/bin/sh
# shellcheck disable=SC2068
# shellcheck disable=SC2181
# author: crazywhalecc
# since: 2.5.0
if [ "$ZM_CUSTOM_PHP_PATH" != "" ]; then
echo "* Using PHP executable: ""$ZM_CUSTOM_PHP_PATH"
executable="$ZM_CUSTOM_PHP_PATH"
elif [ -f "$(pwd)/runtime/php" ]; then
executable="$(pwd)/runtime/php"
echo "* Framework started with built-in php."
else
which php >/dev/null 2>&1
if [ $? -eq 0 ]; then
executable=$(which php)
else
echo '[ErrCode:E00014] Cannot find any PHP runtime, please use command "./install-runtime.sh" or install PHP manually!'
exit 1
fi
fi
if [ -f "$(pwd)/src/entry.php" ]; then
$executable "$(pwd)/src/entry.php" $@
elif [ -f "$(pwd)/vendor/zhamao/framework/src/entry.php" ]; then
$executable "$(pwd)/vendor/zhamao/framework/src/entry.php" $@
else
echo "[ErrCode:E00015] Cannot find zhamao-framework entry file!"
exit 1
fi

27
bin/zhamao.bat Normal file
View File

@@ -0,0 +1,27 @@
@echo off
@REM Check if ZM_CUSTOM_PHP_PATH is set
IF /i "%ZM_CUSTOM_PHP_PATH%" neq "" (
@REM Set the path to the custom PHP
echo "* Using custom PHP executable: %ZM_CUSTOM_PHP_PATH%"
SET executable=%ZM_CUSTOM_PHP_PATH%
) ELSE IF exist ./runtime/php.exe (
@REM Set the path to the built-in PHP
echo "* Using built-in PHP executable"
SET executable=.\runtime\php.exe
) ELSE (
@REM Set the path to the system PHP
echo "* Using system PHP executable"
SET executable=php
)
IF exist src/entry.php (
@REM Run the PHP entry point
%executable% src/entry.php %*
) ELSE IF exist vendor/zhamao/framework/src/entry.php (
@REM Run the PHP entry point
%executable% vendor/zhamao/framework/src/entry.php %*
) ELSE (
@REM No entry point found
echo "[ErrCode:E00015] Cannot find zhamao-framework entry file!"
exit /b 1
)

47
captainhook.json Normal file
View File

@@ -0,0 +1,47 @@
{
"pre-push": {
"enabled": true,
"actions": [
{
"action": "composer analyse"
},
{
"action": "composer test"
}
]
},
"pre-commit": {
"enabled": true,
"actions": [
{
"action": "composer cs-fix -- --config=.php-cs-fixer.php --dry-run --diff {$STAGED_FILES|of-type:php}",
"conditions": [
{
"exec": "\\CaptainHook\\App\\Hook\\Condition\\FileStaged\\OfType",
"args": ["php"]
}
]
}
]
},
"post-change": {
"enabled": true,
"actions": [
{
"action": "composer install",
"options": [],
"conditions": [
{
"exec": "\\CaptainHook\\App\\Hook\\Condition\\FileChanged\\Any",
"args": [
[
"composer.json",
"composer.lock"
]
]
}
]
}
]
}
}

View File

@@ -1,41 +1,103 @@
{
"name": "zhamao/framework",
"description": "High performance QQ robot and web server development framework",
"minimum-stability": "stable",
"description": "High performance chat robot and web server development framework",
"license": "Apache-2.0",
"version": "1.6",
"authors": [
{
"name": "whale",
"email": "crazysnowcc@gmail.com"
"name": "jerry",
"email": "admin@zhamao.me"
},
{
"name": "swift",
"email": "hugo_swift@yahoo.com"
"name": "sunxyw",
"email": "dev@sunxyw.xyz"
}
],
"prefer-stable": true,
"bin": [
"bin/start"
],
"require": {
"php": ">=7.2",
"swoole/ide-helper": "@dev",
"ext-mbstring": "*",
"swlib/saber": "^1.0",
"doctrine/annotations": "~1.10",
"php": "^8.0 || ^8.1 || ^8.2",
"ext-json": "*",
"ext-posix": "*",
"ext-ctype": "*",
"ext-pdo": "*",
"psy/psysh": "@stable"
"ext-tokenizer": "*",
"doctrine/dbal": "^2.13.1",
"dragonmantank/cron-expression": "^3.3",
"jelix/version": "^2.0",
"koriym/attributes": "^1.0",
"nunomaduro/collision": "^6.3",
"onebot/libonebot": "^0.5",
"php-di/php-di": "^7",
"psr/container": "^2.0",
"psr/simple-cache": "^3.0",
"psy/psysh": "^0.11.8",
"symfony/console": "^6.0",
"symfony/polyfill-ctype": "^1.19",
"symfony/polyfill-mbstring": "^1.19",
"symfony/routing": "~6.0 || ~5.0 || ~4.0"
},
"require-dev": {
"captainhook/captainhook": "^5.12",
"friendsofphp/php-cs-fixer": "^3.2 != 3.7.0",
"jangregor/phpstan-prophecy": "^1.0",
"jetbrains/phpstorm-attributes": "^1.0",
"mikey179/vfsstream": "^1.6",
"phpspec/prophecy-phpunit": "^2.0",
"phpstan/extension-installer": "^1.1",
"phpstan/phpstan": "^1.1",
"phpstan/phpstan-deprecation-rules": "^1.0",
"phpstan/phpstan-phpunit": "^1.1",
"phpunit/phpunit": "^8.5 || ^9.0",
"roave/security-advisories": "dev-latest",
"swoole/ide-helper": "^4.5"
},
"replace": {
"symfony/polyfill-php80": "*"
},
"suggest": {
"ext-ctype": "Use C/C++ extension instead of polyfill will be more efficient",
"ext-mbstring": "Use C/C++ extension instead of polyfill will be more efficient",
"ext-pdo_mysql": "If you use mysql in framework, you will need this extension",
"ext-redis": "If you use Redis in framework, you will need this extension",
"league/climate": "Display columns and status in terminal"
},
"minimum-stability": "dev",
"prefer-stable": true,
"autoload": {
"psr-4": {
"Custom\\": "src/Custom",
"Framework\\": "src/Framework",
"ZM\\": "src/ZM",
"Module\\": "src/Module"
"ZM\\": "src/ZM"
},
"files": [
"src/Globals/global_functions.php",
"src/Globals/global_defines_app.php",
"src/Globals/global_class_alias.php"
]
},
"autoload-dev": {
"psr-4": {
"Module\\": "src/Module",
"Tests\\": "tests"
}
},
"bin": [
"bin/phpunit-zm",
"bin/zhamao",
"bin/zhamao.bat"
],
"config": {
"allow-plugins": {
"phpstan/extension-installer": true
},
"optimize-autoloader": true,
"sort-packages": true
},
"extra": {
"zm": {
"exclude-annotation-path": [
"src/ZM",
"tests"
]
}
},
"scripts": {
"post-autoload-dump": "vendor/bin/captainhook install -f -s",
"analyse": "phpstan analyse --memory-limit 300M",
"cs-fix": "PHP_CS_FIXER_FUTURE_MODE=1 php-cs-fixer fix",
"test": "bin/phpunit-zm --no-coverage"
}
}

28
config/config.php Normal file
View File

@@ -0,0 +1,28 @@
<?php
declare(strict_types=1);
/**
* Config 配置类的配置文件
* 由于 Config 类是第一批被加载的类,因此本文件存在以下限制:
* 1. 只能使用 PHP 格式
* 2. 无法利用容器及依赖注入
* 3. 必须存在于本地,无法使用远程配置(后续版本可能会支持)
*/
return [
'repository' => [
\OneBot\Config\Repository::class, // 配置仓库,须实现 \OneBot\Config\RepositoryInterface 接口
[], // 传入的参数,依序传入构造函数
],
'loader' => [
\OneBot\Config\Loader\DelegateLoader::class, // 配置加载器,须实现 \OneBot\Config\LoaderInterface 接口
[], // 传入的参数,依序传入构造函数
],
'source' => [
'extensions' => ['php', 'yaml', 'yml', 'json', 'toml'], // 配置文件扩展名
'paths' => [
SOURCE_ROOT_DIR . '/config', // 配置文件所在目录
// 可以添加多个配置文件目录
],
],
];

29
config/console_color.json Normal file
View File

@@ -0,0 +1,29 @@
{
"default": {
"success": "green",
"info": "lightblue",
"warning": "yellow",
"error": "red",
"verbose": "blue",
"debug": "gray",
"trace": "gray"
},
"white-term": {
"success": "green",
"info": "",
"warning": "yellow",
"error": "red",
"verbose": "blue",
"debug": "gray",
"trace": "gray"
},
"no-color": {
"success": "",
"info": "",
"warning": "",
"error": "",
"verbose": "",
"debug": "",
"trace": ""
}
}

28
config/container.php Normal file
View File

@@ -0,0 +1,28 @@
<?php
declare(strict_types=1);
use OneBot\Driver\Driver;
use OneBot\Driver\Process\ProcessManager;
use Psr\Log\LoggerInterface;
use ZM\Framework;
/*
* 这里是容器的配置文件,你可以在这里配置容器的绑定和其他一些参数。
* 选用的容器是 PHP-DI你可以在这里查看文档https://php-di.org/doc/
* 我们建议你在使用容器前先阅读以下章节:
* - 基本使用方式https://php-di.org/doc/container.html
* - 注册绑定方式https://php-di.org/doc/php-definitions.html#definition-types
* - 最佳使用实践https://php-di.org/doc/best-practices.html
* 同时,你也可以选择查阅我们(炸毛框架)的相关文档,其会包含一些简单的使用方法和示例。
* 关于框架在不同事件(或周期中)默认注册的绑定,请参阅我们的文档,或直接查看 {@see \ZM\Container\ContainerRegistrant}
*/
return [
// 这里定义的是全局容器的绑定,不建议在此处直接调用框架、应用内部的类或方法,因为这些类可能还没有被加载或初始化
// 你可以使用匿名函数来延迟加载
'definitions' => [
'worker_id' => fn () => ProcessManager::getProcessId(),
Driver::class => fn () => Framework::getInstance()->getDriver(),
LoggerInterface::class => fn () => logger(),
],
];

View File

@@ -1,94 +1,125 @@
<?php
global $config;
/** bind host */
$config['host'] = '0.0.0.0';
declare(strict_types=1);
/** bind port */
$config['port'] = 20001;
/* 启动框架的底层驱动(原生支持 swoole、workerman 两种) */
$config['driver'] = 'workerman';
/** 框架开到公网或外部的HTTP访问链接通过 DataProvider::getFrameworkLink() 获取 */
$config['http_reverse_link'] = "http://127.0.0.1:".$config['port'];
/** 框架是否启动debug模式 */
$config['debug_mode'] = false;
/** 存放框架内文件数据的目录 */
$config['zm_data'] = realpath(__DIR__ . "/../").'/zm_data/';
/** 存放各个模块配置文件的目录 */
$config['config_dir'] = $config['zm_data'].'config/';
/** 存放崩溃和运行日志的目录 */
$config['crash_dir'] = $config['zm_data'].'crash/';
/** 对应swoole的server->set参数 */
$config['swoole'] = [
'log_file' => $config['crash_dir'].'swoole_error.log',
'worker_num' => 1,
'dispatch_mode' => 2,
//'task_worker_num' => 1,
//'task_enable_coroutine' => true
];
/** MySQL数据库连接信息host留空则启动时不创建sql连接池 */
$config['sql_config'] = [
'sql_host' => '',
'sql_port' => 3306,
'sql_username' => 'name',
'sql_database' => 'db_name',
'sql_password' => '',
'sql_enable_cache' => true,
'sql_reset_cache' => '0300',
'sql_options' => [
PDO::ATTR_STRINGIFY_FETCHES => false,
PDO::ATTR_EMULATE_PREPARES => false
/* 要启动的服务器监听端口及协议 */
$config['servers'] = [
[
'host' => '0.0.0.0',
'port' => 20001,
'type' => 'websocket',
],
[
'host' => '0.0.0.0',
'port' => 20002,
'type' => 'http',
'flag' => 20002,
],
'sql_no_exception' => false,
'sql_default_fetch_mode' => PDO::FETCH_BOTH // added in 1.5.6
];
/** CQHTTP连接约定的token */
$config["access_token"] = "";
/** HTTP服务器固定请求头的返回 */
$config['http_header'] = [
'X-Powered-By' => 'zhamao-framework',
'Content-Type' => 'text/html; charset=utf-8'
/* Workerman 驱动相关配置 */
$config['workerman_options'] = [
'worker_num' => 1, // 如果你只有一个 OneBot 实例连接到框架并且代码没有复杂的CPU密集计算则可把这里改为1使用全局变量
];
/** HTTP服务器在指定状态码下回复的页面默认 */
$config['http_default_code_page'] = [
'404' => '404.html'
/* Swoole 驱动相关配置 */
$config['swoole_options'] = [
'coroutine_hook_flags' => SWOOLE_HOOK_ALL & (~SWOOLE_HOOK_CURL), // 协程 Hook 内容
'swoole_set' => [
'worker_num' => 1, // 如果你只有一个 OneBot 实例连接到框架并且代码没有复杂的CPU密集计算则可把这里改为1使用全局变量
'dispatch_mode' => 2, // 包分配原则,见 https://wiki.swoole.com/#/server/setting?id=dispatch_mode
'max_coroutine' => 300000, // 允许最大的协程数
'max_wait_time' => 5, // 安全退出模式下允许等待 Worker 的最长秒数
// 'task_worker_num' => 4, // 启动 TaskWorker 进程的数量(默认不启动)
// 'task_enable_coroutine' => true // TaskWorker 是否开启协程
],
'swoole_server_mode' => SWOOLE_PROCESS, // Swoole Server 启动模式,默认为 SWOOLE_PROCESS
];
/** zhamao-framework在框架启动时初始化的atomic们 */
$config['init_atomics'] = [
'in_count' => 0, //消息接收message的统计数量
'out_count' => 0, //消息发送调用send_*_msg的统计数量
'reload_time' => 0, //调用reload功能统计数量
'wait_msg_id' => 0, //协程挂起id自增
'info_level' => 2, //终端显示的log等级
/* 默认存取炸毛数据的目录相对目录时代表WORKING_DIR下的目录绝对目录按照绝对目录来 */
$config['data_dir'] = WORKING_DIR . '/zm_data';
/* 框架本体运行时的一些可调配置 */
$config['runtime'] = [
'reload_delay_time' => 800,
'annotation_reader_ignore' => [ // 设置注解解析器忽略的注解名或命名空间,防止解析到不该解析的
'name' => [
'mixin',
],
'namespace' => [],
],
'timezone' => 'Asia/Shanghai',
];
/** 自动保存的缓存保存时间(秒) */
$config['auto_save_interval'] = 900;
/** 上下文接口类 implemented from ContextInterface */
/* 上下文接口类 implemented from ContextInterface */
$config['context_class'] = \ZM\Context\Context::class;
/** 静态文件访问 */
$config['static_file_server'] = [
'status' => false,
'document_root' => realpath(__DIR__ . "/../") . '/resources/html',
'document_index' => [
'index.html'
]
/* 允许加载插件形式 */
$config['plugin'] = [
'enable' => true,
'load_dir' => 'plugins',
];
/** 注册 Swoole Server 事件注解的类列表 */
$config['server_event_handler_class'] = [
\Framework\ServerEventHandler::class, //默认不可删除,否则会不能使用框架
/* 内部默认启用的插件 */
$config['native_plugin'] = [
'onebot12' => true, // OneBot v12 协议支持
'onebot12-ban-other-ws' => true, // OneBot v12 协议支持,禁止其他 WebSocket 连接
'command-manual' => true,
];
/* 静态文件读取器 */
$config['file_server'] = [
'enable' => true,
'document_root' => $config['data_dir'] . '/public/',
'document_index' => 'index.html',
'document_code_page' => [
'404' => '404.html',
'500' => '500.html',
],
];
/* MySQL 和 SQLite3 数据库连接配置,框架将自动生成连接池,支持多个连接池 */
$config['database'] = [
'sqlite_db1' => [
'enable' => false,
'type' => 'sqlite',
'dbname' => 'a.db',
'pool_size' => 10,
],
'default' => [
'enable' => false,
'type' => 'mysql',
'host' => '127.0.0.1', // 填写数据库服务器地址后才会创建数据库连接
'port' => 3306,
'username' => 'root',
'password' => 'ZhamaoTEST',
'dbname' => 'zm',
'charset' => 'utf8mb4',
'pool_size' => 64,
],
];
/* Redis 连接配置,框架将自动生成连接池,支持多个连接池 */
$config['redis'] = [
'default' => [
'enable' => false,
'host' => '127.0.0.1',
'port' => 6379,
'index' => 0,
'auth' => '',
'pool_size' => 10,
],
];
/* KV 数据库的配置 */
$config['kv'] = [
'use' => \LightCache::class, // 默认在单进程模式下使用 LightCache多进程需要使用 ZMRedis
'light_cache_dir' => $config['data_dir'] . '/lc', // 默认的 LightCache 保存持久化数据的位置
'light_cache_autosave_time' => 600, // LightCache 自动保存时间(秒)
'redis_config' => 'default',
];
return $config;

152
config/global_old.php Normal file
View File

@@ -0,0 +1,152 @@
<?php
/** @noinspection PhpComposerExtensionStubsInspection */
declare(strict_types=1);
/* bind host */
$config['host'] = '0.0.0.0';
/* bind port */
$config['port'] = 20001;
/* 框架开到公网或外部的HTTP访问链接通过 DataProvider::getFrameworkLink() 获取 */
$config['http_reverse_link'] = 'http://127.0.0.1:' . $config['port'];
/* 框架是否启动debug模式当debug模式为true时启用热更新需要安装inotify扩展 */
$config['debug_mode'] = false;
/* 存放框架内文件数据的目录 */
$config['zm_data'] = realpath(WORKING_DIR) . '/zm_data/';
/* 存放各个模块配置文件的目录 */
$config['config_dir'] = $config['zm_data'] . 'config/';
/* 存放崩溃和运行日志的目录 */
$config['crash_dir'] = $config['zm_data'] . 'crash/';
/* 对应swoole的server->set参数 */
$config['swoole'] = [
'log_file' => $config['crash_dir'] . 'swoole_error.log',
// 'worker_num' => swoole_cpu_num(), //如果你只有一个 OneBot 实例连接到框架并且代码没有复杂的CPU密集计算则可把这里改为1使用全局变量
'dispatch_mode' => 2, // 包分配原则,见 https://wiki.swoole.com/#/server/setting?id=dispatch_mode
'max_coroutine' => 300000,
'max_wait_time' => 5,
// 'task_worker_num' => 4,
// 'task_enable_coroutine' => true
];
/* 一些框架与框架运行时设置的调整 */
$config['runtime'] = [
'swoole_coroutine_hook_flags' => SWOOLE_HOOK_ALL & (~SWOOLE_HOOK_CURL),
'swoole_server_mode' => SWOOLE_PROCESS,
'middleware_error_policy' => 1,
'reload_delay_time' => 800,
'global_middleware_binding' => [],
'save_console_log_file' => false, // 改为目标路径,则将 Console 输出的日志保存到文件
'annotation_reader_ignore' => [ // 设置注解解析器忽略的注解名或命名空间,防止解析到不该解析的
'name' => [
'mixin',
],
'namespace' => [],
],
];
/* 轻量字符串缓存,默认开启 */
$config['light_cache'] = [
'size' => 512, // 最多允许储存的条数需要2的倍数
'max_strlen' => 32768, // 单行字符串最大长度需要2的倍数
'hash_conflict_proportion' => 0.6, // Hash冲突率越大越好但是需要的内存更多
'persistence_path' => $config['zm_data'] . '_cache.json',
'auto_save_interval' => 900,
];
/* 大容量跨进程变量存储2.2.0可用) */
$config['worker_cache'] = [
'worker' => 0,
'transaction_timeout' => 30000,
];
/* MySQL数据库连接信息host留空则启动时不创建sql连接池 */
$config['mysql_config'] = [
'host' => '',
'port' => 3306,
'unix_socket' => null,
'username' => 'root',
'password' => '123456',
'dbname' => '',
'charset' => 'utf8mb4',
'pool_size' => 64,
'options' => [
PDO::ATTR_STRINGIFY_FETCHES => false,
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
],
];
/* Redis连接信息host留空则启动时不创建Redis连接池 */
$config['redis_config'] = [
'host' => '',
'port' => 6379,
'timeout' => 1,
'db_index' => 0,
'auth' => '',
];
/* onebot连接约定的token */
$config['access_token'] = '';
/* HTTP服务器固定请求头的返回 */
$config['http_header'] = [
'Server' => 'zhamao-framework',
'Content-Type' => 'text/html; charset=utf-8',
];
/* HTTP服务器在指定状态码下回复的页面默认 */
$config['http_default_code_page'] = [
'404' => '404.html',
];
/* zhamao-framework在框架启动时初始化的atomic们 */
$config['init_atomics'] = [
// 'custom_atomic_name' => 0, //自定义添加的Atomic
];
/* 终端日志显示等级0-4 */
$config['info_level'] = 2;
/* 上下文接口类 implemented from ContextInterface */
$config['context_class'] = \ZM\Context\Context::class;
/* 静态文件访问 */
$config['static_file_server'] = [
'status' => false,
'document_root' => realpath(__DIR__ . '/../') . '/resources/html',
'document_index' => [
'index.html',
],
];
/* 机器人解析模块关闭后无法使用如CQCommand等注解(上面的modules即将废弃) */
$config['onebot'] = [
'status' => true,
'single_bot_mode' => false,
'message_level' => 99,
'message_convert_string' => true,
'message_command_policy' => 'interrupt',
];
/* 一个远程简易终端使用nc直接连接即可但是不建议开放host为0.0.0.0(远程连接) */
$config['remote_terminal'] = [
'status' => false,
'host' => '127.0.0.1',
'port' => 20002,
'token' => '',
];
/* 模块(插件)加载器的相关设置 */
$config['module_loader'] = [
'enable_hotload' => false,
'load_path' => $config['zm_data'] . 'modules',
];
return $config;

View File

@@ -1,6 +1,6 @@
______
|__ / |__ __ _ _ __ ___ __ _ ___
/ /| '_ \ / _` | '_ ` _ \ / _` |/ _ \
/ /_| | | | (_| | | | | | | (_| | (_) |
/____|_| |_|\__,_|_| |_| |_|\__,_|\___/
______
|__ / |__ __ _ _ __ ___ __ _ ___
/ /| '_ \ / _` | '_ ` _ \ / _` |/ _ \
/ /_| | | | (_| | | | | | | (_| | (_) |
/____|_| |_|\__,_|_| |_| |_|\__,_|\___/

96
docker-compose.yml Normal file
View File

@@ -0,0 +1,96 @@
version: "3.9"
services:
bot:
build:
context: docker/zhamao
dockerfile: ./Dockerfile
container_name: zhamao-bot
depends_on:
- database-postgres
- database-redis
networks:
- bot-net
ports:
- "20001-20005:20001-20005/tcp"
volumes:
- ".:/bot"
walle-q:
build:
context: docker/walle-q
dockerfile: ./Dockerfile
container_name: zhamao-bot-walle-q
depends_on:
- bot
networks:
- bot-net
volumes:
- "./docker/volumes/walle-q-data:/bot"
database-postgres:
container_name: zhamao-bot-db-postgres
env_file:
- docker/environment.env
image: postgres:14.4-alpine
networks:
- bot-net
ports:
- "5432:5432/tcp"
restart: always
volumes:
- "./docker/volumes/postgres-data:/var/lib/postgresql/data"
- "./docker/volumes/postgres-init:/docker-entrypoint-initdb.d"
database-redis:
command:
- redis-server
- --requirepass
- "$${REDIS_PASSWORD}"
container_name: zhamao-bot-db-redis
env_file:
- docker/environment.env
image: redis:7.0-alpine
networks:
- bot-net
ports:
- "6379:6379/tcp"
restart: always
volumes:
- "./docker/volumes/redis-data:/data"
db-admin-adminer:
container_name: zhamao-bot-dbadmin-adminer
depends_on:
database-postgres:
condition: service_started
database-redis:
condition: service_started
env_file:
- docker/environment.env
image: adminer:latest
networks:
- bot-net
ports:
- "15432:8080/tcp"
profiles:
- with-adminer
db-admin-redis-insight:
container_name: zhamao-bot-dbadmin-redis-insight
depends_on:
database-postgres:
condition: service_started
database-redis:
condition: service_started
image: redislabs/redisinsight:latest
networks:
- bot-net
ports:
- "16379:8001/tcp"
profiles:
- with-adminer
networks:
bot-net:
name: bot-net

2
docker/.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
/volumes
environment.env

View File

@@ -0,0 +1,7 @@
REDIS_PASSWORD={{$REDIS_PASSWORD}}
POSTGRES_USER={{$DB_ROOT_USER}}
POSTGRES_PASSWORD={{$DB_ROOT_PASSWORD}}
POSTGRES_APPLICATION_USER={{$DB_USER}}
POSTGRES_APPLICATION_USER_PASSWORD={{$DB_PASSWORD}}
POSTGRES_APPLICATION_DATABASE={{$DB_NAME}}

14
docker/walle-q/Dockerfile Normal file
View File

@@ -0,0 +1,14 @@
FROM alpine:latest
MAINTAINER sunxyw <me@sunxyw.xyz>
RUN apk add --no-cache curl
RUN mkdir -p /bot && \
curl -fsSL https://github.com/onebot-walle/walle-q/releases/latest/download/walle-q-i686-linux-musl.tar.gz -O && \
tar -zxvf walle-q-i686-linux-musl.tar.gz -C /bot && \
rm -rf walle-q-i686-linux-musl.tar.gz && \
chmod +x /bot/walle-q-i686-linux-musl
ENV TZ=Asia/Shanghai
ENTRYPOINT [ "/bot/walle-q-i686-linux-musl" ]

14
docker/zhamao/Dockerfile Normal file
View File

@@ -0,0 +1,14 @@
FROM phpswoole/swoole:5.0-php8.1
MAINTAINER sunxyw <me@sunxyw.xyz>
WORKDIR "/bot"
ENV TZ=Asia/Shanghai
EXPOSE 20001-20005
RUN docker-php-ext-install pcntl
ENTRYPOINT [ "./zhamao" ]
CMD [ "server" ]

View File

@@ -1,18 +0,0 @@
FROM richardchien/cqhttp:latest
RUN apt-get update && apt-get install -y software-properties-common tzdata
RUN dpkg-reconfigure -f noninteractive tzdata
RUN add-apt-repository ppa:ondrej/php && \
apt-get update && \
apt-get install php php-dev php-mbstring gcc make openssl \
php-mbstring php-json php-curl php-mysql -y && \
apt-get install wget composer -y && \
wget https://github.com/swoole/swoole-src/archive/v4.5.0.tar.gz && \
tar -zxvf v4.5.0.tar.gz && \
cd swoole-src-4.5.0/ && \
phpize && ./configure --enable-openssl --enable-mysqlnd && make -j2 && make install && \
(echo "extension=swoole.so" >> $(php -i | grep "Loaded Configuration File" | awk '{print $5}'))
ADD start.sh /home/user/start.sh
RUN chown user:user /home/user/start.sh && chmod +x /home/user/start.sh
ADD https://github.com/zhamao-robot/zhamao-framework/archive/master.zip /home/user/master.zip
RUN chown user:user /home/user/master.zip && chmod 777 /home/user/master.zip
VOLUME ["/home/user/coolq","/home/user/zhamao-framework"]

View File

@@ -1,6 +0,0 @@
#!/bin/bash
unzip master.zip
mv zhamao-framework-master/* zhamao-framework/
cd zhamao-framework
php bin/start

View File

@@ -0,0 +1,141 @@
<template>
<div class="doc-chat-container">
<div class="doc-chat-content">
<div v-for="i in chat" v-bind="i">
<div class="doc-chat-row" v-if="i.type === 0">
<div class="doc-chat-box">{{ i.content }}</div>
<img class="doc-chat-avatar" src="https://api.btstu.cn/sjtx/api.php" alt=""/>
</div>
<div class="doc-chat-row doc-chat-row-robot" v-else-if="i.type === 1">
<img class="doc-chat-avatar" src="https://docs-v1.zhamao.xin/logo.png" alt=""/>
<div class="doc-chat-box doc-chat-box-robot">
<span v-for="(p,index) in i.content.split('\n')">{{p}}<br v-if="index !== i.content.length - 1"></span>
</div>
</div>
<div class="doc-chat-row doc-chat-banner" v-else-if="i.type === 2">
{{ i.content }}
</div>
<div class="doc-chat-row doc-chat-row-robot" v-else-if="i.type === 3">
<img class="doc-chat-avatar" src="https://docs-v1.zhamao.xin/logo.png" alt=""/>
<div class="doc-chat-box doc-chat-box-robot">
<img :src="i.content" alt="" />
</div>
</div>
</div>
</div>
</div>
</template>
<!--
type:
0: 我方发送消息
1: 机器人回复消息
2: 显示一个横幅系统消息
3: 机器人回复一个图片
-->
<script>
export default {
name: "ChatBox",
props: ['myChats'],
data() {
return {
chat: this.myChats,
multiline: ''
}
}
}
</script>
<style scoped>
.doc-chat-content {
padding: 12px;
}
.doc-chat-container {
border-radius: 6px;
max-width: 550px;
min-height: 30px;
/*noinspection CssUnresolvedCustomProperty*/
background-color: #f2f4f5;
margin-bottom: 1em;
box-shadow: 0 3px 1px -2px rgba(0,0,0,.2), 0 2px 2px 0 rgba(0,0,0,.14), 0 1px 5px 0 rgba(0,0,0,.12);
}
.doc-chat-row {
margin: 0;
display: flex;
flex-wrap: wrap;
flex: 1 1 auto;
justify-content: flex-end;
}
.doc-chat-banner {
justify-content: center;
background: rgba(0,0,0,0.1);
width: max-content;
margin: 8px auto;
padding: 4px 14px;
border-radius: 8px;
color: gray;
font-size: 14px;
}
.doc-chat-row-robot {
justify-content: flex-start !important;
}
.doc-chat-box {
color: #000000de;
position: relative;
width: fit-content;
max-width: 55%;
border-radius: .5rem;
padding: .4rem .6rem;
margin: .4rem .8rem;
background-color: #fff;
line-height: 1.5;
font-size: 16px;
outline: none;
overflow-wrap: break-word;
white-space: normal;
box-shadow: 0 2px 12px 0 rgba(0,0,0,.1);
}
.doc-chat-box:after {
content: "";
position: absolute;
right: auto;
top: 0;
width: 8px;
height: 12px;
color: #fff;
border: 0 solid transparent;
border-bottom: 7px solid;
border-radius: 0 0 8px 0;
left: calc(100% - 4px);
box-sizing: inherit;
}
.doc-chat-box-robot:after {
content: "";
position: absolute;
right: calc(100% - 4px);
top: 0;
width: 8px;
height: 12px;
color: #fff;
border: 0 solid transparent;
border-bottom: 7px solid;
border-radius: 0 0 0 8px;
left: auto;
box-sizing: inherit;
}
.doc-chat-avatar {
background-color: aquamarine;
width: 36px !important;
height: 36px !important;
border-radius: 18px;
}
</style>

65
docs/.vuepress/config.js Normal file
View File

@@ -0,0 +1,65 @@
module.exports = {
title: '炸毛框架 v3',
description: '一个高性能聊天机器人 + Web 框架',
theme: 'antdocs',
markdown: {
lineNumbers: true
},
head: [
['link', { rel: 'icon', href: '/logo_trans.png' }],
['script', {}, `
var _hmt = _hmt || [];
(function () {
var hm = document.createElement("script");
hm.src = "https://hm.baidu.com/hm.js?f0f276cefa10aa31a20ae3815a50b795";
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(hm, s);
})();
`]
],
themeConfig: {
repo: 'zhamao-robot/zhamao-framework',
logo: '/logo_trans.png',
docsDir: 'docs',
editLinks: true,
lastUpdated: '上次更新',
activeHeaderLinks: false,
nav: [
{ text: '指南', link: '/guide/' },
{ text: '事件', link: '/event/' },
{ text: 'API 文档', link: '/doxy/', target: '_blank' },
{ text: '炸毛框架 v2', link: 'https://docs-v2.zhamao.xin/' }
],
sidebar: {
'/guide/': [
{
title: '指南',
collapsable: false,
sidebarDepth: 1,
children: [
'',
'installation',
'configuration',
'structure',
'get_started',
]
}
],
'/event/': [
{
title: '事件',
collapsable: false,
sidebarDepth: 1,
children: [
'',
'bot',
'http',
'middleware',
'framework',
'extend',
]
}
]
}
}
}

View File

@@ -0,0 +1 @@
framework.zhamao.me

Binary file not shown.

After

Width:  |  Height:  |  Size: 449 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 61 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

View File

@@ -0,0 +1 @@
User-agent: *

View File

@@ -0,0 +1 @@
@accentColor: #3665aa;

1
docs/CNAME Normal file
View File

@@ -0,0 +1 @@
docs-v2.zhamao.me

44
docs/README.md Normal file
View File

@@ -0,0 +1,44 @@
---
home: true
heroImage: ./logo_trans.png
actions:
- text: 快速上手
link: /guide/
type: primary
size: large
- text: 快速上手v2 旧版)
link: https://docs-v2.zhamao.xin/
type: primary
ghost: true
size: large
features:
- 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>
---
# 快速上手
## 安装框架和环境
此命令可一键以模板安装框架!(仅限 Linux 和 macOS
```bash
bash <(curl -fsSL https://zhamao.xin/v3.sh)
```
## 运行框架
```bash
cd zhamao-app/
./zhamao server
```
## 效果图
![index_demo](/index_demo.png)

25
docs/event/README.md Normal file
View File

@@ -0,0 +1,25 @@
# 入门
## 事件是什么
简单来说,事件是一个底层的 Event Loop 收到消息后调用对应的方法的一个模型,比如给机器人发送消息后框架会调用你定义的方法来执行你的业务代码。
## 属性和注解是什么
属性Attribute是 PHP 8 最大的新变化之一,是 PHP 官方支持的、内置的注解实现,允许我们通过编程方式获取对应的元数据,可以大大方便我们对某一类代码进行处理。
而注解Annotation则是在 PHP 尚未支持属性的时代,用来代替的社区实现方案,通过解析 PHPDoc 注释来实现自己的注解机制。
炸毛框架同时支持注解和属性,在文档当中,有时会混用两者的字眼,在大多数情况下都可以安全地交换使用,例如 `#[BotEvent]``@BotEvent` 的行为是完全一致的。
## 注解和事件的关系
在炸毛框架中,注解是事件分发的一个重要角色,但注解本身并非事件,更恰当地说,注解代表了事件。
无论是机器人开发过程中场景的 `#[BotCommand]` 或是 HTTP 服务的路由 `#[RequestMapping]` 都是注解代表事件的例子。
## 阻断事件分发
在炸毛框架中,事件由一个统一的事件分发器进行分发,你可以在任意事件中阻断所有后续的分发。
(待考)

86
docs/event/bot.md Normal file
View File

@@ -0,0 +1,86 @@
# 机器人事件
<aside>
🛰️ 此页面下的所有注解命名空间为 `ZM\Annotation\OneBot`
</aside>
> 在使用注解绑定事件时,如果不存在 **必需** 参数,可一个参数都不写,效果就是此事件在任何情况下都会调用此方法,例如 `#[BotEvent()]` 会在收到任意机器人事件时调用。
>
## BotAction
啊?
| 参数名称 | 允许值 | 用途 | 默认 |
| --- | --- | --- | --- |
| action | string | 动作名称 | “” |
| need_response | string | 动作是否需要响应 | false |
| level | int | 事件优先级(越大越先执行) | 20 |
## BotActionResponse
啊??
| 参数名称 | 允许值 | 用途 | 默认 |
| --- | --- | --- | --- |
| retcode | int | 响应码 | null |
| level | int | 事件优先级(越大越先执行) | 20 |
## BotEvent
用于处理所有的机器人事件,具体的参数含义可以参见 [https://12.onebot.dev/connect/data-protocol/event/](https://12.onebot.dev/connect/data-protocol/event/)。
| 参数名称 | 允许值 | 用途 | 默认 |
| --- | --- | --- | --- |
| type | string | 对应标准中的事件类型 | null |
| detail_type | string | 对应标准中的事件详细类型 | null |
| sub_type | string | 对应标准中的事件子类型 | null |
| level | int | 事件优先级(越大越先执行) | 20 |
## BotCommand
对于 `BotEvent` 的封装,用于支持常用的命令式调用(如:”天气 深圳”)。
| 参数名称 | 允许值 | 用途 | 默认 |
| --- | --- | --- | --- |
| name | string | 命令名称,应全局唯一 | “” |
| match | string | 匹配第一个词的命令式消息,如 天气 北京 中的 天气 | “” |
| pattern | string | 根据 * 号通配符进行模式匹配用户消息,如 查询*天气 | “” |
| regex | string 合法的正则表达式 | 匹配正则表达式匹配到的用户消息 | “” |
| start_with | string | 匹配消息开头相匹配的消息,如 我叫炸毛,这里写 我叫 | “” |
| end_with | string | 匹配消息结尾相匹配的消息,以 start_with 类推 | “” |
| keyword | string | 匹配消息中有相关关键词的消息 | “” |
| alias | string | match 匹配到命令的别名,数组形式 | [] |
| detail_type | string | 限定消息事件的详细类型,见 BotEvent | “” |
| prefix | string | | |
| level | int | 事件优先级(越大越先执行) | 20 |
> 机器人命令注册的实例可参见【一堆例子链接】
>
## CommandArgument
与 BotCommand 搭配使用,可以自动识别参数及生成帮助。
| 参数名称 | 允许值 | 用途 | 默认 |
| --- | --- | --- | --- |
| name | string | 参数名称 | “” |
| description | string | 参数描述 | “” |
| required | bool | 参数是否必需 | false |
| prompt | string | 当参数缺失时请求用户输入时提示的消息(需要参数设为必需) | “请输入{$name}” |
| default | mixed | 当参数非必需且未填入时的默认值 | null |
| timeout | int 单位秒 | 请求输入超时时间 | 60 |
## CommandHelp
与 BotCommand 搭配使用,可以补充生成的帮助信息。
| 参数名称 | 允许值 | 用途 | 默认 |
| --- | --- | --- | --- |
| description | string | 命令描述 | “” |
| usage | string | 命令用法 | “” |
| example | string | 命令示例 | “” |
> 关于自动帮助生成的更多信息,请参见 【这里链接】
>

3
docs/event/extend.md Normal file
View File

@@ -0,0 +1,3 @@
# 扩展事件分发器
TODO

31
docs/event/framework.md Normal file
View File

@@ -0,0 +1,31 @@
# 框架事件
<aside>
🛰️ 此页面下的所有注解命名空间为 `ZM\Annotation\Framework`
</aside>
## BindEvent
相对底层的事件绑定,支持绑定所有透过框架分发的事件。
| 参数名称 | 允许值 | 用途 | 默认 |
| --- | --- | --- | --- |
| event_class | string | 时间名 | 必填 |
| level | int | 事件优先级(越大越先执行) | 800 |
## Init
在 Worker 进程初始化时触发,用于进行 Worker 初始化。
| 参数名称 | 允许值 | 用途 | 默认 |
| --- | --- | --- | --- |
| worker | int 由 0 至 (最大Worker数-1) | 限定执行的 Worker 进程,-1 为在所有 Worker 执行 | 0 |
## Setup
在框架初始化时触发,在主进程执行,不可使用协程相关功能。
可用于改变所有进程的设置,相关更改会随着进程创建应用到所有 Worker 和 Manager 进程。
*没有参数*

25
docs/event/http.md Normal file
View File

@@ -0,0 +1,25 @@
# 路由事件
<aside>
🛰️ 此页面下的所有注解命名空间为 `ZM\Annotation\Http`
</aside>
## Controller
对同一类下的路由进行修饰,只可在类上使用。
| 参数名称 | 允许值 | 用途 | 默认 |
| --- | --- | --- | --- |
| prefix | string | 路由前缀,应用到类下的所有路由 | 必填 |
## Route
路由事件,当对应的路由收到请求时触发。
| 参数名称 | 允许值 | 用途 | 默认 |
| --- | --- | --- | --- |
| route | string | 路由 | 必填 |
| name | string | 路由名称 | “” |
| request_method | array<string> | 允许的请求方法 | [GET, POST] |
| params | array<string, string> | 路由参数 | [] |

18
docs/event/middleware.md Normal file
View File

@@ -0,0 +1,18 @@
# 中间件事件
<aside>
🛰️ 此页面下的所有注解命名空间为 `ZM\Annotation\Middleware`
</aside>
## Middleware
当绑定了此中间件的方法被触发时触发。
| 参数名称 | 允许值 | 用途 | 默认 |
| --- | --- | --- | --- |
| name | string | 中间件名称 | 必填 |
| params | array<mixed> | 中间件参数 | [] |
> 关于中间件的具体用法,请参见【再来链接】
>

26
docs/guide/README.md Normal file
View File

@@ -0,0 +1,26 @@
# 介绍
> 编写文档需要较大精力,你也可以参与到本文档的建设中来,比如找错字,增加或更正内容,每页文档可直接点击右上方铅笔图标直接跳转至 GitHub 进行编辑,编辑后自动 Fork 并生成 Pull Request以此来贡献此文档
炸毛框架主要面向聊天机器人OneBot 标准)和 API 服务的开发。
框架使用 PHP 编写,无需安装任何额外扩展即可运行在任意主流平台,支持包括 Swoole 和 Workerman 在内的多种驱动,同时支持所有在 OneBot 标准内的通信方式并支持使用注解Annotation和属性Attribute注册绑定各种事件同时引入了依赖注入容器让开发更为便捷。
框架内置了对于 WebSocket 和 HTTP 的服务端和客户端支持,并针对聊天机器人消息处理进行优化扩展,提供常用会话机制和内部调用机制,让代码更为灵活。
## 环境要求
虽然我们已经大力简化了运行框架的要求,但仍然存在少量的必要项:
- PHP 8.0 或以上版本(使用命令 `php -v` 检查)
- Tokenizer 扩展(使用命令 `php -m | grep tokenizer` 检查)
- Composer 工具(使用命令 `composer` 检查)
## 框架特色
- 支持MySQL数据库连接池自带查询缓存提高多查询时的效率
- WebSocket 服务器、HTTP 服务器兼容运行,一个框架多个用处
- 支持命令、自然语言处理等多种插件形式
- 支持多个机器人账号负载均衡
- 完善的插件系统,可以随意加载和编写独立的插件
- 灵活的注释和注解注册事件方式,支持 PHP 原生注解,提示更为友好

View File

@@ -0,0 +1,47 @@
# 配置
炸毛框架的所有配置文件都存储在 `config` 目录中。每个选项都带有文档,所以你可以查阅这些文件并熟悉可用的配置项。
一般来说,我们建议你优先查看 `config/global.php` 文件及其文档,它包含了运行框架所需要的绝大部分配置,例如通信方式和时区等。
## 配置文件格式
除了 `php` 文件外,我们还支持以下格式:
- YAML
- JSON
- TOML
## 环境配置
根据运行的环境采用不同的配置值是很有必要的,例如你可能希望在本地和生产环境中使用不同的数据库配置。
为了方便这一功能,我们提供了基于环境的配置加载措施。你可以在启动框架时使用 `--env` 选项指定当前环境,例如 `./zhamao server --env=production`
如果未明确指定当前环境,则默认环境为 `development`
如果要使某一配置文件只在特定环境下记载,你可以为给文件添加后缀,例如 `example.production.php` 只会在当前环境为 `production` 时加载。
你可以同时设置基础配置文件和环境特定配置文件,例如 `global.php``global.production.php` ,后者将会覆盖前者中的配置项。
### 配置安全
我们**非常不建议**你将数据库信息、访问密钥的敏感字段提交给版本控制,因为这可能会导致相关信息的泄露,同时也不利于其他开发人员修改自己的本地配置。
相反,我们建议你借助 DotEnv 等库,将相关配置信息写入 `.env` 文件中,并按需读取。
## 访问配置项
你可以在任何地方使用全局 `config` 函数获取配置项值。支持使用点语法获取,配置项名称由文件名开头,并允许指定默认值。
```php
# 获取时区,未设置则返回 Asia/Shanghai
$value = config('global.runtime.timezone', 'Asia/Shanghai');
```
你也可以使用 `config` 函数设置配置项,传递数组即可:
```php
# 将时区修改为 UTC
config(['global.runtime.timezone' => 'UTC']);
```

112
docs/guide/get_started.md Normal file
View File

@@ -0,0 +1,112 @@
# 快速上手
在这里,我们将会以一个基础的复读机为例,帮助你快速熟悉框架的开发流程。
在开始之前,你需要先准备一个可用的 OneBot 机器人实现端(客户端)。
其中一些可用的选项为:
- Walle-Q
- 更多…
## 机器人实现端
> 机器人实现端与炸毛框架相互独立。关于实现端本身的问题请向对应的开发者反馈。如果你确定相关问题由炸毛框架引起(例如缺少适配或代码问题等)请向我们报告。
框架支持多种通信方式,这里将以反向 WebSocket 为例,即框架充当 WS 服务端,实现端作为 WS 客户端连接到框架。
这里以 Walle-Q 实现端为例,在实际使用中,你可以自由选用不同的实现端。
你可以前往 Walle-Q 的 [发布页面](https://github.com/onebot-walle/walle-q/releases) 下载最新的发行版本,并运行以进行初始化。
在登录成功后,请关闭 Walle-Q 以修改配置文件。
首次运行后,将会在当前目录下生成 `walle-q.toml` 文件。在大多数场景下,这是你唯一需要接触的文件。
在于框架对接的情况中,我们只需要关注 `onebot.websocket_rev` 配置。
```toml
[onebot]
http = []
http_webhook = []
websocket = []
[[onebot.websocket_rev]]
url = "ws://127.0.0.1:20001" # 这里是框架的监听地址
reconnect_interval = 4
```
修改完成并保存后,重新启动 Walle-Q 并登录即可。如果出现连接失败也请勿惊慌,因为框架此时尚未启动,失败是正常现象。
有些情况可能无法正常扫码登录,可使用 QQ+密码 的方式登录,在最上方插入配置:
```toml
[qq.123456]
password = "MyPassword"
```
> 请将 123456 替换为你的机器人 QQ 号码MyPassword 替换为机器人 QQ 密码。
## 编写第一个功能
在框架中,几乎所有事件的绑定都是通过注解进行的,详情可以参阅 注解的使用。
让我们新建第一个插件,插件的功能很简单,就是复读。我们假设这个复读插件的名字是 `repeater`
```bash
./zhamao plugin:make
# 然后根据提示,创建,比如名字输入 repeater
# 选择类型的时候,输入 file
```
我们就可以在目录 `plugins/repeater/` 下得到两个文件,其中 `main.php` 代码可能如下:
```php
<?php
declare(strict_types=1);
$plugin = new ZMPlugin(__DIR__);
/*
* 发送 "测试repeater",回复 "这是repeater插件的第一个命令"
*/
$cmd1 = BotCommand::make('repeater', match: '测试repeater')->on(fn () => '这是repeater插件的第一个命令');
$plugin->addBotCommand($cmd1);
return $plugin;
```
然后根据复读的原理(简单重复一遍用户发的消息),将上方 `$cmd1` 替换为下面的指令:
```php
$cmd1 = BotCommand::make('repeater', match: '复读')->on(function(OneBotEvent $event, BotContext $ctx) {
$ctx->reply($event->getMessage());
});
```
此后,保存文件。
> 借助容器的依赖注入功能,我们可以直接指定相应的类,相关实例会在调用时自动传入。上方的 OneBotEvent 和 BotContext 可以自由选择位置。
## 启动框架
在保存了上述的代码后,你就可以通过 `./zhamao server` 启动框架了。
启动后Walle-Q 的日志应当会显示连接成功的信息。
此时,你可以通过任意账号向机器人发送 `复读 给我复读` 消息,机器人会回复 `复读 给我复读`
至此,你的第一个功能,复读机,也就开发完成了。
<chat-box :my-chats="[
{type:0,content:'复读 给我复读'},
{type:1,content:'复读 给我复读'},
]"></chat-box>
## 使用机器人 API 和更多事件
如果你希望机器人进行其他复杂的动作(操作),请参见 机器人 API。
关于更多可以注册绑定的事件,请参见 注解事件。

View File

@@ -0,0 +1,88 @@
# 安装
我们希望尽可能轻松地使用炸毛,不论是本地开发或是部署都提供多种选择,尽量覆盖所有需求。
- 一键脚本
- Docker
- Composer
## 一键脚本
炸毛框架提供了一键脚本来设置运行环境并拉取脚手架,帮助你快速进行开发。
如果检测到本机未安装 PHP 或不符合运行要求,脚本将会自动拉取提前编译好的静态 PHP 运行时。
```shell
# 将静态 PHP 和框架安装在当前目录(适用于 Linux、macOS
bash <(curl -fsSL https://zhamao.xin/v3.sh)
# 安装完成后启动
./zhamao server
```
> 关于静态运行时的更多用法,请参见 这里是链接
## Docker
待完善
## Composer
如果你已经有了必要的 PHP 环境和 Composer 工具,你可以直接在任意目录下初始化框架。
> 由于目前 3.0 仍处于预发布阶段,请使用 `composer require zhamao/framework:^3` 来安装
```shell
# 在当前目录初始化框架
composer require zhamao/framework
./vendor/bin/zhamao init
## 安装完成后启动
./zhamao server
## 生成新插件脚手架,用于开发
./zhamao plugin:make
```
## Windows 安装方法
由于 Windows 系统下的 PHP 环境配置较为复杂,我们推荐使用 Docker 或一键脚本来进行安装。
如果你打算在 Windows 使用原生的 Win 环境 PHP你需要先安装 PHP 和 Composer然后在任意目录下执行上方 composer 的安装方法即可。
### 包管理安装
Windows 也可以使用包管理安装 PHP、Composer例如你可以使用 Scoop 包管理进行安装:
```powershell
scoop install php
scoop install composer
```
采用这种包管理安装后,可直接使用 `php``composer` 命令在任意位置,无需配置环境变量。
如果你使用包管理或已经安装了 PHP 到系统内,接下来就直接使用 Composer 来安装框架即可!
```powershell
composer create-project zhamao/framework-starter zhamao-v3
cd zhamao-v3
./zhamao plugin:make
./zhamao server
```
### 纯手动安装
如果你不想使用包管理的方式安装 PHP且让 PHP 仅框架独立使用,你可以依次采用以下的方式来安装 PHP、Composer 和框架:
1. 从 GitHub 下载框架的脚手架,地址:<https://github.com/zhamao-robot/zhamao-framework-starter/archive/refs/heads/master.zip>
2. 解压框架脚手架,重命名文件夹名称为你自己喜欢的名称,例如 `zhamao-v3`
3. 从 PHP 官网下载 PHP选择 `Non Thread Safe` 版本PHP 版本选择 8.0 ~ 8.2 均可(推荐 8.1),下载完成后解压到框架目录下的 `runtime\php` 目录,例如 `D:\zhamao-v3\runtime\php\`
4. 从 [Composer 官网](https://getcomposer.org/download/) 或 [阿里云镜像](https://mirrors.aliyun.com/composer/composer.phar) 下载 Composer下载到 `runtime\` 目录。
5. 在你的脚手架目录下执行 `.\runtime\php\php.exe .\runtime\composer.phar install` 安装框架依赖。
6. 执行框架初始化命令:`./zhamao init`
7. 接下来你就可以使用和上方所有框架操作指令相同的内容了,例如 `./zhamao plugin:make``./zhamao server` 等。
8. 如果你需要使用 Composer你可以使用 `.\runtime\php\php.exe .\runtime\composer.phar` 来代替 `composer` 命令。
## 更多的环境部署和开发方式
除了上述方式之外,框架还支持源码模式、守护进程等运行方式,详情请参阅 [进阶开发]。

36
docs/guide/structure.md Normal file
View File

@@ -0,0 +1,36 @@
# 目录结构
## 用户目录
### config 目录
`config` 目录包含框架、应用的所有配置文件。最好把这些文件都浏览一遍,并熟悉所有可用的选项。
```
config/
├── global.php # 全局配置文件
├── container.php # 容器配置文件
└── motd.txt # 框架启动时展示的文字信息
```
### vendor 目录
`vendor` 目录包含你通过 Composer 安装的所有依赖,此目录为自动生成,无需操作。
### plugins 目录
`plugins` 目录包含你编写或加载到源代码模式的插件,里面的插件都会被框架自动扫描并解析,你可以在其中利用注解来注册事件绑定并进行相应处理。
比如你通过 `./zhamao plugin:make` 新建了一个名字叫 `test-app` 的插件,并且设置为单文件模式(`file`),那么这个插件内包含的文件及结构为:
```
plugins/
└── test-app/
├── main.php # 你的插件源代码文件
└── zmplugin.json # 插件元信息(如名称、版本等)
```
### zm_data 目录
`zm_data` 目录存放了框架运行时持久化保存的数据,例如 KV 数据库、驱动日志等内容。

34
ext/go-cqhttp-down.sh Normal file
View File

@@ -0,0 +1,34 @@
#!/bin/bash
echo "正在检查最新版本的go-cqhttp..."
if [ "$(uname -m)" = "x86_64" ]; then
arch_type="amd64"
elif [ "$(uname -m)" = "i386" ]; then
arch_type="386"
elif [ "$(uname -m)" = "aarch64" ]; then
arch_type="arm64"
else
echo "Not supported architecture: $(uname -m)"
exit 1
fi
aas=$(uname -s | tr 'A-Z' 'a-z')
ver=$(wget -qO- -t1 -T2 "https://fgit-api.zhamao.me/repos/Mrs4s/go-cqhttp/releases" | grep "tag_name" | head -n 1 | awk -F ":" '{print $2}' | sed 's/\"//g;s/,//g;s/ //g')
if [ "$ver" != "" ]; then
echo "最新版本:"$ver
echo -n "是否下载到本地?[y/N] "
read option
if [ "$option" = "y" ]; then
wget https://fgit.zhamao.me/Mrs4s/go-cqhttp/releases/download/$ver/go-cqhttp-$ver-$aas-$arch_type.tar.gz -O temp.tar.gz
if [ $? != 0 ]; then
wget https://fgit.zhamao.me/Mrs4s/go-cqhttp/releases/download/$ver/go-cqhttp_"$aas""_""$arch_type"".tar.gz" -O temp.tar.gz
fi
tar -zxvf temp.tar.gz go-cqhttp
rm temp.tar.gz
echo "下载完成,启动命令:./go-cqhttp"
echo "首次启动后先编辑config文件"
fi
fi

264
ext/go.sh Executable file
View File

@@ -0,0 +1,264 @@
#!/usr/bin/env bash
# 支持的环境变量:
# ZM_DOWN_PHP_VERSION php版本默认为8.0
# ZM_NO_LOCAL_PHP 如果填入任意内容则不检查本地PHP直接安装内建PHP仅限Linux
# ZM_TEMP_DIR 脚本下载内建PHP和Composer的临时目录默认为/tmp/.zm-runtime
# ZM_CUSTOM_DIR 自定义新建目录名称默认为zhamao-app
# ZM_COMPOSER_PACKAGIST 是否使用Composer的国外源默认使用国内阿里云如果设置并填写了内容则自动使用Composer的国外源
ZM_PWD=$(pwd)
_cyan="\033[0;36m"
_reset="\033[0m"
# 彩头
function nhead() {
if [ "$1" = "red" ]; then
echo -ne "\033[0;31m[!]"
elif [ "$1" = "yellow" ]; then
echo -ne "\033[0;33m[?]"
else
echo -ne "\033[0;32m[*]"
fi
echo -e "\033[0m"
}
# 下载文件 $1 到目录 $2自动选择使用 curl 或者 wget
function download_file() {
downloader="wget"
type wget >/dev/null 2>&1 || { downloader="curl"; }
if [ "$downloader" = "wget" ]; then
_down_prefix="O"
else
_down_prefix="o"
fi
_down_symbol=0
if [ ! -f "$2" ]; then
echo -ne "$(nhead) 正在下载 $1 ... "
$downloader "$1" -$_down_prefix "$2" >/dev/null 2>&1 && echo "完成!" && _down_symbol=1
else
echo "已存在!" && _down_symbol=1
fi
if [ $_down_symbol == 0 ]; then
echo "$(nhead red) 下载失败!请检查网络连接!"
rm -rf "$2"
return 1
fi
return 0
}
# 安装下载内建PHP
function install_native_php() {
ZM_PHP_VERSION="8.1"
if [ "$ZM_DOWN_PHP_VERSION" != "" ]; then
ZM_PHP_VERSION="$ZM_DOWN_PHP_VERSION"
fi
echo "$(nhead) 使用的内建 PHP 版本: $ZM_PHP_VERSION"
rm -rf "$ZM_TEMP_DIR"
mkdir "$ZM_TEMP_DIR" >/dev/null 2>&1
if [ ! -f "$ZM_TEMP_DIR/php" ]; then
download_file "https://dl.zhamao.xin/php-bin/down.php?php_ver=$ZM_PHP_VERSION&arch=$(uname -m)" "$ZM_TEMP_DIR/php.tgz" || return 1
tar -xf "$ZM_TEMP_DIR/php.tgz" -C "$ZM_TEMP_DIR/" && rm -rf "$ZM_TEMP_DIR/php.tgz"
fi
echo "$(nhead) 安装内建 PHP 完成!"
php_executable="$ZM_TEMP_DIR/php"
return 0
}
# 安装下载Composer
function install_native_composer() {
if [ ! -f "$ZM_TEMP_DIR/composer.phar" ]; then
# 下载 composer.phar
download_file "https://mirrors.aliyun.com/composer/composer.phar" "$ZM_TEMP_DIR/composer.phar" || return 1
if [ "$php_executable" = "$ZM_TEMP_DIR/php" ]; then
# shellcheck disable=SC2016
txt='#!/usr/bin/env sh
if [ -f "$(dirname $0)/php" ]; then
"$(dirname $0)/php" "$(dirname $0)/composer.phar" $*
else
php "$(dirname $0)/composer.phar" $*
fi'
echo "$txt" >"$ZM_TEMP_DIR/composer"
chmod +x "$ZM_TEMP_DIR/composer"
else
mv "$ZM_TEMP_DIR/composer.phar" "$ZM_TEMP_DIR/composer" && chmod +x "$ZM_TEMP_DIR/composer"
fi
fi
echo "$(nhead) 安装内建 Composer 完成!"
composer_executable="$ZM_TEMP_DIR/composer"
return 0
}
# 检查Composer可用性
function composer_check() {
# 顺带检查一下
echo "$(nhead) 正在检查 Git、unzip、7z 能否正常使用 ... "
type git >/dev/null 2>&1 || {
echo "$(nhead red) 检测到系统不存在 git 命令,可能无法正常使用 Composer 下载 GitHub 等仓库项目!"
}
zip_check_symbol=0
if type unzip >/dev/null 2>&1; then
zip_check_symbol=1
fi
if type 7z >/dev/null 2>&1; then
zip_check_symbol=1
fi
if [ $zip_check_symbol -eq 0 ]; then
if [ "$($php_executable -m | grep zip)" = "" ]; then
echo "$(nhead red) 检测到系统不存在 unzip 或 7z 命令PHP 不存在 zip 扩展,可能无法正常使用 Composer 下载压缩包项目!"
fi
fi
# 测试 Composer 和 PHP 是否能正常使用
if [ "$("$composer_executable" -n about | grep Manager)" = "" ]; then
echo "$(nhead red) Download PHP binary and composer failed!"
return 1
fi
echo "$(nhead) 环境检查完成!"
return 0
}
# 环境检查
function darwin_env_check() {
echo -ne "$(nhead) 检查是否存在 PHP ... "
if type php >/dev/null 2>&1; then
php_executable=$(which php)
echo "位置:$php_executable"
if [ "$($php_executable -m | grep swoole)" = "" ]; then
echo "$(nhead red) PHP 不存在 swoole 扩展,可能无法正常使用 Swoole 框架!" && return 1
fi
else
echo "不存在"
if type brew >/dev/null 2>&1; then
echo -n "$(nhead yellow) 是否使用 Homebrew 安装 PHP[y/N] "
read -r y
if [ "$y" = "" ]; then y="N"; fi
if [ "$y" = "y" ]; then
brew install php || echo "$(nhead red) 安装 PHP 失败!" && return 1
else
echo "$(nhead red) 跳过安装 PHP" && return 1
fi
fi
fi
echo -ne "$(nhead) 检查是否存在 Composer ... "
if type composer >/dev/null 2>&1; then
composer_executable=$(which composer)
echo "位置:$composer_executable"
else
echo "不存在,正在下载 Composer ..."
install_native_composer || return 1
fi
composer_check || return 1
}
# 询问是否安装 native php
function prompt_install_native_php() {
echo -ne "$(nhead yellow) 检测到系统的 PHP 不存在 swoole 扩展,是否下载安装独立的内建 PHP 和 Composer[Y/n] "
read -r y
case $y in
Y|y|"") return 0 ;;
*) echo "$(nhead red) 跳过安装内建 PHP" && return 1 ;;
esac
}
# 环境检查
function linux_env_check() {
if [ "$ZM_NO_LOCAL_PHP" != "" ]; then # 如果指定了不使用本地 php则不检查直接下载
install_native_php && install_native_composer && composer_check && return 0 || return 1
else
echo -ne "$(nhead) 检查是否存在 PHP ... "
if type php >/dev/null 2>&1; then
php_executable=$(which php)
echo "位置:$php_executable"
if [ "$($php_executable -m | grep swoole)" = "" ]; then
echo "$(nhead red) PHP 不存在 swoole 扩展,可能无法正常使用 Swoole 框架!" && \
prompt_install_native_php && \
install_native_php && \
install_native_composer && composer_check && return 0 || return 1
fi
else
echo "不存在,将下载内建 PHP"
install_native_php || return 1
fi
fi
echo -ne "$(nhead) 检查是否存在 Composer ... "
if type composer >/dev/null 2>&1; then
composer_executable=$(which composer)
echo "位置:$composer_executable"
else
echo "不存在,将下载内建 Composer"
install_native_composer || return 1
fi
composer_check || return 1
}
function if_use_aliyun() {
if [ "$ZM_COMPOSER_PACKAGIST" = "" ]; then
$composer_executable -n config repos.packagist composer https://mirrors.aliyun.com/composer
fi
}
function if_restore_native_runtime() {
ZM_RUNTIME_DIR="$ZM_PWD/$ZM_CUSTOM_DIR/runtime/"
if [ "$php_executable" = "$ZM_TEMP_DIR/php" ]; then
echo "$(nhead) 移动内建 PHP 到框架目录 $ZM_RUNTIME_DIR ..." && \
mkdir -p "$ZM_RUNTIME_DIR" && \
mv "$ZM_TEMP_DIR/php" "$ZM_RUNTIME_DIR" || {
echo "$(nhead red) 移动内建 PHP 到框架目录失败!" && return 1
}
php_executable="$ZM_RUNTIME_DIR/php"
fi
if [ "$composer_executable" = "$ZM_TEMP_DIR/composer" ]; then
echo "$(nhead) 移动内建 Composer 到框架目录 $ZM_RUNTIME_DIR ..." && \
mkdir -p "$ZM_CUSTOM_DIR/runtime" && \
mv "$ZM_TEMP_DIR/composer" "$ZM_RUNTIME_DIR" && \
mv "$ZM_TEMP_DIR/composer.phar" "$ZM_RUNTIME_DIR" || {
echo "$(nhead red) 移动内建 Composer 到框架目录失败!" && return 1
}
composer_executable="$ZM_RUNTIME_DIR/composer"
fi
return 0
}
function install_framework() {
echo "$(nhead) 开始安装框架到目录 $ZM_CUSTOM_DIR ..."
mkdir -p "$ZM_PWD/$ZM_CUSTOM_DIR" && \
cd "$ZM_PWD/$ZM_CUSTOM_DIR" && \
$composer_executable init --name="zhamao/framework-starter" -n -q && \
if_use_aliyun && \
echo "$(nhead) 从 Composer 拉取框架 ..." && \
$composer_executable require -n -q zhamao/framework:^2.7 && \
$composer_executable require -n -q --dev swoole/ide-helper:^4.5 && \
if_restore_native_runtime && \
echo "$(nhead) 初始化框架脚手架文件 ..." && \
vendor/bin/start init >/dev/null 2>&1 && \
$composer_executable dump-autoload -n -q && \
echo "$(nhead) 安装框架完成,已安装到目录 $ZM_CUSTOM_DIR" && \
echo -e "$(nhead) 启动框架命令:""$_cyan""cd $ZM_CUSTOM_DIR && ./zhamao server""$_reset" || {
echo "$(nhead red) 安装框架失败!" && return 1
}
}
# 环境变量设置
test "$ZM_TEMP_DIR" = "" && ZM_TEMP_DIR="/tmp/.zm-runtime"
test "$ZM_CUSTOM_DIR" = "" && ZM_CUSTOM_DIR="zhamao-app"
if [ -d "$ZM_PWD/$ZM_CUSTOM_DIR" ]; then
echo "$(nhead red) 检测到目录 $ZM_CUSTOM_DIR/ 已安装过框架,请更换文件夹名称或删除旧文件夹再试!"
exit 1
fi
# 检查系统环境,目前只支持 Linux
case $(uname -s) in
Linux) linux_env_check || exit 1 ;;
Darwin) darwin_env_check || exit 1 ;;
*) echo "$(nhead red) Only support Linux and macOS!" && exit 1 ;;
esac
# 安装框架
install_framework

278
ext/v3.sh Executable file
View File

@@ -0,0 +1,278 @@
#!/usr/bin/env bash
# 支持的环境变量:
# ZM_DOWN_PHP_VERSION php版本默认为8.0
# ZM_NO_LOCAL_PHP 如果填入任意内容则不检查本地PHP直接安装内建PHP仅限Linux
# ZM_TEMP_DIR 脚本下载内建PHP和Composer的临时目录默认为/tmp/.zm-runtime
# ZM_CUSTOM_DIR 自定义新建目录名称默认为zhamao-v3
# ZM_COMPOSER_PACKAGIST 是否使用Composer的国外源默认使用国内阿里云如果设置并填写了内容则自动使用Composer的国外源
ZM_PWD=$(pwd)
_cyan="\033[0;36m"
_reset="\033[0m"
# 彩头
function nhead() {
if [ "$1" = "red" ]; then
echo -ne "\033[0;31m[!]"
elif [ "$1" = "yellow" ]; then
echo -ne "\033[0;33m[?]"
else
echo -ne "\033[0;32m[*]"
fi
echo -e "\033[0m"
}
# 下载文件 $1 到目录 $2自动选择使用 curl 或者 wget
function download_file() {
downloader="wget"
type wget >/dev/null 2>&1 || { downloader="curl"; }
if [ "$downloader" = "wget" ]; then
_down_prefix="O"
else
_down_prefix="o"
fi
_down_symbol=0
if [ ! -f "$2" ]; then
echo -ne "$(nhead) 正在下载 $1 ... "
$downloader "$1" -$_down_prefix "$2" >/dev/null 2>&1 && echo "完成!" && _down_symbol=1
else
echo "已存在!" && _down_symbol=1
fi
if [ $_down_symbol == 0 ]; then
echo "$(nhead red) 下载失败!请检查网络连接!"
rm -rf "$2"
return 1
fi
return 0
}
# 安装下载内建PHP
function install_native_php() {
ZM_PHP_VERSION="8.1"
if [ "$ZM_DOWN_PHP_VERSION" != "" ]; then
ZM_PHP_VERSION="$ZM_DOWN_PHP_VERSION"
fi
echo "$(nhead) 使用的内建 PHP 版本: $ZM_PHP_VERSION"
rm -rf "$ZM_TEMP_DIR"
mkdir "$ZM_TEMP_DIR" >/dev/null 2>&1
if [ ! -f "$ZM_TEMP_DIR/php" ]; then
download_file "https://dl.zhamao.xin/php-bin/down.php?php_ver=$ZM_PHP_VERSION&arch=$(uname -m)" "$ZM_TEMP_DIR/php.tgz" || return 1
tar -xf "$ZM_TEMP_DIR/php.tgz" -C "$ZM_TEMP_DIR/" && rm -rf "$ZM_TEMP_DIR/php.tgz"
fi
echo "$(nhead) 安装内建 PHP 完成!"
php_executable="$ZM_TEMP_DIR/php"
return 0
}
# 安装下载Composer
function install_native_composer() {
if [ ! -f "$ZM_TEMP_DIR/composer.phar" ]; then
# 下载 composer.phar
download_file "https://mirrors.aliyun.com/composer/composer.phar" "$ZM_TEMP_DIR/composer.phar" || return 1
if [ "$php_executable" = "$ZM_TEMP_DIR/php" ]; then
# shellcheck disable=SC2016
txt='#!/usr/bin/env sh
if [ -f "$(dirname $0)/php" ]; then
"$(dirname $0)/php" "$(dirname $0)/composer.phar" $*
else
php "$(dirname $0)/composer.phar" $*
fi'
echo "$txt" >"$ZM_TEMP_DIR/composer"
chmod +x "$ZM_TEMP_DIR/composer"
else
mv "$ZM_TEMP_DIR/composer.phar" "$ZM_TEMP_DIR/composer" && chmod +x "$ZM_TEMP_DIR/composer"
fi
fi
echo "$(nhead) 安装内建 Composer 完成!"
composer_executable="$ZM_TEMP_DIR/composer"
return 0
}
# 检查Composer可用性
function composer_check() {
# 顺带检查一下
echo "$(nhead) 正在检查 Git、unzip、7z 能否正常使用 ... "
type git >/dev/null 2>&1 || {
echo "$(nhead red) 检测到系统不存在 git 命令,可能无法正常使用 Composer 下载 GitHub 等仓库项目!"
}
zip_check_symbol=0
if type unzip >/dev/null 2>&1; then
zip_check_symbol=1
fi
if type 7z >/dev/null 2>&1; then
zip_check_symbol=1
fi
if [ $zip_check_symbol -eq 0 ]; then
if [ "$($php_executable -m | grep zip)" = "" ]; then
echo "$(nhead red) 检测到系统不存在 unzip 或 7z 命令PHP 不存在 zip 扩展,可能无法正常使用 Composer 下载压缩包项目!"
fi
fi
# 测试 Composer 和 PHP 是否能正常使用
if [ "$("$composer_executable" -n about | grep Manager)" = "" ]; then
echo "$(nhead red) Download PHP binary and composer failed!"
return 1
fi
echo "$(nhead) 环境检查完成!"
return 0
}
# 环境检查
function darwin_env_check() {
echo -ne "$(nhead) 检查是否存在 PHP ... "
if type php >/dev/null 2>&1; then
php_executable=$(which php)
echo "位置:$php_executable"
if [ "$($php_executable -m | grep swoole)" = "" ]; then
echo "$(nhead red) PHP 不存在 swoole 扩展,可能无法正常使用 Swoole 框架!" && return 1
fi
else
echo "不存在"
if type brew >/dev/null 2>&1; then
echo -n "$(nhead yellow) 是否使用 Homebrew 安装 PHP[y/N] "
read -r y
if [ "$y" = "" ]; then y="N"; fi
if [ "$y" = "y" ]; then
brew install php || echo "$(nhead red) 安装 PHP 失败!" && return 1
else
echo "$(nhead red) 跳过安装 PHP" && return 1
fi
fi
fi
echo -ne "$(nhead) 检查是否存在 Composer ... "
if type composer >/dev/null 2>&1; then
composer_executable=$(which composer)
echo "位置:$composer_executable"
else
echo "不存在,正在下载 Composer ..."
install_native_composer || return 1
fi
composer_check || return 1
}
# 询问是否安装 native php
function prompt_install_native_php() {
echo -ne "$(nhead yellow) 检测到系统的 PHP 不符合要求,是否下载安装独立的内建 PHP 和 Composer[Y/n] "
read -r y
case $y in
Y|y|"") return 0 ;;
*) echo "$(nhead red) 跳过安装内建 PHP" && return 1 ;;
esac
}
# 环境检查
function linux_env_check() {
if [ "$ZM_NO_LOCAL_PHP" != "" ]; then # 如果指定了不使用本地 php则不检查直接下载
install_native_php && install_native_composer && composer_check && return 0 || return 1
else
echo -ne "$(nhead) 检查是否存在 PHP ... "
if type php >/dev/null 2>&1; then
php_executable=$(which php)
echo "位置:$php_executable"
ver_id=$($php_executable -r "echo PHP_VERSION_ID;")
if [ "$ver_id" -lt 80000 ]; then
echo "$(nhead red) PHP 版本过低,框架需要 PHP >= 8.0.0" && \
prompt_install_native_php && \
install_native_php && \
install_native_composer && composer_check && return 0 || return 1
fi
if [ "$($php_executable -m | grep tokenizer)" = "" ]; then
echo "$(nhead red) PHP 不存在 tokenizer 扩展,可能无法正常使用框架!" && \
prompt_install_native_php && \
install_native_php && \
install_native_composer && composer_check && return 0 || return 1
fi
else
echo "不存在,将下载内建 PHP"
install_native_php || return 1
fi
fi
echo -ne "$(nhead) 检查是否存在 Composer ... "
if type composer >/dev/null 2>&1; then
composer_executable=$(which composer)
echo "位置:$composer_executable"
else
echo "不存在,将下载内建 Composer"
install_native_composer || return 1
fi
composer_check || return 1
}
function if_use_aliyun() {
if [ "$ZM_COMPOSER_PACKAGIST" = "" ]; then
$composer_executable -n config repos.packagist composer https://mirrors.aliyun.com/composer
fi
}
function if_restore_native_runtime() {
ZM_RUNTIME_DIR="$ZM_PWD/$ZM_CUSTOM_DIR/runtime/"
if [ "$php_executable" = "$ZM_TEMP_DIR/php" ]; then
echo "$(nhead) 移动内建 PHP 到框架目录 $ZM_RUNTIME_DIR ..." && \
mkdir -p "$ZM_RUNTIME_DIR" && \
mv "$ZM_TEMP_DIR/php" "$ZM_RUNTIME_DIR" || {
echo "$(nhead red) 移动内建 PHP 到框架目录失败!" && return 1
}
php_executable="$ZM_RUNTIME_DIR/php"
fi
if [ "$composer_executable" = "$ZM_TEMP_DIR/composer" ]; then
echo "$(nhead) 移动内建 Composer 到框架目录 $ZM_RUNTIME_DIR ..." && \
mkdir -p "$ZM_CUSTOM_DIR/runtime" && \
mv "$ZM_TEMP_DIR/composer" "$ZM_RUNTIME_DIR" && \
mv "$ZM_TEMP_DIR/composer.phar" "$ZM_RUNTIME_DIR" || {
echo "$(nhead red) 移动内建 Composer 到框架目录失败!" && return 1
}
composer_executable="$ZM_RUNTIME_DIR/composer"
fi
return 0
}
function install_framework() {
echo "$(nhead) 开始安装框架到目录 $ZM_CUSTOM_DIR ..."
export COMPOSER_ALLOW_SUPERUSER=1
mkdir -p "$ZM_PWD/$ZM_CUSTOM_DIR" && \
cd "$ZM_PWD/$ZM_CUSTOM_DIR" && \
$composer_executable init --name="zhamao/zhamao-v3-app" -n -q && \
if_use_aliyun && \
echo "$(nhead) 从 Composer 拉取框架 ..." && \
echo '{"minimum-stability":"dev"}' > composer.json && composer require -n zhamao/framework:^3 && \
$composer_executable require -n --dev swoole/ide-helper:^4.5 && \
if_restore_native_runtime && \
echo "$(nhead) 初始化框架脚手架文件 ..." && \
vendor/bin/zhamao init && \
$composer_executable dump-autoload -n && \
show_success_msg || {
echo "$(nhead red) 安装框架失败!" && cd $ZM_PWD && rm -rf "$ZM_CUSTOM_DIR" && return 1
}
}
function show_success_msg() {
echo -e "$(nhead) 框架安装成功,已安装到目录 $ZM_CUSTOM_DIR" && \
echo -e "$(nhead) 进入应用目录:""$_cyan""cd $ZM_CUSTOM_DIR""$_reset" && \
echo -e "$(nhead) 启动框架命令:""$_cyan""./zhamao server""$_reset" && \
echo -e "$(nhead) 生成插件脚手架目录的命令:""$_cyan""./zhamao plugin:make""$_reset"
}
# 环境变量设置
test "$ZM_TEMP_DIR" = "" && ZM_TEMP_DIR="/tmp/.zm-runtime"
test "$ZM_CUSTOM_DIR" = "" && ZM_CUSTOM_DIR="zhamao-v3"
if [ -d "$ZM_PWD/$ZM_CUSTOM_DIR" ]; then
echo "$(nhead red) 检测到目录 $ZM_CUSTOM_DIR/ 已安装过框架,请更换文件夹名称或删除旧文件夹再试!"
exit 1
fi
# 检查系统环境,目前只支持 Linux
case $(uname -s) in
Linux) linux_env_check || exit 1 ;;
Darwin) darwin_env_check || exit 1 ;;
*) echo "$(nhead red) Only support Linux and macOS!" && exit 1 ;;
esac
# 安装框架
install_framework

69
install-runtime.sh Executable file
View File

@@ -0,0 +1,69 @@
#!/usr/bin/env bash
function download_file() {
downloader="wget"
type wget >/dev/null 2>&1 || { downloader="curl"; }
if [ "$downloader" = "wget" ]; then
_down_prefix="O"
else
_down_prefix="o"
fi
_down_symbol=0
if [ ! -f "$2" ]; then
echo $1
$downloader "$1" -$_down_prefix "$2" >/dev/null 2>&1 && \
echo "完成!" && _down_symbol=1
else
echo "已存在!" && _down_symbol=1
fi
if [ $_down_symbol == 0 ]; then
echo "失败!请检查网络连接!"
rm -rf "$2"
return 1
fi
return 0
}
function test_composer_and_php() {
succ=$("$(pwd)/runtime/composer" -n about | grep Manage)
if [ "$succ" = "" ]; then
echo "Download PHP binary and composer failed!"
return 1
fi
return 0
}
if [ "$(uname -s)" != "Linux" ]; then
echo "Only support Linux!!!"
exit 1
fi
ZM_PHP_VERSION="7.4"
if [ "$ZM_DOWN_PHP_VERSION" != "" ]; then
ZM_PHP_VERSION="$ZM_DOWN_PHP_VERSION"
echo "Using custom PHP version: $ZM_PHP_VERSION"
fi
mkdir "$(pwd)/runtime" >/dev/null 2>&1
if [ ! -f "$(pwd)/runtime/php" ]; then
download_file "https://dl.zhamao.me/php-bin/down.php?php_ver=$ZM_PHP_VERSION&arch=$(uname -m)" "$(pwd)/runtime/php.tar.gz"
if [ $? -ne 0 ]; then
exit 1
fi
tar -xf "$(pwd)/runtime/php.tar.gz" -C "$(pwd)/runtime/"
fi
if [ ! -f "$(pwd)/runtime/composer" ]; then
download_file "https://mirrors.aliyun.com/composer/composer.phar" "$(pwd)/runtime/composer.phar"
if [ $? -ne 0 ]; then
exit 1
fi
echo '$(dirname $0)/php $(dirname $0)/composer.phar $@' > $(pwd)/runtime/composer
chmod +x $(pwd)/runtime/composer
test_composer_and_php
fi
if [ $? -ne 0 ]; then
exit 1
fi
echo "成功下载!" && \
echo -e "PHP使用\truntime/php -v" && \
echo -e "Composer使用\truntime/composer"

20
instant-plugin-demo.php Normal file
View File

@@ -0,0 +1,20 @@
<?php
declare(strict_types=1);
$plugin = new \ZM\ZMApplication(__DIR__);
/*
* 发送 "测试 123",回复 "你好123"
*/
$cmd1 = BotCommand::make('test', '测试')->withArgument('arg1')->on(fn () => '你好,{{arg1}}');
/*
* 浏览器访问 http://ip:port/index233返回内容
*/
$route1 = Route::make('/index233')->on(fn () => '<h1>Hello world</h1>');
$plugin->addBotCommand($cmd1);
$plugin->addHttpRoute($route1);
$plugin->run();

39
mybot.php Normal file
View File

@@ -0,0 +1,39 @@
<?php
declare(strict_types=1);
use OneBot\Driver\Event\Http\HttpRequestEvent;
require 'vendor/autoload.php';
// 创建框架 App
$app = new ZM\ZMApplication();
// 传入自定义配置文件
$app->patchConfig([
'driver' => 'workerman',
]);
// 改变启动所需的参数
$app->patchArgs([
'--private-mode',
]);
// 如果有 Composer 依赖的插件,使用 enablePlugins 进行开启
$app->enablePlugins([
'a',
'b',
'c',
'd',
]);
// BotCommand 事件构造
$cmd = BotCommand::make('test')->on(function () {
ctx()->reply('test ok');
});
$event = BotEvent::make(type: 'message')->on(function () {
});
$app->addBotEvent($event);
$app->addBotCommand($cmd);
$app->addEvent(HttpRequestEvent::getName(), function (HttpRequestEvent $event) {
$event->withResponse(\OneBot\Http\HttpFactory::getInstance()->createResponse(503));
});
$app->run();

10
package.json Normal file
View File

@@ -0,0 +1,10 @@
{
"dependencies": {
"vuepress-theme-antdocs": "^1.4.5",
"vuepress": "^1.9.7"
},
"scripts": {
"docs:dev": "vuepress dev docs",
"docs:build": "vuepress build docs"
}
}

View File

@@ -1,85 +0,0 @@
<?php
global $is_phar;
use Framework\FrameworkLoader;
$is_phar = true;
if (substr(__DIR__, 0, 7) != 'phar://') {
die("You can not run this script directly!\n");
}
testEnvironment();
spl_autoload_register(function ($class) {
//echo $class."\n";
$exp = str_replace("\\", '/', $class);
$exp = __DIR__ . '/src/' . $exp . '.php';
if (is_file($exp)) {
require_once $exp;
}
});
loadPhp(__DIR__ . '/src');
Swoole\Coroutine::set([
'max_coroutine' => 30000,
]);
date_default_timezone_set("Asia/Shanghai");
define('WORKING_DIR', __DIR__);
define('FRAMEWORK_DIR', __DIR__);
define('LOAD_MODE', 2);
$s = new FrameworkLoader($argv);
function loadPhp($dir) {
$dirs = scandir($dir);
foreach ($dirs as $v) {
$path = $dir . '/' . $v;
if (is_dir($path)) {
loadPhp($path);
} else {
if (pathinfo($dir . '/' . $v)['extension'] == 'php') {
if(pathinfo($dir . '/' . $v)['basename'] == 'terminal_listener.php') continue;
//echo 'loading '.$path.PHP_EOL;
require_once $path;
}
}
}
}
function testEnvironment() {
$current_dir = realpath('.');
@mkdir($current_dir . '/config/');
if (!is_file($current_dir . '/config/global.php')) {
echo "Exporting default global config...\n";
$global = file_get_contents(__DIR__ . '/config/global.php');
$global = str_replace("WORKING_DIR", 'realpath(__DIR__ . "/../")', $global);
file_put_contents($current_dir . '/config/global.php', $global);
}
if (!is_file($current_dir . '/config/file_header.json')) {
echo "Exporting default file_header config...\n";
$global = file_get_contents(__DIR__ . '/config/file_header.json');
file_put_contents($current_dir . '/config/file_header.json', $global);
}
if (!is_dir($current_dir . '/resources')) mkdir($current_dir . '/resources');
if (!is_dir($current_dir . '/src')) mkdir($current_dir . '/src');
if (!is_dir($current_dir . '/src')) mkdir($current_dir . '/src');
if (!is_dir($current_dir . '/src/Module')) {
mkdir($current_dir . '/src/Module');
mkdir($current_dir . '/src/Module/Example');
file_put_contents($current_dir . '/src/Module/Example/Hello.php', file_get_contents(__DIR__ . '/tmp/Hello.php.bak'));
mkdir($current_dir . '/src/Module/Middleware');
file_put_contents($current_dir . '/src/Module/Middleware/TimerMiddleware.php', file_get_contents(__DIR__ . '/tmp/TimerMiddleware.php.bak'));
}
if (!is_dir($current_dir . '/src/Custom')) {
mkdir($current_dir . '/src/Custom');
mkdir($current_dir . '/src/Custom/Annotation');
mkdir($current_dir . '/src/Custom/Connection');
file_put_contents($current_dir . '/src/Custom/global_function.php', "<?php\n\n//这里写你的全局方法");
}
}

22
phpstan.neon Normal file
View File

@@ -0,0 +1,22 @@
parameters:
reportUnmatchedIgnoredErrors: false
level: 4
paths:
- ./src/
- ./tests/
excludePaths:
- ./src/ZM/Exception/Solution/SolutionRepository.php
ignoreErrors:
- '#Constant .* not found#'
- '#PHPDoc tag @throws with type Psr\\Container\\ContainerExceptionInterface is not subtype of Throwable#'
- '#Unsafe usage of new static#'
- '#Call to method initTableList\(\) of deprecated class ZM\\DB\\DB#'
- '#class Fiber#'
- # Ignore Prophesize deprecation bug: https://github.com/phpstan/phpstan-deprecation-rules/issues/76
message: '#^Call to deprecated method prophesize\(\) of class Tests\\TestCase#'
path: tests
dynamicConstantNames:
- SWOOLE_VERSION
- ZM_TEST_LOG_DEBUG
- _PHAR_STUB_ID
- LOAD_MODE

33
phpunit.xml.dist Normal file
View File

@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="./tests/bootstrap.php"
backupGlobals="false"
backupStaticAttributes="false"
colors="true"
convertDeprecationsToExceptions="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnError="false"
stopOnFailure="false"
testdox="true"
verbose="true"
>
<testsuites>
<testsuite name="Zhamao Framework Test Suite">
<directory suffix="Test.php">./tests</directory>
</testsuite>
</testsuites>
<coverage>
<include>
<directory suffix=".php">./src/ZM</directory>
</include>
<report>
<html outputDirectory="./build/html-coverage"/>
<clover outputFile="./build/coverage.xml"/>
</report>
</coverage>
<php>
<env name="APP_ENV" value="testing"/>
</php>
</phpunit>

View File

@@ -0,0 +1,10 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Example page</title>
</head>
<body>
<div style="background: red; width: 100px; height: 100px"></div>
</body>
</html>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 385 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 115 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 61 KiB

View File

@@ -1,19 +0,0 @@
<?php
namespace Custom\Annotation;
use Doctrine\Common\Annotations\Annotation\Target;
use ZM\Annotation\Interfaces\CustomAnnotation;
/**
* Class CustomAnnotation
* @Annotation
* @Target("ALL")
* @package Custom\Annotation
*/
class Example implements CustomAnnotation
{
/** @var string */
public $str;
}

View File

@@ -1,14 +0,0 @@
<?php
namespace Custom\Connection;
use ZM\Connection\WSConnection;
class CustomConnection extends WSConnection
{
public function getType() {
return "custom";
}
}

View File

@@ -1,3 +0,0 @@
<?php
//这里写你的全局函数

View File

@@ -1,277 +0,0 @@
<?php
/**
* Created by PhpStorm.
* User: jerry
* Date: 2018/2/10
* Time: 下午6:13
*/
namespace Framework;
use ZM\Annotation\Swoole\SwooleEventAt;
use ZM\Connection\WSConnection;
use ZM\Utils\ZMUtil;
use Exception;
class Console
{
/**
* @var false|resource
*/
public static $console_proc = null;
public static $pipes = [];
static function setColor($string, $color = "") {
switch ($color) {
case "red":
return "\x1b[38;5;203m" . $string . "\x1b[m";
case "green":
return "\x1b[38;5;83m" . $string . "\x1b[m";
case "yellow":
return "\x1b[38;5;227m" . $string . "\x1b[m";
case "blue":
return "\033[34m" . $string . "\033[0m";
case "pink": // I really don't know what stupid color it is.
case "lightpurple":
return "\x1b[38;5;207m" . $string . "\x1b[m";
case "lightblue":
return "\x1b[38;5;87m" . $string . "\x1b[m";
case "gold":
return "\x1b[38;5;214m" . $string . "\x1b[m";
case "gray":
return "\x1b[38;5;59m" . $string . "\x1b[m";
case "lightlightblue":
return "\x1b[38;5;63m" . $string . "\x1b[m";
default:
return $string;
}
}
static function error($obj, $head = null) {
if ($head === null) $head = date("[H:i:s] ") . "[E] ";
if (ZMBuf::$info_level !== null && in_array(ZMBuf::$info_level->get(), [1, 2])) {
$trace = debug_backtrace()[1] ?? ['file' => '', 'function' => ''];
$trace = "[" . basename($trace["file"], ".php") . ":" . $trace["function"] . "] ";
}
if (!is_string($obj)) {
if (isset($trace)) {
var_dump($obj);
return;
} else $obj = "{Object}";
}
echo(self::setColor($head . ($trace ?? "") . $obj, "red") . "\n");
}
static function warning($obj, $head = null) {
if ($head === null) $head = date("[H:i:s]") . " [W] ";
if (ZMBuf::$info_level !== null && in_array(ZMBuf::$info_level->get(), [1, 2])) {
$trace = debug_backtrace()[1] ?? ['file' => '', 'function' => ''];
$trace = "[" . basename($trace["file"], ".php") . ":" . $trace["function"] . "] ";
}
if (ZMBuf::$atomics["info_level"]->get() >= 1) {
if (!is_string($obj)) {
if (isset($trace)) {
var_dump($obj);
return;
} else $obj = "{Object}";
}
echo(self::setColor($head . ($trace ?? "") . $obj, in_array("--white-term", FrameworkLoader::$argv) ? "blue" : "yellow") . "\n");
}
}
static function info($obj, $head = null) {
if ($head === null) $head = date("[H:i:s] ") . "[I] ";
if (ZMBuf::$info_level !== null && in_array(ZMBuf::$info_level->get(), [1, 2])) {
$trace = debug_backtrace()[1] ?? ['file' => '', 'function' => ''];
$trace = "[" . basename($trace["file"], ".php") . ":" . $trace["function"] . "] ";
}
if (ZMBuf::$atomics["info_level"]->get() >= 2) {
if (!is_string($obj)) {
if (isset($trace)) {
var_dump($obj);
return;
} else $obj = "{Object}";
}
echo(self::setColor($head . ($trace ?? "") . $obj, in_array("--white-term", FrameworkLoader::$argv) ? "black" : "lightblue") . "\n");
}
}
static function success($obj, $head = null) {
if ($head === null) $head = date("[H:i:s] ") . "[S] ";
if (ZMBuf::$info_level !== null && in_array(ZMBuf::$info_level->get(), [1, 2])) {
$trace = debug_backtrace()[1] ?? ['file' => '', 'function' => ''];
$trace = "[" . basename($trace["file"], ".php") . ":" . $trace["function"] . "] ";
}
if (ZMBuf::$atomics["info_level"]->get() >= 2) {
if (!is_string($obj)) {
if (isset($trace)) {
var_dump($obj);
return;
} else $obj = "{Object}";
}
echo(self::setColor($head . ($trace ?? "") . $obj, "green") . "\n");
}
}
static function verbose($obj, $head = null) {
if ($head === null) $head = date("[H:i:s] ") . "[V] ";
if (ZMBuf::$atomics["info_level"]->get() >= 3) {
if (!is_string($obj)) {
if (isset($trace)) {
var_dump($obj);
return;
} else $obj = "{Object}";
}
echo(self::setColor($head . ($trace ?? "") . $obj, "blue") . "\n");
}
}
static function debug($msg) {
if (ZMBuf::$atomics["info_level"]->get() >= 4) Console::log(date("[H:i:s] ") . "[D] " . $msg, 'gray');
}
static function log($obj, $color = "") {
if (!is_string($obj)) var_dump($obj);
else echo(self::setColor($obj, $color) . "\n");
}
static function stackTrace() {
$log = "Stack trace:\n";
$trace = debug_backtrace();
//array_shift($trace);
foreach ($trace as $i => $t) {
if (!isset($t['file'])) {
$t['file'] = 'unknown';
}
if (!isset($t['line'])) {
$t['line'] = 0;
}
if (!isset($t['function'])) {
$t['function'] = 'unknown';
}
$log .= "#$i {$t['file']}({$t['line']}): ";
if (isset($t['object']) and is_object($t['object'])) {
$log .= get_class($t['object']) . '->';
}
$log .= "{$t['function']}()\n";
}
$log = Console::setColor($log, "gray");
echo $log;
}
static function listenConsole() {
if (in_array('--disable-console-input', FrameworkLoader::$argv) || in_array('--debug-mode', FrameworkLoader::$argv)) {
self::info("ConsoleCommand disabled.");
return;
}
global $terminal_id;
global $port;
$port = ZMBuf::globals("port");
$vss = new SwooleEventAt();
$vss->type = "open";
$vss->level = 256;
$vss->rule = "connectType:terminal";
$terminal_id = call_user_func(function () {
try {
$data = random_bytes(16);
} catch (Exception $e) {
return "";
}
$data[6] = chr(ord($data[6]) & 0x0f | 0x40);
$data[8] = chr(ord($data[8]) & 0x3f | 0x80);
return strtoupper(vsprintf('%s%s-%s-%s-%s-%s%s%s', str_split(bin2hex($data), 4)));
});
$vss->callback = function(?WSConnection $conn) use ($terminal_id){
$req = ctx()->getRequest();
if($conn->getType() != "terminal") return false;
Console::debug("Terminal fd: ".$conn->fd);
if(($req->header["x-terminal-id"] ?? "") != $terminal_id) {
$conn->close();
return false;
}
return false;
};
ZMBuf::$events[SwooleEventAt::class][] = $vss;
$vss2 = new SwooleEventAt();
$vss2->type = "message";
$vss2->rule = "connectType:terminal";
$vss2->callback = function(?WSConnection $conn){
if ($conn === null) return false;
if($conn->getType() != "terminal") return false;
$cmd = ctx()->getFrame()->data;
self::executeCommand($cmd);
return false;
};
ZMBuf::$events[SwooleEventAt::class][] = $vss2;
go(function () {
global $terminal_id, $port;
$descriptorspec = array(
0 => STDIN,
1 => STDOUT,
2 => STDERR
);
self::$console_proc = proc_open('php -r \'$terminal_id = "'.$terminal_id.'";$port = '.$port.';require "'.__DIR__.'/terminal_listener.php";\'', $descriptorspec, $pipes);
});
}
/**
* @param string $cmd
* @return bool
*/
private static function executeCommand(string $cmd) {
$it = explodeMsg($cmd);
switch ($it[0] ?? '') {
case 'logtest':
Console::log(date("[H:i:s]") . " [L] This is normal msg. (0)");
Console::error("This is error msg. (0)");
Console::warning("This is warning msg. (1)");
Console::info("This is info msg. (2)");
Console::success("This is success msg. (2)");
Console::verbose("This is verbose msg. (3)");
Console::debug("This is debug msg. (4)");
return true;
case 'call':
$class_name = $it[1];
$function_name = $it[2];
$class = new $class_name([]);
call_user_func_array([$class, $function_name], []);
return true;
case 'bc':
$code = base64_decode($it[1] ?? '', true);
try {
eval($code);
} catch (Exception $e) {
}
return true;
case 'echo':
Console::info($it[1]);
return true;
case 'color':
Console::log($it[2], $it[1]);
return true;
case 'stop':
ZMUtil::stop();
return false;
case 'reload':
case 'r':
ZMUtil::reload();
return false;
case 'save':
$origin = ZMBuf::$atomics["info_level"]->get();
//ZMBuf::$atomics["info_level"]->set(3);
DataProvider::saveBuffer();
//ZMBuf::$atomics["info_level"]->set($origin);
return true;
case '':
return true;
default:
Console::info("Command not found: " . $cmd);
return true;
}
}
public static function withSleep(string $string, int $int) {
self::info($string);
sleep($int);
}
}

View File

@@ -1,78 +0,0 @@
<?php
namespace Framework;
use ZM\Annotation\Swoole\OnSave;
class DataProvider
{
public static $buffer_list = [];
public static function getResourceFolder() {
return self::getWorkingDir() . '/resources/';
}
public static function getWorkingDir() {
if(LOAD_MODE == 0) return WORKING_DIR;
elseif (LOAD_MODE == 1) return LOAD_MODE_COMPOSER_PATH;
elseif (LOAD_MODE == 2) return realpath('.');
return null;
}
public static function getDataConfig() {
return CONFIG_DIR;
}
public static function addSaveBuffer($buf_name, $sub_folder = null) {
$name = ($sub_folder ?? "") . "/" . $buf_name . ".json";
self::$buffer_list[$buf_name] = $name;
Console::debug("Added " . $buf_name . " at $sub_folder");
ZMBuf::set($buf_name, self::getJsonData($name));
}
public static function saveBuffer() {
$head = Console::setColor(date("[H:i:s] ") . "[V] Saving buffer......", "blue");
if (ZMBuf::$atomics["info_level"]->get() >= 3)
echo $head;
foreach (self::$buffer_list as $k => $v) {
Console::debug("Saving " . $k . " to " . $v);
self::setJsonData($v, ZMBuf::get($k));
}
foreach (ZMBuf::$events[OnSave::class] ?? [] as $v) {
$c = $v->class;
$method = $v->method;
$class = new $c();
Console::debug("Calling @OnSave: $c -> $method");
$class->$method();
}
if (ZMBuf::$atomics["info_level"]->get() >= 3)
echo Console::setColor("saved", "blue") . PHP_EOL;
}
public static function getFrameworkLink() {
return ZMBuf::globals("http_reverse_link");
}
public static function getJsonData(string $string) {
if (!file_exists(self::getDataConfig() . $string)) return [];
return json_decode(file_get_contents(self::getDataConfig() . $string), true);
}
public static function setJsonData($filename, array $args) {
$pathinfo = pathinfo($filename);
if (!is_dir(self::getDataConfig() . $pathinfo["dirname"])) {
Console::debug("Making Directory: " . self::getDataConfig() . $pathinfo["dirname"]);
mkdir(self::getDataConfig() . $pathinfo["dirname"]);
}
$r = file_put_contents(self::getDataConfig() . $filename, json_encode($args, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT | JSON_BIGINT_AS_STRING));
if ($r === false) {
Console::warning("无法保存文件: " . $filename);
}
}
public static function getDataFolder() {
return ZM_DATA;
}
}

View File

@@ -1,193 +0,0 @@
<?php
namespace Framework;
use Doctrine\Common\Annotations\AnnotationReader;
use ReflectionClass;
use ReflectionMethod;
use Swoole\Runtime;
use ZM\Annotation\Swoole\OnEvent;
use Exception;
use Swoole\WebSocket\Server;
/**
* Class FrameworkLoader
* Everything is beginning from here
* @package Framework
*/
class FrameworkLoader
{
/** @var GlobalConfig */
public static $settings;
/** @var FrameworkLoader|null */
public static $instance = null;
/** @var float|string */
public static $run_time;
/**
* @var array
*/
public static $argv;
/** @var Server */
private $server;
public function __construct($args = []) {
$this->requireGlobalFunctions();
if (LOAD_MODE == 0) define("WORKING_DIR", getcwd());
elseif (LOAD_MODE == 1) define("WORKING_DIR", realpath(__DIR__ . "/../../"));
elseif (LOAD_MODE == 2) echo "Phar mode: " . WORKING_DIR . PHP_EOL;
//$this->registerAutoloader('classLoader');
require_once "DataProvider.php";
if (file_exists(DataProvider::getWorkingDir() . "/vendor/autoload.php")) {
/** @noinspection PhpIncludeInspection */
require_once DataProvider::getWorkingDir() . "/vendor/autoload.php";
}
if (LOAD_MODE == 2) {
require_once FRAMEWORK_DIR . "/vendor/autoload.php";
spl_autoload_register('phar_classloader');
}
self::$settings = new GlobalConfig();
if (self::$settings->get("debug_mode") === true) {
$args[] = "--debug-mode";
$args[] = "--disable-console-input";
}
self::$argv = $args;
if (!in_array("--debug-mode", self::$argv)) {
Runtime::enableCoroutine(true, SWOOLE_HOOK_ALL);
}
self::$settings = new GlobalConfig();
ZMBuf::$globals = self::$settings;
if (!self::$settings->success) die("Failed to load global config. Please check config/global.php file");
$this->defineProperties();
//start swoole Framework
$this->selfCheck();
try {
$this->server = new Server(self::$settings->get("host"), self::$settings->get("port"));
$settings = self::$settings->get("swoole");
if (in_array("--daemon", $args)) {
$settings["daemonize"] = 1;
Console::log("已启用守护进程,输出重定向到 " . $settings["log_file"]);
self::$argv[] = "--disable-console-input";
}
$this->server->set($settings);
$all_event_class = self::$settings->get("server_event_handler_class");
$event_list = [];
foreach ($all_event_class as $v) {
$reader = new AnnotationReader();
$reflection_class = new ReflectionClass($v);
$methods = $reflection_class->getMethods(ReflectionMethod::IS_PUBLIC);
foreach ($methods as $vs) {
$method_annotations = $reader->getMethodAnnotations($vs);
if ($method_annotations != []) {
$annotation = $method_annotations[0];
if ($annotation instanceof OnEvent) {
$annotation->class = $v;
$annotation->method = $vs->getName();
$event_list[strtolower($annotation->event)] = $annotation;
}
}
}
}
foreach ($event_list as $k => $v) {
$this->server->on($k, function (...$param) use ($v) {
$c = $v->class;
//echo $c.PHP_EOL;
$c = new $c();
call_user_func_array([$c, $v->method], $param);
});
}
ZMBuf::initAtomic();
if (in_array("--remote-shell", $args)) RemoteShell::listen($this->server, "127.0.0.1");
if (in_array("--log-error", $args)) ZMBuf::$atomics["info_level"]->set(0);
if (in_array("--log-warning", $args)) ZMBuf::$atomics["info_level"]->set(1);
if (in_array("--log-info", $args)) ZMBuf::$atomics["info_level"]->set(2);
if (in_array("--log-verbose", $args)) ZMBuf::$atomics["info_level"]->set(3);
if (in_array("--log-debug", $args)) ZMBuf::$atomics["info_level"]->set(4);
Console::log(
"host: " . self::$settings->get("host") .
", port: " . self::$settings->get("port") .
", log_level: " . ZMBuf::$atomics["info_level"]->get() .
", version: " . ZM_VERSION .
"\nworking_dir: " . DataProvider::getWorkingDir()
);
global $motd;
if (!file_exists(DataProvider::getWorkingDir() . "/config/motd.txt")) {
echo $motd;
} else {
echo file_get_contents(DataProvider::getWorkingDir() . "/config/motd.txt");
}
if (in_array("--debug-mode", self::$argv))
Console::warning("You are in debug mode, do not use in production!");
register_shutdown_function(function() {
$error = error_get_last();
if(isset($error["type"]) && $error["type"] == 1) {
if(mb_strpos($error["message"], "require") !== false && mb_strpos($error["message"], "callback") !== false) {
echo "\e[38;5;203mYou may need to update your \"global.php\" config!\n";
echo "Please see: https://github.com/zhamao-robot/zhamao-framework/issues/15\e[m\n";
}
}
});
$this->server->start();
} catch (Exception $e) {
Console::error("Framework初始化出现错误请检查");
Console::error($e->getMessage());
die;
}
}
private function requireGlobalFunctions() {
require_once __DIR__ . '/global_functions.php';
}
private function defineProperties() {
define("ZM_START_TIME", microtime(true));
define("ZM_DATA", self::$settings->get("zm_data"));
define("ZM_VERSION", json_decode(file_get_contents(__DIR__ . "/../../composer.json"), true)["version"] ?? "unknown");
define("CONFIG_DIR", self::$settings->get("config_dir"));
define("CRASH_DIR", self::$settings->get("crash_dir"));
@mkdir(ZM_DATA);
@mkdir(CONFIG_DIR);
@mkdir(CRASH_DIR);
define("ZM_MATCH_ALL", 0);
define("ZM_MATCH_FIRST", 1);
define("ZM_MATCH_NUMBER", 2);
define("ZM_MATCH_SECOND", 3);
define("ZM_BREAKPOINT", 'if(in_array("--debug-mode", \Framework\FrameworkLoader::$argv)) extract(\Psy\debug(get_defined_vars(), isset($this) ? $this : @get_called_class()));');
define("BP", ZM_BREAKPOINT);
define("ZM_DEFAULT_FETCH_MODE", self::$settings->get("sql_config")["sql_default_fetch_mode"] ?? 4);
}
private function selfCheck() {
if (!extension_loaded("swoole")) die("Can not find swoole extension.\n");
if (version_compare(SWOOLE_VERSION, "4.4.13") == -1) die("You must install swoole version >= 4.4.13 !");
//if (!extension_loaded("gd")) die("Can not find gd extension.\n");
if (!extension_loaded("sockets")) die("Can not find sockets extension.\n");
if (!extension_loaded("ctype")) die("Can not find ctype extension.\n");
if (!function_exists("mb_substr")) die("Can not find mbstring extension.\n");
if (substr(PHP_VERSION, 0, 1) != "7") die("PHP >=7 required.\n");
//if (!function_exists("curl_exec")) die("Can not find curl extension.\n");
//if (!class_exists("ZipArchive")) die("Can not find Zip extension.\n");
//if (!file_exists(CRASH_DIR . "last_error.log")) die("Can not find log file.\n");
return true;
}
}
global $motd;
$motd = <<<EOL
______
|__ / |__ __ _ _ __ ___ __ _ ___
/ /| '_ \ / _` | '_ ` _ \ / _` |/ _ \
/ /_| | | | (_| | | | | | | (_| | (_) |
/____|_| |_|\__,_|_| |_| |_|\__,_|\___/
EOL;

View File

@@ -1,37 +0,0 @@
<?php
/**
* Created by PhpStorm.
* User: jerry
* Date: 2019-03-16
* Time: 13:58
*/
namespace Framework;
/**
* 请不要diss此class的语法。可能写的很糟糕。
* Class GlobalConfig
*/
class GlobalConfig
{
private $config = null;
public $success = false;
public function __construct() {
/** @noinspection PhpIncludeInspection */
include_once DataProvider::getWorkingDir() . '/config/global.php';
global $config;
$this->success = true;
$this->config = $config;
}
public function get($key) {
$r = $this->config[$key] ?? null;
if ($r === null) return null;
return $r;
}
public function getAll() {
return $this->config;
}
}

View File

@@ -1,264 +0,0 @@
<?php
namespace Framework;
use Co;
use Exception;
use Swoole\Coroutine;
use swoole\server;
class RemoteShell
{
const STX = "DEBUG";
private static $contexts = array();
static $oriPipeMessageCallback = null;
/**
* @var server
*/
static $serv;
static $menu = array(
"p|print [variant]\t打印一个PHP变量的值",
"e|exec [code]\t执行一段PHP代码",
"w|worker [id]\t切换Worker进程",
"l|list\t打印服务器所有连接的fd",
"s|stats\t打印服务器状态",
"c|coros\t打印协程列表",
"b|bt\t打印协程调用栈",
"i|info [fd]\t显示某个连接的信息",
"h|help\t显示帮助界面",
"q|quit\t退出终端",
);
const PAGESIZE = 20;
/**
* @param $serv server
* @param string $host
* @param int $port
* @throws Exception
* @throws Exception
*/
static function listen($serv, $host = "127.0.0.1", $port = 9599) {
Console::warning("正在监听".$host.":".strval($port)."的调试接口,请注意安全");
$port = $serv->listen($host, $port, SWOOLE_SOCK_TCP);
if (!$port) {
throw new Exception("listen fail.");
}
$port->set(array(
"open_eof_split" => true,
'package_eof' => "\r\n",
));
$port->on("Connect", array(__CLASS__, 'onConnect'));
$port->on("Close", array(__CLASS__, 'onClose'));
$port->on("Receive", array(__CLASS__, 'onReceive'));
if (method_exists($serv, 'getCallback')) {
self::$oriPipeMessageCallback = $serv->getCallback('PipeMessage');
}
$serv->on("PipeMessage", array(__CLASS__, 'onPipeMessage'));
self::$serv = $serv;
}
static function onConnect($serv, $fd, $reactor_id) {
self::$contexts[$fd]['worker_id'] = $serv->worker_id;
self::output($fd, implode("\r\n", self::$menu));
}
static function output($fd, $msg) {
if (!isset(self::$contexts[$fd]['worker_id'])) {
$msg .= "\r\nworker#" . self::$serv->worker_id . "$ ";
} else {
$msg .= "\r\nworker#" . self::$contexts[$fd]['worker_id'] . "$ ";
}
self::$serv->send($fd, $msg);
}
static function onClose($serv, $fd, $reactor_id) {
unset(self::$contexts[$fd]);
}
static function onPipeMessage($serv, $src_worker_id, $message) {
//不是 debug 消息
if (!is_string($message) or substr($message, 0, strlen(self::STX)) != self::STX) {
if (self::$oriPipeMessageCallback == null) {
trigger_error("require swoole-4.3.0 or later.", E_USER_WARNING);
return true;
}
return call_user_func(self::$oriPipeMessageCallback, $serv, $src_worker_id, $message);
} else {
$request = unserialize(substr($message, strlen(self::STX)));
self::call($request['fd'], $request['func'], $request['args']);
}
return true ;
}
static protected function call($fd, $func, $args) {
ob_start();
call_user_func_array($func, $args);
self::output($fd, ob_get_clean());
}
static protected function exec($fd, $func, $args) {
//不在当前Worker进程
if (self::$contexts[$fd]['worker_id'] != self::$serv->worker_id) {
self::$serv->sendMessage(self::STX . serialize(['fd' => $fd, 'func' => $func, 'args' => $args]), self::$contexts[$fd]['worker_id']);
} else {
self::call($fd, $func, $args);
}
}
static function getCoros() {
var_export(iterator_to_array(Coroutine::listCoroutines()));
}
static function getBackTrace($_cid) {
$info = Co::getBackTrace($_cid);
if (!$info) {
echo "coroutine $_cid not found.";
} else {
echo get_debug_print_backtrace($info);
}
}
static function printVariant($var) {
$var = ltrim($var, '$ ');
var_dump($var);
var_dump($$var);
}
static function evalCode($code) {
eval($code . ';');
}
/**
* @param $serv server
* @param $fd
* @param $reactor_id
* @param $data
*/
static function onReceive($serv, $fd, $reactor_id, $data) {
$args = explode(" ", $data, 2);
$cmd = trim($args[0]);
unset($args[0]);
switch ($cmd) {
case 'w':
case 'worker':
if (!isset($args[1])) {
self::output($fd, "invalid command.");
break;
}
$dstWorkerId = intval($args[1]);
self::$contexts[$fd]['worker_id'] = $dstWorkerId;
self::output($fd, "[switching to worker " . self::$contexts[$fd]['worker_id'] . "]");
break;
case 'e':
case 'exec':
if (!isset($args[1])) {
self::output($fd, "invalid command.");
break;
}
$var = trim($args[1]);
self::exec($fd, 'self::evalCode', [$var]);
break;
case 'p':
case 'print':
$var = trim($args[1]);
self::exec($fd, 'self::printVariant', [$var]);
break;
case 'h':
case 'help':
self::output($fd, implode("\r\n", self::$menu));
break;
case 's':
case 'stats':
$stats = $serv->stats();
self::output($fd, var_export($stats, true));
break;
case 'c':
case 'coros':
self::exec($fd, 'self::getCoros', []);
break;
/**
* 查看协程堆栈
*/
case 'bt':
case 'b':
case 'backtrace':
if (empty($args[1])) {
self::output($fd, "invalid command [" . trim($args[1]) . "].");
break;
}
$_cid = intval($args[1]);
self::exec($fd, 'self::getBackTrace', [$_cid]);
break;
case 'i':
case 'info':
if (empty($args[1])) {
self::output($fd, "invalid command [" . trim($args[1]) . "].");
break;
}
$_fd = intval($args[1]);
$info = $serv->getClientInfo($_fd);
if (!$info) {
self::output($fd, "connection $_fd not found.");
} else {
self::output($fd, var_export($info, true));
}
break;
case 'l':
case 'list':
$tmp = array();
foreach ($serv->connections as $fd) {
$tmp[] = $fd;
if (count($tmp) > self::PAGESIZE) {
self::output($fd, json_encode($tmp));
$tmp = array();
}
}
if (count($tmp) > 0) {
self::output($fd, json_encode($tmp));
}
break;
case 'q':
case 'quit':
$serv->close($fd);
break;
default:
self::output($fd, "unknow command[$cmd]");
break;
}
}
}
function get_debug_print_backtrace($traces) {
$ret = array();
foreach ($traces as $i => $call) {
$object = '';
if (isset($call['class'])) {
$object = $call['class'] . $call['type'];
if (is_array($call['args'])) {
foreach ($call['args'] as &$arg) {
get_arg($arg);
}
}
}
$ret[] = '#' . str_pad($i, 3, ' ')
. $object . $call['function'] . '(' . implode(', ', $call['args'])
. ') called at [' . $call['file'] . ':' . $call['line'] . ']';
}
return implode("\n", $ret);
}
function get_arg(&$arg) {
if (is_object($arg)) {
$arr = (array)$arg;
$args = array();
foreach ($arr as $key => $value) {
if (strpos($key, chr(0)) !== false) {
$key = ''; // Private variable found
}
$args[] = '[' . $key . '] => ' . get_arg($value);
}
$arg = get_class($arg) . ' Object (' . implode(',', $args) . ')';
}
}

View File

@@ -1,84 +0,0 @@
<?php
namespace Framework;
use Co;
use Doctrine\Common\Annotations\AnnotationException;
use Swoole\Http\Request;
use Swoole\Server;
use Swoole\WebSocket\Frame;
use ZM\Annotation\AnnotationParser;
use ZM\Annotation\Swoole\OnEvent;
use ZM\Connection\ConnectionManager;
use ZM\Event\EventHandler;
use ZM\Http\Response;
class ServerEventHandler
{
/**
* @OnEvent("WorkerStart")
* @param Server $server
* @param $worker_id
* @throws AnnotationException
* @throws \ReflectionException
*/
public function onWorkerStart(Server $server, $worker_id) {
if ($server->taskworker === false) {
FrameworkLoader::$run_time = microtime(true);
EventHandler::callSwooleEvent("WorkerStart", $server, $worker_id);
} else {
ob_start();
AnnotationParser::registerMods();
//加载Custom目录下的自定义的内部类
ConnectionManager::registerCustomClass();
ob_get_clean();
}
}
/**
* @OnEvent("message")
* @param $server
* @param Frame $frame
* @throws AnnotationException
*/
public function onMessage($server, Frame $frame) {
Console::debug("Calling Swoole \"message\" from fd=" . $frame->fd);
EventHandler::callSwooleEvent("message", $server, $frame);
}
/**
* @OnEvent("request")
* @param $request
* @param $response
* @throws AnnotationException
*/
public function onRequest($request, $response) {
$response = new Response($response);
Console::debug("Receiving Http request event, cid=" . Co::getCid());
EventHandler::callSwooleEvent("request", $request, $response);
}
/**
* @OnEvent("open")
* @param $server
* @param Request $request
* @throws AnnotationException
*/
public function onOpen($server, Request $request) {
Console::debug("Calling Swoole \"open\" event from fd=" . $request->fd);
EventHandler::callSwooleEvent("open", $server, $request);
}
/**
* @OnEvent("close")
* @param $server
* @param $fd
* @throws AnnotationException
*/
public function onClose($server, $fd) {
Console::debug("Calling Swoole \"close\" event from fd=" . $fd);
EventHandler::callSwooleEvent("close", $server, $fd);
}
}

View File

@@ -1,121 +0,0 @@
<?php
/**
* Created by PhpStorm.
* User: jerry
* Date: 2018/2/25
* Time: 下午11:11
*/
namespace Framework;
use Swoole\Atomic;
use Swoole\Database\PDOPool;
use swoole_atomic;
use ZM\connection\WSConnection;
class ZMBuf
{
//读写的缓存数据需要在worker_num = 1下才能正常使用
/** @var mixed[] ZMBuf的data */
private static $cache = [];
/** @var WSConnection[] */
static $connect = [];//储存连接实例的数组
//Scheduler计划任务连接实例只可以在单worker_num时使用
static $scheduler = null; //This is stupid warning...
//Swoole SQL连接池多进程下每个进程一个连接池
/** @var PDOPool */
static $sql_pool = null;//保存sql连接池的类
//只读的数据可以在多worker_num下使用
/** @var null|\Framework\GlobalConfig */
static $globals = null;
// swoole server操作对象每个进程均分配
/** @var \swoole_websocket_server $server */
static $server;
/** @var array Http请求uri路径根节点 */
public static $req_mapping_node;
/** @var mixed TimeNLP初始化后的对象每个进程均可初始化 */
public static $time_nlp;
/** @var string[] $custom_connection_class */
public static $custom_connection_class = [];//保存自定义的ws connection连接类型的
// Atomic可跨进程读写的原子计数任何地方均可使用
/** @var null|swoole_atomic */
static $info_level = null;//保存log等级的原子计数
public static $events = [];
/** @var Atomic[] */
public static $atomics;
public static $req_mapping = [];
public static $config = [];
public static $context = [];
public static $instance = [];
public static $context_class = [];
public static $server_events = [];
static function get($name, $default = null) {
return self::$cache[$name] ?? $default;
}
static function set($name, $value) {
self::$cache[$name] = $value;
}
static function append($name, $value) {
self::$cache[$name][] = $value;
}
static function appendKey($name, $key, $value) {
self::$cache[$name][$key] = $value;
}
static function appendKeyInKey($name, $key, $value) {
self::$cache[$name][$key][] = $value;
}
static function unsetCache($name) {
unset(self::$cache[$name]);
}
static function unsetByValue($name, $vale) {
$key = array_search($vale, self::$cache[$name]);
array_splice(self::$cache[$name], $key, 1);
}
static function isset($name) {
return isset(self::$cache[$name]);
}
static function array_key_exists($name, $key) {
return isset(self::$cache[$name][$key]);
}
static function in_array($name, $val) {
return in_array($val, self::$cache[$name]);
}
static function globals($key) {
return self::$globals->get($key);
}
static function config($config_name) {
return self::$config[$config_name] ?? null;
}
public static function resetCache() {
self::$cache = [];
self::$connect = [];
self::$time_nlp = null;
self::$instance = [];
}
/**
* 初始化atomic计数器
*/
public static function initAtomic() {
foreach (ZMBuf::globals("init_atomics") as $k => $v) {
self::$atomics[$k] = new Atomic($v);
}
}
}

View File

@@ -1,227 +0,0 @@
<?php
use Framework\Console;
use Framework\DataProvider;
use Framework\ZMBuf;
use Swoole\Coroutine\System;
use ZM\Context\ContextInterface;
use ZM\Utils\ZMUtil;
function phar_classloader($p){
$filepath = getClassPath($p);
if($filepath === null) {
Console::debug("F:Warning: get class path wrongs.$p");
return;
}
try {
require_once $filepath;
} catch (Exception $e) {
echo "Error when finding class: " . $p . PHP_EOL;
die;
}
}
function getClassPath($class_name) {
$dir = str_replace("\\", "/", $class_name);
$dir2 = WORKING_DIR . "/src/" . $dir . ".php";
//echo "@@@".$dir2.PHP_EOL;
$dir2 = str_replace("\\", "/", $dir2);
if (file_exists($dir2)) return $dir2;
else {
$dir = DataProvider::getWorkingDir() . "/src/" . $dir . ".php";
//echo "###".$dir.PHP_EOL;
if (file_exists($dir)) return $dir;
else return null;
}
}
/**
* 使用自己定义的万san能分割函数
* @param $msg
* @param bool $ban_comma
* @return array
*/
function explodeMsg($msg, $ban_comma = false) {
$msg = str_replace(" ", "\n", trim($msg));
if (!$ban_comma) {
//$msg = str_replace("", "\n", $msg);
$msg = str_replace("\t", "\n", $msg);
}
$msgs = explode("\n", $msg);
$ls = [];
foreach ($msgs as $k => $v) {
if (trim($v) == "") continue;
$ls[] = trim($v);
}
return $ls;
}
function unicode_decode($str) {
return preg_replace_callback('/\\\\u([0-9a-f]{4})/i', function ($matches) {
return mb_convert_encoding(pack("H*", $matches[1]), "UTF-8", "UCS-2BE");
}, $str);
}
/**
* 获取模块文件夹下的每个类文件的类名称
* @param $dir
* @param string $indoor_name
* @return array
*/
function getAllClasses($dir, $indoor_name) {
if(!is_dir($dir)) return [];
$list = scandir($dir);
$classes = [];
unset($list[0], $list[1]);
foreach ($list as $v) {
//echo "Finding " . $dir . $v . PHP_EOL;
//echo "At " . $indoor_name . PHP_EOL;
if (is_dir($dir . $v)) $classes = array_merge($classes, getAllClasses($dir . $v . "/", $indoor_name . "\\" . $v));
elseif (mb_substr($v, -4) == ".php") {
$class_name = $indoor_name . "\\" . mb_substr($v, 0, -4);
$classes [] = $class_name;
}
}
return $classes;
}
function matchPattern($pattern, $context) {
if (mb_substr($pattern, 0, 1) == "" && mb_substr($context, 0, 1) == "")
return true;
if ('*' == mb_substr($pattern, 0, 1) && "" != mb_substr($pattern, 1, 1) && "" == mb_substr($context, 0, 1))
return false;
if (mb_substr($pattern, 0, 1) == mb_substr($context, 0, 1))
return matchPattern(mb_substr($pattern, 1), mb_substr($context, 1));
if (mb_substr($pattern, 0, 1) == "*")
return matchPattern(mb_substr($pattern, 1), $context) || matchPattern($pattern, mb_substr($context, 1));
return false;
}
function split_explode($del, $str, $divide_en = false) {
$str = explode($del, $str);
for ($i = 0; $i < mb_strlen($str[0]); $i++) {
if (
is_numeric(mb_substr($str[0], $i, 1)) &&
(
!is_numeric(mb_substr($str[0], $i - 1, 1)) &&
mb_substr($str[0], $i - 1, 1) != ' ' &&
ctype_alpha(mb_substr($str[0], $i - 1, 1)) === false
)
) {
$str[0] = mb_substr($str[0], 0, $i) . " " . mb_substr($str[0], $i);
} elseif (
$divide_en &&
ctype_alnum(mb_substr($str[0], $i, 1)) &&
!ctype_alnum(mb_substr($str[0], $i - 1, 1)) &&
mb_substr($str[0], $i - 1, 1) != ' '
) {
$str[0] = mb_substr($str[0], 0, $i) . ' ' . mb_substr($str[0], $i);
}
}
$str = implode($del, $str);
//echo $str."\n";
$ls = [];
foreach (explode($del, $str) as $k => $v) {
if (trim($v) == "") continue;
$ls[] = $v;
}
//var_dump($ls);
return $ls == [] ? [""] : $ls;
}
function matchArgs($pattern, $context) {
$result = [];
if (matchPattern($pattern, $context)) {
if (mb_strpos($pattern, "*") === false) return [];
$exp = explode("*", $pattern);
$i = 0;
foreach ($exp as $k => $v) {
//echo "[MATCH$k] " . $v . PHP_EOL;
if ($v == "" && $k == 0) continue;
elseif ($v == "" && $k == count($exp) - 1) {
$context = $context . "^EOL";
$v = "^EOL";
}
$cur_var = "";
//echo mb_substr($context, $i) . "|" . $v . PHP_EOL;
$ori = $i;
while (($a = mb_substr($context, $i, mb_strlen($v))) != $v && $a != "") {
$cur_var .= mb_substr($context, $i, 1);
++$i;
}
if ($i != $ori || $k == 1 || $k == count($exp) - 1) {
//echo $cur_var . PHP_EOL;
$result[] = $cur_var;
}
$i += mb_strlen($v);
}
return $result;
} else return false;
}
function set_coroutine_params($array) {
$cid = Co::getCid();
if ($cid == -1) die("Cannot set coroutine params at none coroutine mode.");
if (isset(ZMBuf::$context[$cid])) ZMBuf::$context[$cid] = array_merge(ZMBuf::$context[$cid], $array);
else ZMBuf::$context[$cid] = $array;
foreach (ZMBuf::$context as $c => $v) {
if (!Co::exists($c)) unset(ZMBuf::$context[$c], ZMBuf::$context_class[$c]);
}
}
/**
* @return ContextInterface|null
*/
function context() {
return ctx();
}
/**
* @return ContextInterface|null
*/
function ctx() {
$cid = Co::getCid();
$c_class = ZMBuf::globals("context_class");
if (isset(ZMBuf::$context[$cid])) {
return ZMBuf::$context_class[$cid] ?? (ZMBuf::$context_class[$cid] = new $c_class($cid));
} else {
Console::debug("未找到当前协程的上下文($cid),正在找父进程的上下文");
while (($pcid = Co::getPcid($cid)) !== -1) {
$cid = $pcid;
if (isset(ZMBuf::$context[$cid])) return ZMBuf::$context_class[$cid] ?? (ZMBuf::$context_class[$cid] = new $c_class($cid));
}
return null;
}
}
function debug($msg) { Console::debug($msg); }
function zm_sleep($s = 1) { Co::sleep($s); }
function zm_exec($cmd): array { return System::exec($cmd); }
function zm_cid() { return Co::getCid(); }
function zm_yield() { Co::yield(); }
function zm_resume(int $cid) { Co::resume($cid); }
function zm_timer_after($ms, callable $callable) {
go(function () use ($ms, $callable) {
ZMUtil::checkWait();
Swoole\Timer::after($ms, $callable);
});
}
function zm_timer_tick($ms, callable $callable) {
go(function () use ($ms, $callable) {
ZMUtil::checkWait();
Console::debug("Adding extra timer tick of " . $ms . " ms");
Swoole\Timer::tick($ms, $callable);
});
}

View File

@@ -1,33 +0,0 @@
<?php
use Swoole\Coroutine\Http\Client;
Co\run(function (){
hello:
global $terminal_id, $port;
$client = new Client("127.0.0.1", $port);
$client->set(['websocket_mask' => true]);
$client->setHeaders(["x-terminal-id" => $terminal_id, 'x-pid' => posix_getppid()]);
$ret = $client->upgrade("/?type=terminal");
if ($ret) {
while (true) {
$line = fgets(STDIN);
if ($line !== false) {
$r = $client->push(trim($line));
if (trim($line) == "reload" || trim($line) == "r" || trim($line) == "stop") {
break;
}
if($r === false) {
echo "Unable to connect framework terminal, connection closed. Trying to reconnect after 5s.\n";
sleep(5);
goto hello;
}
} else {
break;
}
}
} else {
echo "Unable to connect framework terminal. port: $port\n";
}
});

View File

@@ -0,0 +1,25 @@
<?php
declare(strict_types=1);
class_alias(\ZM\Annotation\Framework\BindEvent::class, 'BindEvent');
class_alias(\ZM\Annotation\Framework\Init::class, 'Init');
class_alias(\ZM\Annotation\Framework\Setup::class, 'Setup');
class_alias(\ZM\Annotation\Http\Controller::class, 'Controller');
class_alias(\ZM\Annotation\Http\Route::class, 'Route');
class_alias(\ZM\Annotation\Middleware\Middleware::class, 'Middleware');
class_alias(\ZM\Annotation\OneBot\BotCommand::class, 'BotCommand');
class_alias(\ZM\Annotation\OneBot\BotEvent::class, 'BotEvent');
class_alias(\ZM\Annotation\OneBot\CommandArgument::class, 'CommandArgument');
class_alias(\ZM\Annotation\Closed::class, 'Closed');
class_alias(\ZM\Plugin\ZMPlugin::class, 'ZMPlugin');
class_alias(\OneBot\V12\Object\OneBotEvent::class, 'OneBotEvent');
class_alias(\ZM\Context\BotContext::class, 'BotContext');
class_alias(\ZM\Store\KV\LightCache::class, 'LightCache');
class_alias(\ZM\Store\KV\Redis\KVRedis::class, 'KVRedis');
// 下面是 OneBot 相关类的全局别称
class_alias(\OneBot\Driver\Event\WebSocket\WebSocketOpenEvent::class, 'WebSocketOpenEvent');
class_alias(\OneBot\Driver\Event\WebSocket\WebSocketCloseEvent::class, 'WebSocketCloseEvent');
class_alias(\OneBot\Driver\Event\WebSocket\WebSocketMessageEvent::class, 'WebSocketMessageEvent');
class_alias(\OneBot\Driver\Event\Http\HttpRequestEvent::class, 'HttpRequestEvent');

View File

@@ -0,0 +1,93 @@
<?php
declare(strict_types=1);
/*
此文件用于定义一些常量,是框架运行的前提常量,例如定义全局版本、全局方法等。
*/
use ZM\Framework;
/** 全局版本ID */
const ZM_VERSION_ID = Framework::VERSION_ID;
/** 全局版本名称 */
const ZM_VERSION = Framework::VERSION;
/** 机器人用的,用于判断二元语意 */
const TRUE_LIST = ['yes', 'ok', 'y', 'true', 'on', '是', '对', true];
const FALSE_LIST = ['no', 'n', 'false', 'off', '否', '错', false];
/** 定义多进程的全局变量 */
const ZM_PROCESS_MASTER = ONEBOT_PROCESS_MASTER;
const ZM_PROCESS_MANAGER = ONEBOT_PROCESS_MANAGER;
const ZM_PROCESS_WORKER = ONEBOT_PROCESS_WORKER;
const ZM_PROCESS_USER = ONEBOT_PROCESS_USER;
const ZM_PROCESS_TASKWORKER = ONEBOT_PROCESS_TASKWORKER;
/** 定义一些内部引用的错误ID */
const ZM_ERR_NONE = 0; // 正常
const ZM_ERR_METHOD_NOT_FOUND = 1; // 找不到方法
const ZM_ERR_ROUTE_NOT_FOUND = 2; // 找不到路由
const ZM_ERR_ROUTE_METHOD_NOT_ALLOWED = 3; // 路由方法不允许
/** 定义 BotContext 下 reply 回复的模式 */
const ZM_REPLY_NONE = 0; // 默认回复,不带任何东西
const ZM_REPLY_MENTION = 1; // 回复时 @ 该用户
const ZM_REPLY_QUOTE = 2; // 回复时引用该消息
const LOAD_MODE_VENDOR = 0; // 从 vendor 加载
const LOAD_MODE_SRC = 1; // 从 src 加载
/* 定义工作目录 */
define('WORKING_DIR', getcwd());
/* 定义源码根目录,如果是 Phar 打包框架运行的话,就是 Phar 文件本身 */
define('SOURCE_ROOT_DIR', Phar::running() !== '' ? Phar::running() : WORKING_DIR);
if (DIRECTORY_SEPARATOR === '\\') {
define('TMP_DIR', 'C:\\Windows\\Temp');
} elseif (!empty(getenv('TMPDIR'))) {
define('TMP_DIR', getenv('TMPDIR'));
} elseif (is_writable('/tmp')) {
define('TMP_DIR', '/tmp');
} else {
define('TMP_DIR', getcwd() . '/.zm-tmp');
}
/* 定义启动模式,这里指的是框架本身的源码目录是通过 composer 加入 vendor 加载的还是直接放到 src 目录加载的,前者为 1后者为 0 */
define('LOAD_MODE', is_dir(zm_dir(SOURCE_ROOT_DIR . '/src/ZM')) ? LOAD_MODE_VENDOR : LOAD_MODE_SRC);
/* 定义框架本身所处的根目录,此处如果 LOAD_MODE 为 1 的话,框架自身的根目录在 vendor/zhamao/framework 子目录下 */
if (Phar::running() !== '') {
define('FRAMEWORK_ROOT_DIR', zm_dir(LOAD_MODE == 1 ? (SOURCE_ROOT_DIR . '/vendor/zhamao/framework') : SOURCE_ROOT_DIR));
} else {
define('FRAMEWORK_ROOT_DIR', realpath(zm_dir(__DIR__ . '/../../')));
}
define('ZM_INIT_TIME', microtime(true));
/* 定义用于存放框架运行状态的目录Windows 可用) */
define('ZM_STATE_DIR', TMP_DIR . '/.zm_' . sha1(ZM_INIT_TIME . FRAMEWORK_ROOT_DIR));
/* 对 global.php 在 Windows 下的兼容性考虑,因为 Windows 或者无 Swoole 环境时候无法运行 */
!defined('SWOOLE_BASE') && define('SWOOLE_BASE', 1) && define('SWOOLE_PROCESS', 2);
!defined('SWOOLE_HOOK_ALL') && (
define('SWOOLE_HOOK_TCP', 2)
&& define('SWOOLE_HOOK_UDP', 4)
&& define('SWOOLE_HOOK_UNIX', 8)
&& define('SWOOLE_HOOK_UDG', 16)
&& define('SWOOLE_HOOK_SSL', 32)
&& define('SWOOLE_HOOK_TLS', 64)
&& define('SWOOLE_HOOK_STREAM_FUNCTION', 128)
&& define('SWOOLE_HOOK_STREAM_SELECT', 128)
&& define('SWOOLE_HOOK_FILE', 256)
&& define('SWOOLE_HOOK_STDIO', 32768)
&& define('SWOOLE_HOOK_SLEEP', 512)
&& define('SWOOLE_HOOK_PROC', 1024)
&& define('SWOOLE_HOOK_CURL', 2048)
&& define('SWOOLE_HOOK_NATIVE_CURL', 4096)
&& define('SWOOLE_HOOK_BLOCKING_FUNCTION', 8192)
&& define('SWOOLE_HOOK_SOCKETS', 16384)
&& define('SWOOLE_HOOK_ALL', 2_147_481_599)
);

View File

@@ -0,0 +1,15 @@
<?php
declare(strict_types=1);
use ZM\Utils\ZMUtil;
/* 定义炸毛框架初始启动时间 */
if (!defined('ZM_START_TIME')) {
define('ZM_START_TIME', microtime(true));
}
/* 定义使用炸毛框架应用的版本 */
if (!defined('APP_VERSION')) {
define('APP_VERSION', LOAD_MODE == 1 ? (ZMUtil::getComposerMetadata()['version'] ?? ZM_VERSION) : ZM_VERSION);
}

View File

@@ -0,0 +1,270 @@
<?php
declare(strict_types=1);
use OneBot\Driver\Coroutine\Adaptive;
use OneBot\Driver\Coroutine\CoroutineInterface;
use OneBot\Driver\Process\ExecutionResult;
use OneBot\V12\Object\MessageSegment;
use Psr\Log\LoggerInterface;
use ZM\Config\ZMConfig;
use ZM\Container\ContainerHolder;
use ZM\Logger\ConsoleLogger;
use ZM\Middleware\MiddlewareHandler;
use ZM\Store\Database\DBException;
use ZM\Store\Database\DBQueryBuilder;
use ZM\Store\Database\DBWrapper;
use ZM\Store\KV\KVInterface;
use ZM\Store\KV\Redis\RedisWrapper;
// 防止重复引用引发报错
if (function_exists('zm_internal_errcode')) {
return;
}
/**
* 根据具体操作系统替换目录分隔符
*
* @param string $dir 目录
*/
function zm_dir(string $dir): string
{
if (str_starts_with($dir, 'phar://')) {
return $dir;
}
return str_replace('/', DIRECTORY_SEPARATOR, $dir);
}
/**
* 执行shell指令
*
* @param string $cmd 命令行
*/
function zm_exec(string $cmd): ExecutionResult
{
return Adaptive::exec($cmd);
}
/**
* sleep 指定时间单位为秒最小单位为1毫秒即0.001
*/
function zm_sleep(float|int $time)
{
Adaptive::sleep($time);
}
/**
* 获取协程接口
*/
function coroutine(): ?CoroutineInterface
{
return Adaptive::getCoroutine();
}
/**
* 获取内部错误码
*/
function zm_internal_errcode(int|string $code): string
{
return "[ErrCode:{$code}] ";
}
/**
* 返回当前炸毛实例的 ID
*/
function zm_instance_id(): string
{
if (defined('ZM_INSTANCE_ID')) {
return ZM_INSTANCE_ID;
}
if (!defined('ZM_START_TIME')) {
define('ZM_START_TIME', microtime(true));
}
$instance_id = dechex(crc32(strval(ZM_START_TIME)));
define('ZM_INSTANCE_ID', $instance_id);
return ZM_INSTANCE_ID;
}
/**
* 助手方法,返回一个 Logger 实例
*/
function logger(): LoggerInterface
{
global $ob_logger;
if ($ob_logger === null) {
return new ConsoleLogger();
}
return $ob_logger;
}
/**
* 判断传入的数组是否为关联数组
*/
function is_assoc_array(array $array): bool
{
return !empty($array) && array_keys($array) !== range(0, count($array) - 1);
}
/**
* 格式匹配
*/
function match_pattern(string $pattern, string $subject): bool
{
$pattern = str_replace(['\*', '\\\\.*'], ['.*', '\*'], preg_quote($pattern, '/'));
$pattern = '/^' . $pattern . '$/i';
return preg_match($pattern, $subject) === 1;
}
/**
* 匹配参数
*
* @return array|false 成功时返回匹配到的参数数组失败时返回false
*/
function match_args(string $pattern, string $subject)
{
$result = [];
if (match_pattern($pattern, $subject)) {
if (mb_strpos($pattern, '*') === false) {
return [];
}
$exp = explode('*', $pattern);
$i = 0;
foreach ($exp as $k => $v) {
if (empty($v) && $k === 0) {
continue;
}
if (empty($v) && $k === count($exp) - 1) {
$subject .= '^EOL';
$v = '^EOL';
}
$cur_var = '';
$ori = $i;
while (($a = mb_substr($subject, $i, mb_strlen($v))) !== $v && !empty($a)) {
$cur_var .= mb_substr($subject, $i, 1);
++$i;
}
if ($i !== $ori || $k === 1 || $k === count($exp) - 1) {
$result[] = $cur_var;
}
$i += mb_strlen($v);
}
return $result;
}
return false;
}
/**
* 构建消息段的助手函数
*
* @param string $type 类型
* @param array $data 字段
*/
function segment(string $type, array $data = []): MessageSegment
{
return new MessageSegment($type, $data);
}
/**
* 中间件操作类的助手函数
*/
function middleware(): MiddlewareHandler
{
return MiddlewareHandler::getInstance();
}
// ////////////////// 容器部分 //////////////////////
/**
* 获取容器实例
*/
function container(): DI\Container
{
return ContainerHolder::getEventContainer();
}
/**
* 解析类实例(使用容器)
*
* 这是 {@see container()}->make($abstract, $parameters) 的别名
*
* @template T
* @param class-string<T> $abstract
* @return Closure|mixed|T
*/
function resolve(string $abstract, array $parameters = [])
{
/* @noinspection PhpUnhandledExceptionInspection */
return container()->make($abstract, $parameters);
}
/**
* 获取 MySQL 调用的类
*
* @throws DBException
*/
function db(string $name = '')
{
return new DBWrapper($name);
}
/**
* 获取构建 MySQL 的类
*
* @throws DBException
*/
function sql_builder(string $name = ''): DBQueryBuilder
{
return (new DBWrapper($name))->createQueryBuilder();
}
/**
* 获取 Redis 操作类
*
* @param string $name 使用的 Redis 连接名称
*/
function redis(string $name = 'default'): RedisWrapper
{
return new RedisWrapper($name);
}
/**
* 获取 / 设置配置项
*
* 传入键名和(或)默认值,获取配置项
* 传入数组,设置配置项
* 不传参数,返回配置容器
*
* @param null|array|string $key 键名
* @param null|mixed $default 默认值
* @return mixed|void|ZMConfig
*/
function config(array|string $key = null, mixed $default = null)
{
$config = ZMConfig::getInstance();
if (is_null($key)) {
return $config;
}
if (is_array($key)) {
$config->set($key);
return;
}
return $config->get($key, $default);
}
function bot(): ZM\Context\BotContext
{
if (container()->has(ZM\Context\BotContext::class)) {
return container()->get(ZM\Context\BotContext::class);
}
return new \ZM\Context\BotContext('', '');
}
function kv(string $name = ''): Psr\SimpleCache\CacheInterface
{
global $kv_class;
if (!$kv_class) {
$kv_class = config('global.kv.use', \LightCache::class);
}
/* @phpstan-ignore-next-line */
return is_a($kv_class, KVInterface::class, true) ? $kv_class::open($name) : new $kv_class($name);
}

View File

@@ -0,0 +1,54 @@
<?php
declare(strict_types=1);
use ZM\Annotation\AnnotationParser;
use ZM\Annotation\Framework\Setup;
use ZM\Utils\ZMUtil;
function _zm_setup_loader()
{
try {
global $_tmp_setup_list;
$_tmp_setup_list = [];
$parser = new AnnotationParser(false);
$composer = ZMUtil::getComposerMetadata();
// 合并 dev 和 非 dev 的 psr-4 加载目录
$merge_psr4 = array_merge($composer['autoload']['psr-4'] ?? [], $composer['autoload-dev']['psr-4'] ?? []);
// 排除 composer.json 中指定需要排除的目录
$excludes = $composer['extra']['zm']['exclude-annotation-path'] ?? [];
foreach ($merge_psr4 as $k => $v) {
// 如果在排除表就排除,否则就解析注解
if (is_dir(SOURCE_ROOT_DIR . '/' . $v) && !in_array($v, $excludes)) {
// 添加解析路径对应Base命名空间也贴出来
$parser->addPsr4Path(SOURCE_ROOT_DIR . '/' . $v . '/', trim($k, '\\'));
}
}
$parser->addSpecialParser(Setup::class, function (Setup $setup) {
global $_tmp_setup_list;
$_tmp_setup_list[] = [
'class' => $setup->class,
'method' => $setup->method,
];
return true;
});
// TODO: 然后加载插件目录下的插件
// 解析所有注册路径的文件,获取注解
$parser->parse();
return json_encode(['setup' => $_tmp_setup_list]);
} catch (Throwable $e) {
$stderr = fopen('php://stderr', 'w');
fwrite($stderr, zm_internal_errcode('E00031') . $e->getMessage() . ' in ' . $e->getFile() . ' at line ' . $e->getLine() . PHP_EOL);
fclose($stderr);
exit(1);
}
}
// 在*nix等支持多进程环境的情况可直接运行此文件那么就执行
if (debug_backtrace() === []) {
require((!is_dir(__DIR__ . '/../../vendor')) ? getcwd() : (__DIR__ . '/../..')) . '/vendor/autoload.php';
echo _zm_setup_loader();
}

View File

@@ -1,99 +0,0 @@
<?php
namespace Module\Example;
use Framework\Console;
use ZM\Annotation\CQ\CQCommand;
use ZM\Annotation\Http\Middleware;
use ZM\Annotation\Http\RequestMapping;
use ZM\Annotation\Swoole\SwooleEventAt;
use ZM\Connection\CQConnection;
use ZM\Utils\ZMUtil;
/**
* Class Hello
* @package Module\Example
* @since 1.0
*/
class Hello
{
/**
* 在机器人连接后向终端输出信息
* @SwooleEventAt("open",rule="connectType:qq")
* @param $conn
*/
public function onConnect(CQConnection $conn) {
Console::info("机器人 " . $conn->getQQ() . " 已连接!");
}
/**
* 在机器人连接后向终端输出信息
* @SwooleEventAt("close",rule="connectType:qq")
*/
public function onDisconnect() {
$conn = ctx()->getConnection();
Console::info("机器人 " . $conn->getQQ() . " 已断开连接!");
}
/**
* 向机器人发送"你好",即可回复这句话
* @CQCommand(match="你好",alias={"你好啊","你是谁"})
*/
public function hello() {
return "你好啊,我是由炸毛框架构建的机器人!";
}
/**
* @CQCommand(".reload")
*/
public function reload() {
context()->reply("reloading...");
ZMUtil::reload();
}
/**
* @CQCommand("随机数")
* @CQCommand(regexMatch="*从*到*的随机数")
* @param $arg
*/
public function randNum($arg) {
// 获取第一个数字类型的参数
$num1 = context()->getArgs($arg, ZM_MATCH_NUMBER, "请输入第一个数字");
// 获取第二个数字类型的参数
$num2 = context()->getArgs($arg, ZM_MATCH_NUMBER, "请输入第二个数字");
$a = min(intval($num1), intval($num2));
$b = max(intval($num1), intval($num2));
// 回复用户结果
context()->reply("随机数是:".mt_rand($a, $b));
}
/**
* 中间件测试的一个示例函数
* @RequestMapping("/httpTimer")
* @Middleware("timer")
*/
public function timer() {
return "This page is used as testing TimerMiddleware! Do not use it in production.";
}
/**
* 默认示例页面
* @RequestMapping("/index")
* @RequestMapping("/")
*/
public function index() {
return "Hello Zhamao!";
}
/**
* 框架会默认关闭未知的WebSocket链接因为这个绑定的事件你可以根据你自己的需求进行修改
* @SwooleEventAt(type="open",rule="connectType:unknown")
*/
public function closeUnknownConn() {
Console::info("Unknown connection , I will close it.");
context()->getConnection()->close();
}
}

View File

@@ -0,0 +1,56 @@
<?php
declare(strict_types=1);
namespace Module\Example;
use OneBot\Driver\Coroutine\Adaptive;
use OneBot\Driver\Event\WebSocket\WebSocketMessageEvent;
use ZM\Annotation\Framework\Cron;
use ZM\Annotation\Http\Route;
use ZM\Annotation\Middleware\Middleware;
use ZM\Annotation\OneBot\BotCommand;
use ZM\Annotation\OneBot\BotEvent;
use ZM\Annotation\OneBot\CommandArgument;
use ZM\Annotation\OneBot\CommandHelp;
use ZM\Context\BotContext;
use ZM\Middleware\TimerMiddleware;
class Hello123
{
#[Route('/route', request_method: ['GET'])]
#[Middleware(TimerMiddleware::class)]
public function route()
{
return 'Hello ZhamaoThis is the first 3.0 page';
}
#[BotEvent()]
public function onOBEvent(\OneBotEvent $event, WebSocketMessageEvent $messageEvent): void
{
logger()->info("收到了 {$event->getType()}.{$event->getDetailType()} 事件");
}
#[BotCommand('echo', 'echo')]
#[CommandArgument('text', '要回复的内容', required: true)]
#[CommandHelp('复读机', '只需要发送 echo+内容 即可自动复读', 'echo 你好 会回复 你好')]
public function repeat(\OneBotEvent $event, BotContext $context): void
{
$context->reply($event->getMessage());
}
#[Cron('* * * * *', no_overlap: true)]
public function logTime(): void
{
$time = date('Y-m-d H:i:s');
logger()->info('我看到时间了,让我写下来');
Adaptive::sleep(5);
logger()->info('写好啦,时间是' . $time);
}
#[Cron('* * * * *')]
public function logTime2(): void
{
logger()->info('我不需要等,但也不给你看时间');
}
}

View File

@@ -1,38 +0,0 @@
<?php
namespace Module\Middleware;
use Framework\Console;
use ZM\Annotation\Http\After;
use ZM\Annotation\Http\Before;
use ZM\Annotation\Http\MiddlewareClass;
use ZM\Http\MiddlewareInterface;
/**
* Class AuthMiddleware
* 示例中间件:用于统计路由函数运行时间用的
* @package Module\Middleware
* @MiddlewareClass()
*/
class TimerMiddleware implements MiddlewareInterface
{
private $starttime;
/**
* @Before()
* @return bool
*/
public function onBefore() {
$this->starttime = microtime(true);
return true;
}
/**
* @After()
*/
public function onAfter() {
Console::info("Using " . round((microtime(true) - $this->starttime) * 1000, 2) . " ms.");
}
public function getName() { return "timer"; }
}

View File

@@ -1,29 +0,0 @@
<?php
namespace Scheduler;
use Swoole\Coroutine\Http\Client;
use Swoole\WebSocket\Frame;
class MessageEvent
{
/**
* @var Frame
*/
private $frame;
/**
* @var Client
*/
private $client;
public function __construct(Client $client, Frame $frame) {
$this->client = $client;
$this->frame = $frame;
}
public function onActivate() {
//TODO: 写Scheduler计时器内的处理逻辑
}
}

View File

@@ -1,140 +0,0 @@
<?php
namespace Scheduler;
use Exception;
use Framework\Console;
use Framework\GlobalConfig;
use Swoole\Coroutine;
use Swoole\Coroutine\Http\Client;
use Swoole\Process;
use Swoole\WebSocket\Frame;
class Scheduler
{
const PROCESS = 1;
const REMOTE = 2;
/**
* @var Process
*/
private $process = null;
/**
* @var int
*/
private $m_pid;
private $pid;
/**
* @var Scheduler
*/
private static $instance;
/**
* @var GlobalConfig
*/
private $settings;
/**
* @var Client
*/
private $client;
public function __construct($method = self::PROCESS, $option = []) {
if (self::$instance !== null) die("Cannot run two scheduler in on process!");
self::$instance = $this;
if ($method == self::PROCESS) $this->initProcess();
elseif ($method == self::REMOTE) $this->initRemote();
}
private function initProcess() { //TODO: 完成Process模式的代码
$m_pid = posix_getpid();
$this->process = new Process(function (Process $worker) use ($m_pid) { self::onWork($worker, $m_pid); }, false, 2, true);
$this->pid = $this->process->start();
while (1) {
$ret = Process::wait();
if ($ret) {
$this->process = new Process(function (Process $worker) use ($m_pid) { self::onWork($worker, $m_pid); }, false, 2, true);
$this->pid = $this->process->start();
echo "Reboot done.\n";
}
}
}
private function initRemote() {
define('WORKING_DIR', __DIR__ . '../..');
$this->requireGlobalFunctions();
$this->registerAutoloader('classLoader');
$this->settings = new GlobalConfig();
if (!$this->settings->success) die("Failed to load global config. Please check config/global.php file");
$this->defineProperties();
//start swoole Framework
$this->selfCheck();
try {
$host = $this->settings->get("scheduler")["host"];
$port = $this->settings->get("scheduler")["port"];
$token = $this->settings->get("scheduler")["token"];
$this->client = new Client($host, $port);
$path = "/" . ($token != "" ? ("?token=" . urlencode($token)) : "");
while (true) {
if ($this->client->upgrade($path)) {
while (true) {
$recv = $this->client->recv();
if ($recv instanceof Frame) {
(new MessageEvent($this->client, $recv))->onActivate();
} else {
break;
}
}
} else {
Console::warning("无法连接Framework将在5秒后重连...");
Coroutine::sleep(5);
}
}
} catch (Exception $e) {
Console::error($e);
}
}
private function requireGlobalFunctions() {
/** @noinspection PhpIncludeInspection */
require WORKING_DIR . '/src/Framework/global_functions.php';
}
private function registerAutoloader(string $string) {
if (!spl_autoload_register($string)) die("Failed to register autoloader named \"$string\" !");
}
private function defineProperties() {
define("ZM_START_TIME", microtime(true));
define("ZM_DATA", $this->settings->get("zm_data"));
//define("CONFIG_DIR", $this->settings->get("config_dir"));
define("CRASH_DIR", $this->settings->get("crash_dir"));
}
private function selfCheck() {
if (!extension_loaded("swoole")) die("Can not find swoole extension.\n");
if (!extension_loaded("sockets")) die("Can not find sockets extension.\n");
if (!function_exists("mb_substr")) die("Can not find mbstring extension.\n");
if (substr(PHP_VERSION, 0, 1) != "7") die("PHP >=7 required.\n");
//if (!class_exists("ZipArchive")) die("Can not find Zip extension.\n");
if (!file_exists(CRASH_DIR . "last_error.log")) die("Can not find log file.\n");
return true;
}
private static function onWork(Process $worker, $m_pid) {
swoole_set_process_name('php-scheduler');
for ($j = 0; $j < 16000; $j++) {
self::checkMpid($worker, $m_pid);
echo "msg: {$j}\n";
sleep(1);
}
}
private static function checkMpid(Process $worker, $m_pid) {
if (!Process::kill($m_pid, 0)) {
$worker->exit(); //主进程死了我也死
// 这句提示,实际是看不到的.需要写到日志中
echo "Master process exited, I [{$worker['pid']}] also quit\n";
}
}
}

View File

@@ -0,0 +1,14 @@
<?php
declare(strict_types=1);
namespace {namespace};
class {class}
{
#[\BotCommand(match: '测试{name}')]
public function firstBotCommand(\BotContext $ctx): void
{
$ctx->reply('这是{name}插件的第一个命令!');
}
}

Some files were not shown because too many files have changed in this diff Show More