Compare commits

...

684 Commits
1.2 ... 2.8.2

Author SHA1 Message Date
crazywhalecc
af75fc2f94 update docs 2022-08-03 17:14:40 +08:00
crazywhalecc
b94bbbca20 increment build number (build 476, 2.8.2) 2022-08-03 17:08:22 +08:00
crazywhalecc
784fc1697b cs fix 2022-08-03 17:03:33 +08:00
crazywhalecc
190eba585b update DataProvider relative=null condition and add tests 2022-08-03 16:59:48 +08:00
crazywhalecc
f97b87d5e5 cs fix 2022-08-03 16:37:46 +08:00
crazywhalecc
2c1a158d3e cs fix 2022-08-03 16:37:26 +08:00
Jerry Ma
90de54c6a3 update api PHPDoc 2022-08-03 16:32:24 +08:00
FishZe
d596c315f2 Update DataProvider.md 2022-08-03 16:32:24 +08:00
FishZe
52afaa3fb9 Update DataProvider.php 2022-08-03 16:32:24 +08:00
crazywhalecc
47cca37854 update docs 2022-07-03 14:12:04 +08:00
Github Build Bot
0fa49171b9 increment build number (build 475) 2022-07-03 05:14:16 +00:00
Github Build Bot
ea1d14ba00 update api docs 2022-07-03 05:14:15 +00:00
crazywhalecc
a01791ddbe Fix phpstan strict compare problem for STDIN 2022-07-03 13:13:29 +08:00
crazywhalecc
51a9c5c4e8 update version name to 2.8.1 2022-07-03 13:13:29 +08:00
crazywhalecc
b1e37943df fix bug #136 2022-07-03 13:13:29 +08:00
crazywhalecc
5459d1c5ff add @OnSave annotation docs 2022-06-14 13:30:35 +08:00
Jerry Ma
21373097bb Update route-annotations.md 2022-06-14 11:42:40 +08:00
Github Build Bot
f4f7327695 increment build number (build 474) 2022-05-21 09:42:07 +00:00
Github Build Bot
36fc2cb4cd update api docs 2022-05-21 09:42:06 +00:00
sunxyw
b7469b9dd4 tmp fix close connection binding warning (#128) 2022-05-21 17:40:43 +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
whale
c635891e0b fix multiple middleware registered in class annotation bug 2020-07-14 12:25:32 +08:00
whale
7b7a2d7010 update to 1.6 version 2020-07-11 15:53:30 +08:00
whale
23b1f797ad fix where body compiler 2020-07-10 21:11:00 +08:00
whale
a72e0f705c add Class-based custom annotation parsing 2020-07-06 19:06:02 +08:00
whale
504934f057 update to 1.5.8 version
add fullMatch to CQCommand.php
2020-06-26 15:53:40 +08:00
whale
e976a96d0b add auto-reconnect method to terminal_listener.php
add short name of ZM_BREAKPOINT (BP)
fix loop error of syntax happened
2020-06-20 14:51:24 +08:00
whale
dc7af105f4 deprecate ModBase, it will be removed in v1.6 2020-06-15 22:11:03 +08:00
whale
fd96543268 remove stupid access token 2020-06-15 19:51:32 +08:00
whale
cebc6fb310 update to 1.5.6 version
add CQCommand filter
add ZM_DEFAULT_FETCH_MODE
2020-06-15 19:50:07 +08:00
whale
c654cf40d5 update README.md 2020-06-13 17:45:29 +08:00
whale
68cc536af3 update to 1.5.5 version 2020-06-13 17:39:50 +08:00
whale
42412fee98 update init structure 2020-06-13 17:23:53 +08:00
whale
500ec4707e update Hello default module 2020-06-13 17:08:13 +08:00
whale
b09857e3b8 add init command of start commandline 2020-06-13 16:58:45 +08:00
whale
7d79126c8f fix stupid bug of rule parsing 2020-06-13 16:19:11 +08:00
whale
a542558503 close ws connection after calling event 2020-06-13 16:05:57 +08:00
whale
6697591a22 fix a bug 2020-06-13 14:09:25 +08:00
whale
aad28f1ec4 update to 1.5.4 version 2020-06-13 12:21:27 +08:00
whale
f1949b1bd0 remove stupid debug breakpoint 2020-06-13 11:29:09 +08:00
whale
3b8aac5d8f add CQCommand alias
switch spl_autoload to psr-4 autoload
2020-06-13 11:28:31 +08:00
whale
5fd45c2542 add sql_no_exception config 2020-06-13 10:17:14 +08:00
whale
af89c1b1f6 fix some sql bugs 2020-06-10 14:39:30 +08:00
whale
3287b96f30 update to 1.5.3 version 2020-06-10 13:24:04 +08:00
whale
00a8683658 update to 1.5.3 version
fix linux terminal input bug
2020-06-10 13:23:40 +08:00
whale
c0ea068d04 update to 1.5.2 version
add ZM_VERSION const
2020-06-08 23:52:55 +08:00
whale
9ba58ff90f remove ModBase to default Module 2020-06-05 19:54:20 +08:00
whale
1a1cf0ad30 update to 1.5.1 version 2020-06-05 19:31:43 +08:00
whale
1de93b9dc1 update to 1.5.1 version
fix a warning bug
2020-06-05 19:31:18 +08:00
Whale
99e44eea3d Merge pull request #12 from 854854321/patch-1
Update ZMRequest.php
2020-06-05 19:25:20 +08:00
Whale
e67958a8d1 Update ZMRequest.php 2020-06-05 19:24:56 +08:00
Whale
23b3dc34e2 Merge pull request #11 from 854854321/master
Update README.md
2020-06-05 18:51:52 +08:00
775672d515 Update ZMRequest.php
增加了http请求 传输 数据体
2020-06-05 18:31:55 +08:00
40e17fab62 Update README.md 2020-06-05 16:02:13 +08:00
whale
59fde3d075 update to 1.5 version 2020-06-05 13:36:30 +08:00
whale
a8183757be update to 1.4.1 version
fix uncaught PDOException
2020-05-31 14:22:39 +08:00
whale
8ae5844649 fix a bug 2020-05-23 17:40:08 +08:00
whale
acc96b78db fix a bug 2020-05-23 17:29:09 +08:00
whale
802f975825 update to version 1.4 2020-05-23 17:23:29 +08:00
whale
76ee308b91 add some exception log feature 2020-05-10 23:45:45 +08:00
whale
d9eca5d7b1 fix finalReply not working 2020-05-10 18:31:44 +08:00
whale
5144bc2094 update LICENSE of composer 2020-05-10 18:27:59 +08:00
whale
f7418de868 update to 1.3.2 version 2020-05-10 18:26:48 +08:00
whale
2bcbdcd3ca support Middleware of TimerTick 2020-05-10 18:25:51 +08:00
whale
013c78dc77 fix OnTick context bug 2020-05-10 14:40:18 +08:00
whale
886816e3d5 update to 1.3.1 version
fix DataProvider::setJsonData bug
add Root document of default request
⚠️ change MySQL driver to PDO, mysqlnd required
improve exception catcher
2020-05-10 14:11:32 +08:00
whale
81db9c6ccb update Dockerfile to fit mysqlnd 2020-05-10 00:52:40 +08:00
whale
ec88c56137 update README.md 2020-05-08 18:45:40 +08:00
whale
acb4bdf9b4 update to 1.3.0 version totally. 2020-05-08 16:37:38 +08:00
whale
a1b013ee53 update to 1.3.0 version. 2020-05-06 17:26:50 +08:00
whale
086c65af26 fix some DataProvider bug. 2020-05-06 17:25:09 +08:00
whale
9b3a2e5296 fix some DataProvider bug. 2020-05-06 17:19:59 +08:00
whale
181f6430a4 update CQ.php 2020-05-06 15:01:32 +08:00
whale
d5c192108e update Dockerfile 2020-05-03 16:38:27 +08:00
whale
0c28dda808 update Dockerfile 2020-05-03 12:03:56 +08:00
whale
b61eeccdb8 fix composer requirement 2020-05-03 11:41:05 +08:00
whale
19d618f167 update README.md 2020-05-02 23:36:54 +08:00
whale
17ce0c20ae update SECURITY.md 2020-05-02 23:28:11 +08:00
whale
82a1f86bbd update to 1.2.1
add phar build script
2020-05-02 23:27:26 +08:00
whale
97e579b8a1 update README.md 2020-04-29 18:11:21 +08:00
504 changed files with 38519 additions and 5327 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 framework --disable-console-input

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: |
一个简单的例子,展示该功能将如何被使用(包括代码、配置文件等)
如果这是针对已有功能的改进,请展示改进前后使用方式(或效能)的对比

View File

@@ -0,0 +1,69 @@
name: Increment Build Number
on:
pull_request:
branches:
- master
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@v2
- name: Setup PHP
uses: "shivammathur/setup-php@v2"
with:
php-version: '8.1'
extensions: swoole, posix, json
- name: Setup problem matchers for PHP
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"
- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache dependencies
uses: actions/cache@v2
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ runner.os }}-composer-
- name: Install Composer Dependencies
run: "composer install --prefer-dist --no-progress --optimize-autoloader"
- name: Generate API Docs
id: generate-api-docs
continue-on-error: true
run: bin/gendoc
- name: Commit api docs
if: steps.generate-api-docs.outcome == 'success'
continue-on-error: true
run: |
git config --global user.name 'Github Build Bot'
git config --global user.email 'noreply@github.com'
git add docs
git commit -m "update api docs"
git push
- name: Increment build number
run: sed -i -r 's/(.*)(\VERSION_ID\s=\s)([0-9]+)(.*)/echo "\1\2$((\3+1))\4"/ge' src/ZM/ConsoleApplication.php
- name: Commit build number
run: |
BUILD_ID=$(cat src/ZM/ConsoleApplication.php | grep "VERSION_ID = " | sed 's/[^0-9]//g')
git config --global user.name 'Github Build Bot'
git config --global user.email 'noreply@github.com'
git add src/ZM/ConsoleApplication.php
git commit -m "increment build number (build $BUILD_ID)"
git push

101
.github/workflows/integration-test.yml vendored Normal file
View File

@@ -0,0 +1,101 @@
name: Integration and Style Test
on:
push:
branches:
- master
paths:
- '**/**.php'
pull_request:
branches:
- master
types:
- opened
- synchronize
- reopened
- ready_for_review
- review_requested
paths:
- '**/**.php'
jobs:
integration:
name: Integration Test (PHP ${{ matrix.php-versions }}) (OS ${{ matrix.operating-system }})
runs-on: ${{ matrix.operating-system }}
strategy:
matrix:
operating-system: [ "ubuntu-latest", "macos-latest" ]
php-versions: [ "7.2", "7.3", "7.4", "8.0", "8.1" ]
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Setup PHP
uses: "shivammathur/setup-php@v2"
with:
php-version: ${{ matrix.php-versions }}
extensions: swoole, posix, json
env:
SWOOLE_CONFIGURE_OPTS: --enable-openssl
- name: Setup problem matchers for PHP
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"
- name: Validate composer.json
run: "composer validate --strict"
- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache dependencies
uses: actions/cache@v2
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ runner.os }}-composer-
- name: Install Composer Dependencies
run: "composer install --prefer-dist --no-progress --optimize-autoloader"
- name: Run Static Analysis
run: "composer analyse"
- name: Run PHPUnit
run: "composer test"
cs-check:
name: PHP CS Fixer Check
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Setup PHP 7.2
uses: "shivammathur/setup-php@v2"
with:
php-version: "7.2"
extensions: swoole, posix, json
- name: Setup problem matchers for PHP
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"
- name: Validate composer.json
run: "composer validate --strict"
- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache dependencies
uses: actions/cache@v2
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ runner.os }}-composer-
- name: Install Composer Dependencies
run: "composer install --prefer-dist --no-progress --optimize-autoloader"
- name: Run PHP CS Fixer Check
run: "composer cs-fix -- --dry-run --diff"

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

@@ -0,0 +1,43 @@
name: Docs and Script Auto Deploy
on:
push:
branches:
- master
paths:
- 'docs/**'
- 'ext/**'
jobs:
build:
name: Deploy docs
runs-on: ubuntu-latest
steps:
- name: Checkout master
uses: actions/checkout@v2
- 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.ZHAMAO_XIN_TARGET }}
- name: deploy script file
uses: wlixcc/SFTP-Deploy-Action@v1.0
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 }}

85
.gitignore vendored
View File

@@ -1,7 +1,80 @@
.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/
# 框架审计文件
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

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

@@ -0,0 +1,75 @@
<?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')
)
->setUsingCache(false);

View File

@@ -0,0 +1,17 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Reload Zhamao Server" type="ShConfigurationType">
<option name="SCRIPT_TEXT" value="./zhamao server:reload &amp;&amp; exit" />
<option name="INDEPENDENT_SCRIPT_PATH" value="true" />
<option name="SCRIPT_PATH" value="" />
<option name="SCRIPT_OPTIONS" value="" />
<option name="INDEPENDENT_SCRIPT_WORKING_DIRECTORY" value="true" />
<option name="SCRIPT_WORKING_DIRECTORY" value="$PROJECT_DIR$" />
<option name="INDEPENDENT_INTERPRETER_PATH" value="true" />
<option name="INTERPRETER_PATH" value="" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="EXECUTE_IN_TERMINAL" value="true" />
<option name="EXECUTE_SCRIPT_FILE" value="false" />
<envs />
<method v="2" />
</configuration>
</component>

View File

@@ -0,0 +1,17 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Run Zhamao Server" type="ShConfigurationType">
<option name="SCRIPT_TEXT" value="./zhamao server" />
<option name="INDEPENDENT_SCRIPT_PATH" value="true" />
<option name="SCRIPT_PATH" value="./zhamao" />
<option name="SCRIPT_OPTIONS" value="server" />
<option name="INDEPENDENT_SCRIPT_WORKING_DIRECTORY" value="true" />
<option name="SCRIPT_WORKING_DIRECTORY" value="$PROJECT_DIR$" />
<option name="INDEPENDENT_INTERPRETER_PATH" value="true" />
<option name="INTERPRETER_PATH" value="" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="EXECUTE_IN_TERMINAL" value="true" />
<option name="EXECUTE_SCRIPT_FILE" value="false" />
<envs />
<method v="2" />
</configuration>
</component>

17
.run/Run watcher.run.xml Normal file
View File

@@ -0,0 +1,17 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Run watcher" type="ShConfigurationType">
<option name="SCRIPT_TEXT" value="bin/watcher" />
<option name="INDEPENDENT_SCRIPT_PATH" value="true" />
<option name="SCRIPT_PATH" value="" />
<option name="SCRIPT_OPTIONS" value="" />
<option name="INDEPENDENT_SCRIPT_WORKING_DIRECTORY" value="true" />
<option name="SCRIPT_WORKING_DIRECTORY" value="$PROJECT_DIR$" />
<option name="INDEPENDENT_INTERPRETER_PATH" value="true" />
<option name="INTERPRETER_PATH" value="/bin/zsh" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="EXECUTE_IN_TERMINAL" value="true" />
<option name="EXECUTE_SCRIPT_FILE" value="false" />
<envs />
<method v="2" />
</configuration>
</component>

View File

@@ -0,0 +1,17 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Stop Zhamao Server" type="ShConfigurationType">
<option name="SCRIPT_TEXT" value="./zhamao server:stop &amp;&amp; exit" />
<option name="INDEPENDENT_SCRIPT_PATH" value="true" />
<option name="SCRIPT_PATH" value="" />
<option name="SCRIPT_OPTIONS" value="" />
<option name="INDEPENDENT_SCRIPT_WORKING_DIRECTORY" value="true" />
<option name="SCRIPT_WORKING_DIRECTORY" value="$PROJECT_DIR$" />
<option name="INDEPENDENT_INTERPRETER_PATH" value="true" />
<option name="INTERPRETER_PATH" value="" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="EXECUTE_IN_TERMINAL" value="true" />
<option name="EXECUTE_SCRIPT_FILE" value="false" />
<envs />
<method v="2" />
</configuration>
</component>

View File

@@ -1,15 +0,0 @@
FROM phpswoole/swoole:4.4.15-php7.3
WORKDIR /app/
RUN echo "Asia/Shanghai" > /etc/timezone
#RUN dpkg-configure -f noninteractive tzdata
ENV LANG C.UTF_8
VOLUME ["/app/zhamao-framework/"]
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
EXPOSE 20001
CMD ["bash", "/app/zhamao-framework-bak/.entry.sh"]

193
README.md
View File

@@ -1,87 +1,172 @@
# 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)
[![版本](https://img.shields.io/badge/version-1.2-green.svg)]()
<p align="center">
<a href="https://onebot.dev/">
<img src="https://img.shields.io/badge/OneBot-11-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/workflow/status/zhamao-robot/zhamao-framework/Integration%20and%20Style%20Test?label=Test&style=flat-square" alt="Integration Test">
</a>
一个异步、多平台兼容的 **聊天机器人** 框架。
<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://wpa.qq.com/msgrd?v=3&uin=627577391&site=qq&menu=yes">
<img src="https://img.shields.io/badge/作者QQ-627577391-orange?style=flat-square" alt="作者QQ">
</a>
<br>
<br>
<a href="https://github.com/zhamao-robot/zhamao-framework/search?q=AnnotationBase">
<img src="https://img.shields.io/github/search/zhamao-robot/zhamao-framework/AnnotationBase?label=Annotations&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&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 编写,采用 Swoole 扩展为基础,主要面向 API 服务聊天机器人OneBot 兼容的 QQ 机器人对接),包含 Websocket、HTTP
等监听和请求库,用户代码采用模块化处理,使用注解可以方便地编写各类功能。
除了起到解析消息的作用,炸毛框架 还提供了完整的 WebSocket + HTTP 服务器,你还能用此框架构建出高性能的 API 接口服务器
框架主要用途为 HTTP 服务器,机器人搭建框架。尤其对于 QQ 机器人消息处理较为方便和全面,提供了众多会话机制和内部调用机制,可以以各种方式设计你自己的模块
```php
/**
* @CQCommand("你好")
*/
public function hello() {
ctx()->reply("你好,我是炸毛!"); // 简单的命令式回复
}
/**
* @RequestMapping("/index")
*/
public function index() {
return "<h1>hello!</h1>"; // 快速的 HTTP 服务开发
}
```
> 从 2.7.0 版本开始,框架已支持同时使用 Annotation 和原生 Attribute 注解,供开发者根据需要自由选用。
## 开始
你可以使用 GitHub 的 `Use This Template` 功能快速将本项目克隆到你的公开或私有仓库,也可以从 `release` 中下载本项目的最新版本到本地私有开发。
框架目前支持 Linux、WSL、macOS 环境直接运行,上述环境可直接使用下方一键安装脚本。
> 如果你想在其他环境安装部署,可使用 Docker、Cygwin详见文档。
```bash
# 检测PHP环境、安装框架
bash <(curl -fsSL https://zhamao.xin/go.sh)
# 启动框架
cd zhamao-app
./zhamao server
```
一键安装脚本还有可以自定义参数的方式,比如:
```bash
# 脚本默认会检测系统的PHP如果想直接跳过检测安装独立的PHP版本则添加此环境变量
export ZM_NO_LOCAL_PHP="yes"
# 脚本如果安装独立版本PHP默认版本为8.0,如果想使用其他版本,则添加此环境变量指定版本
export ZM_DOWN_PHP_VERSION="8.1"
# 脚本默认会将框架在当前目录下的 `zhamao-app` 目录进行安装,如果想使用其他目录,则添加此环境变量
export ZM_CUSTOM_DIR="my-custom-app"
# 脚本默认会对本项目使用阿里云国内加速镜像如果想使用packagist源则添加此环境变量
export ZM_COMPOSER_PACKAGIST="yes"
# 执行完前面的环境变量再执行一键安装脚本,就可以实现自定义参数!
bash <(curl -fsSL https://zhamao.xin/go.sh)
```
关于其他安装方式,请参阅[文档](https://framework.zhamao.xin/guide/installation.html) 。
## 文档
本项目文档正在努力编写中。
Pages[https://framework.zhamao.xin/](https://framework.zhamao.xin/)
查看文档(国内自建):<https://framework.zhamao.xin/>
如果上面的访问较慢,可以访问国内服务器:[https://framework2.zhamao.xin/](https://framework2.zhamao.xin/)
备用链接(国外托管):<https://framework.zhamao.me/>
## 特点
- 支持多账号
- 灵活的注解事件绑定机制
- 采用模块化编写,功能之间高内聚低耦合
- 常驻内存,全局缓存变量随处使用
- 自带 MySQL 查询器、数据库连接池等数据库连接方案
- 自带 HTTP 服务器、WebSocket 服务器可复用,可以构建属于自己的 HTTP API 接口
- 静态文件服务器
## 炸毛特色模块
- 原生支持多个机器人客户端同时连接
- 使用 Swoole 多工作进程机制和协程加持,尽可能简单的情况下提升了性能
- 灵活的注解事件绑定机制,可同时使用 Annotation 和原生 Attribute 注解
- 易用的上下文,模块内随处可用
- 采用模块化编写,可自由搭配其他 Composer 组件,也可单文件面向过程编写
- 支持模块打包、热加载,分享模块更方便
- 常驻内存,全局缓存变量随处使用,提供多种缓存方案
- 自带 MySQL、Redis 等数据库连接池等数据库连接方案
- 本身为 HTTP 服务器、WebSocket 服务器,可以构建属于自己的 HTTP API 接口
- 静态文件服务器,可将前端合并到一起
- 自带 PHP + Swoole 环境无需手动编译安装by [crazywhalecc/static-php-cli](https://github.com/crazywhalecc/static-php-cli)
| 模块名称 | 说明 | 模块地址 |
| ------------------ | -------------------------------- | ------------------------------------------------------------ |
| 微信公众号兼容模块 | 为框架提供微信公众号订阅号兼容层 | [zhamao-wechat-patch](https://github.com/zhamao-robot/zhamao-wechat-patch) |
| 通用模块 | 图片上传和下载模块 | [zhamao-general-tools](https://github.com/zhamao-robot/zhamao-general-tools) |
## 下载源码
## 计划开发内容
- [ ] WebSocket测试脚本客户端
- [X] Session 和中间层管理模块
- [ ] 支持本地和远程两种方式的定时器(计划任务)
- [X] 常驻服务脚本
- [ ] 一些常用的通用 API 例如经济(用户积分、亲密度等)的模块
- [ ] 图灵机器人/腾讯AI 聊天模块
- [ ] 分词模块(可能会放弃计划,因为目前好用的分词都是其他语言的)
- [ ] HTTP 过滤器、Auth 模块、完整的 MVC 兼容(可能会放弃计划,因为框架主打机器人开发)
- [ ] Redis 连接池或开箱即用的相应功能内置
- [ ] 2.0 版本抛弃 `ModBase` 继承结构,完全使用上下文代替
- [X] 更好的 Logger稳定和漂亮的控制台输出
- [ ] 日志服务
- [ ] 模块支持 Phar 打包(可能会比较靠后支持)
- [ ] 兼容面向过程的模块编写方案(可能会比较靠后支持)
- [ ] 完整的单元测试(如果有需求则尽快开发)
- [X] 静态文件服务器
框架源码可直接克隆本仓库进行编辑,如果你在国内,访问 GitHub 和克隆仓库比较慢,可以将 `github.com` 替换为 `fgit.zhamao.me` 进行加速。
## 从 cqbot-swoole 升级
目前新的框架采用了全新的注解机制,所以旧版的框架上写的模块到新框架需要重新编写。当然为了减少工作量,新的框架也最大限度地保留了旧版框架编写的风格,一般情况下根据新版框架的文档仅需修改少量地方即可完成重写。
旧版框架并入了 `old` 分支,如果想继续使用旧版框架请移步分支。升级过程中如果遇到问题可以找作者。
例如:`git clone https://fgit.zhamao.me/zhamao-robot/zhamao-framework.git --depth 1`
## 贡献和捐赠
如果你在使用过程中发现任何问题,可以提交 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年初起稳定运行了**四年半**,并且持续迭代
欢迎随时在 HTTP-API 插件群里提问,当然更好的话可以加作者 QQ[627577391](http://wpa.qq.com/msgrd?v=3&uin=627577391&site=qq&menu=yes)
或提交 [Issue](https://github.com/zhamao-robot/zhamao-framework/issues/new/choose) 进行疑难解答。
本项目在更新内容时,请及时关注 GitHub 动态,更新前请将自己的模块代码做好备份。
项目框架采用 Apache-2.0 协议开源,在分发或重写修改等操作时需遵守协议。项目模块部分(`Module` 文件夹) 在非借鉴框架内代码时可不遵守 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">
感谢 [php-libonebot](https://github.com/botuniverse/php-libonebot) 开发者 @sunxyw 中为项目开发规范化提出的一些建议。
<!-- ![star](https://starchart.cc/zhamao-robot/zhamao-framework.svg) -->

View File

@@ -1,13 +0,0 @@
# Security Policy
## Supported Versions
| Version | Supported |
| ------- | ------------------ |
| 1.2 | :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.

401
bin/gendoc Executable file
View File

@@ -0,0 +1,401 @@
#!/usr/bin/env php
<?php
/**
* 决定是否忽略该类
*
* @param ReflectionClass $class 准备生成的类的反射类
*/
function should_ignore_class(ReflectionClass $class): bool
{
// 注解类
if (($doc = $class->getDocComment()) && strpos($doc, '@Annotation') !== false) {
return true;
}
if (str_ends_with($class->getName(), 'Exception')) {
return true;
}
if (str_contains($class->getName(), '_')) {
return true;
}
return false;
}
if (PHP_VERSION_ID < 70400) {
echo 'PHP 版本必须为 7.4 或以上';
exit(1);
}
function check_composer_executable(string $composer): bool
{
passthru($composer . ' --version 2>/dev/null', $exit_code);
return $exit_code === 0;
}
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);
}
echo '根目录: ' . $root . PHP_EOL;
chdir($root);
if (!is_dir($root . '/src/ZM')) {
echo '源码目录不存在';
exit(1);
}
$phpdoc_package_temp_installed = false;
if (file_exists($root . '/vendor/jasny/phpdoc-parser/composer.json')) {
echo '正在使用现有的 PHPDoc 解析库' . PHP_EOL;
} else {
echo 'PHPDoc 解析库不存在,正在尝试安装...' . PHP_EOL;
echo '本次生成完成后将会自动移除' . PHP_EOL;
$composers = [
'runtime/composer', 'composer', 'php composer.phar',
];
foreach ($composers as $composer) {
if (check_composer_executable($composer)) {
echo '正在使用 ' . $composer . ' 安装 PHPDoc 解析库,请稍候...' . PHP_EOL;
passthru("{$composer} require --quiet jasny/phpdoc-parser", $exit_code);
if ($exit_code === 0) {
$phpdoc_package_temp_installed = true;
break;
}
}
}
if (!$phpdoc_package_temp_installed) {
echo '安装失败请手动安装composer require jasny/phpdoc-parser' . PHP_EOL;
exit(1);
}
}
// 从这里开始是主要生成逻辑
require_once $root . '/vendor/autoload.php';
use Jasny\PhpdocParser\PhpdocParser;
use Jasny\PhpdocParser\Set\PhpDocumentor;
use Jasny\PhpdocParser\Tag\Summery;
use ZM\Console\Console;
$opts = getopt('', ['show-warnings', 'show-debug']);
if (array_key_exists('show-warnings', $opts)) {
$show_warnings = true;
} else {
$show_warnings = false;
}
Console::init(array_key_exists('show-debug', $opts) ? 4 : 2);
$errors = [];
$warnings = [];
// 获取源码目录的文件遍历器
$fs = new \RecursiveDirectoryIterator($root . '/src/ZM', FilesystemIterator::SKIP_DOTS);
// 初始化文档解析器
$parser = new PhpdocParser(PhpDocumentor::tags()->with([
new Summery(),
]));
$metas = [];
$class_count = 0;
$method_count = 0;
function error(string $message)
{
global $errors;
$errors[] = $message;
Console::error($message);
}
function warning(string $message)
{
global $warnings, $show_warnings;
$warnings[] = $message;
if ($show_warnings) {
Console::warning($message);
}
}
/**
* 获取类的元数据
*
* 包括类的注释、方法的注释、参数、返回值等
*/
function get_class_metas(string $class_name, PhpdocParser $parser): array
{
// 尝试获取反射类
try {
$class = new \ReflectionClass($class_name);
} catch (\ReflectionException $e) {
error('无法获取类 ' . $class_name . ' 的反射类');
return [];
}
// 判断是否略过该类
if (should_ignore_class($class)) {
return [];
}
$metas = [];
// 遍历类方法
foreach ($class->getMethods() as $method) {
if ($method->getDeclaringClass()->getName() !== $class_name) {
continue;
}
Console::verbose('正在解析方法:' . $class_name . '::' . $method->getName());
// 获取方法的注释并解析
$doc = $method->getDocComment();
if (!$doc) {
warning('找不到文档:' . $class_name . '::' . $method->getName());
continue;
}
try {
$meta = $parser->parse($doc);
} catch (\Exception $e) {
error('解析失败:' . $class_name . '::' . $method->getName() . '' . $e->getMessage());
continue;
}
// 少数情况解析后会带有 */,需要去除
array_walk_recursive($meta, static function (&$item) {
if (is_string($item)) {
$item = trim(str_replace('*/', '', $item));
}
});
// 对比反射方法获取的参数和注释声明的参数
$parameters = $method->getParameters();
$params_in_doc = $meta['params'] ?? [];
foreach ($parameters as $parameter) {
$parameter_name = $parameter->getName();
// 不存在则添加进参数列表中
if (!isset($params_in_doc[$parameter_name])) {
$params_in_doc[$parameter_name] = [
'type' => $parameter->getType()?->getName(),
'description' => '',
];
}
}
// 确保所有参数都有对应的类型和描述
foreach ($params_in_doc as &$param) {
if (!isset($param['type'])) {
$param['type'] = 'mixed';
}
if (!isset($param['description'])) {
$param['description'] = '';
}
}
// 清除引用
unset($param);
$meta['params'] = $params_in_doc;
// 设定方法默认返回值
if (!isset($meta['return'])) {
$meta['return'] = [
'type' => $method->getReturnType()?->getName() ?: 'mixed',
'description' => '',
];
}
// 设定默认描述
if (!isset($meta['return']['description'])) {
$meta['return']['description'] = '';
}
$metas[$method->getName()] = $meta;
}
return $metas;
}
/**
* 将方法的元数据转换为 Markdown 格式
*
* @param string $method 方法名
* @param array $meta 元数据
*/
function convert_meta_to_markdown(string $method, array $meta): string
{
// 方法名作为标题
$markdown = '## ' . $method . "\n\n";
// 构造方法代码块
$markdown .= '```php' . "\n";
// TODO: 适配 private 等修饰符
$markdown .= 'public function ' . $method . '(';
$params = [];
// 添加参数
foreach ($meta['params'] as $param_name => $param_meta) {
$params[] = sprintf('%s $%s', $param_meta['type'] ?? 'mixed', $param_name);
}
$markdown .= implode(', ', $params) . ')';
// 添加返回值
$markdown .= ': ' . $meta['return']['type'];
$markdown .= "\n```\n\n";
// 方法描述
$markdown .= '### 描述' . "\n\n";
$markdown .= ($meta['description'] ?? '作者很懒,什么也没有说') . "\n\n";
// 参数
if (count($meta['params'])) {
$markdown .= '### 参数' . "\n\n";
$markdown .= '| 名称 | 类型 | 描述 |' . "\n";
$markdown .= '| -------- | ---- | ----------- |' . "\n";
foreach ($meta['params'] as $param_name => $param_meta) {
$markdown .= '| ' . $param_name . ' | ' . $param_meta['type'] . ' | ' . $param_meta['description'] . ' |' . "\n";
}
$markdown .= "\n";
}
// 返回值
$markdown .= '### 返回' . "\n\n";
$markdown .= '| 类型 | 描述 |' . "\n";
$markdown .= '| ---- | ----------- |' . "\n";
$markdown .= '| ' . $meta['return']['type'] . ' | ' . $meta['return']['description'] . ' |' . "\n";
return $markdown;
}
function generate_sidebar_config(string $title, array $items): array
{
return [
'title' => $title,
'collapsable' => true,
'children' => $items,
];
}
Console::info('开始生成!');
// 遍历类并将元数据添加至数组中
foreach (new \RecursiveIteratorIterator($fs) as $file) {
if (!$file->isFile()) {
continue;
}
$path = $file->getPathname();
// 过滤不包含类的文件
$tokens = token_get_all(file_get_contents($path));
$found = false;
foreach ($tokens as $k => $token) {
if (!is_array($token)) {
continue;
}
if ($token[0] === T_CLASS && $tokens[$k - 2][0] !== T_NEW) {
$found = true;
break;
}
if ($k >= 100) {
break;
}
}
if (!$found) {
continue;
}
// 获取完整类名
$path = ltrim($path, $root . '/');
$class = str_replace(['.php', 'src/', '/'], ['', '', '\\'], $path);
Console::verbose('正在解析类:' . $class);
$meta = get_class_metas($class, $parser);
// 忽略不包含任何方法的类
if (empty($meta)) {
continue;
}
$metas[$class] = $meta;
++$class_count;
$method_count += count($meta);
}
// 将元数据转换为 Markdown
$markdown = [];
foreach ($metas as $class => $class_metas) {
$markdown[$class] = [];
// 将类名作为页面大标题
$markdown[$class]['class'] = '# ' . $class;
foreach ($class_metas as $method => $meta) {
$markdown[$class][$method] = convert_meta_to_markdown($method, $meta);
}
}
// 生成文档
$docs = $root . '/docs/api/';
foreach ($markdown as $class => $methods) {
$file = $docs . str_replace('\\', '/', $class) . '.md';
// 确保目录存在
if (!file_exists(dirname($file)) && !mkdir($concurrent_directory = dirname($file), 0777, true) && !is_dir($concurrent_directory)) {
throw new \RuntimeException(sprintf('无法建立目录 %s', $concurrent_directory));
}
Console::verbose('正在生成文档:' . $file);
$text = implode("\n\n", $methods);
file_put_contents($file, $text);
}
// 生成文档目录
$children = array_keys($markdown);
$children = str_replace('\\', '/', $children);
$class_tree = [];
foreach ($children as $child) {
$parent = dirname($child);
$class_tree[$parent][] = $child;
}
ksort($class_tree);
$config = 'module.exports = [';
foreach ($class_tree as $parent => $children) {
$encode = json_encode(generate_sidebar_config($parent, $children));
$encode = str_replace('\/', '/', $encode);
$config .= $encode . ',';
}
$config = rtrim($config, ',');
$config .= ']';
$file = $root . '/docs/.vuepress/api.js';
file_put_contents($file, $config);
if (count($warnings)) {
Console::warning('生成过程中发现 ' . count($warnings) . ' 次警告');
if (!$show_warnings) {
Console::info('生成器默认忽略了警告,你可以通过 gendoc --show-warnings 来查看警告');
}
}
if (count($errors)) {
Console::error('生成过程中发现错误:');
foreach ($errors as $error) {
Console::error($error);
}
}
Console::success('API 文档生成完毕');
Console::success(sprintf('共生成 %d 个类,共 %d 个方法', $class_count, $method_count));
// 完成生成,进行善后
if ($phpdoc_package_temp_installed) {
echo '正在移除 PHPDoc 解析库,请稍候...' . PHP_EOL;
passthru('composer remove --quiet jasny/phpdoc-parser', $exit_code);
if ($exit_code !== 0) {
echo '移除失败请手动移除composer remove jasny/phpdoc-parser' . PHP_EOL;
}
echo '移除完成';
}
exit(0);

111
bin/phpunit-swoole Executable file
View File

@@ -0,0 +1,111 @@
#!/usr/bin/env php
<?php
/** For Swoole coroutine tests */
// 如果改成 true则会在终端显示所有炸毛框架的 Log
const ZM_TEST_LOG_DEBUG = false;
use PHPUnit\Runner\Version;
use PHPUnit\TextUI\TestRunner;
use Swoole\Coroutine;
use ZM\Annotation\Swoole\OnStart;
use ZM\Command\RunServerCommand;
use ZM\Console\Console;
use ZM\ConsoleApplication;
use ZM\Event\EventManager;
use ZM\Framework;
use ZM\Store\ZMAtomic;
use ZM\Utils\ZMUtil;
$root = dirname(__DIR__);
Coroutine::set([
'log_level' => SWOOLE_LOG_INFO,
'trace_flags' => 0,
]);
/*
* This file is part of PHPUnit.
*
* (c) Sebastian Bergmann <sebastian@phpunit.de>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
if (PHP_VERSION_ID <= 70100) {
fwrite(
STDERR,
sprintf(
'This version of PHPUnit is supported on PHP 7.1 and above.' . PHP_EOL .
'You are using PHP %s (%s).' . PHP_EOL,
PHP_VERSION,
PHP_BINARY
)
);
exit(1);
}
if (!ini_get('date.timezone')) {
ini_set('date.timezone', 'Asia/Shanghai');
}
require $root . '/vendor/autoload.php';
const ZM_VERSION_ID = ConsoleApplication::VERSION_ID;
const ZM_VERSION = ConsoleApplication::VERSION;
// 模拟define
const ZM_PROCESS_MASTER = 1;
const ZM_PROCESS_MANAGER = 2;
const ZM_PROCESS_WORKER = 4;
const ZM_PROCESS_USER = 8;
const ZM_PROCESS_TASKWORKER = 16;
define('FRAMEWORK_ROOT_DIR', $root);
define('WORKING_DIR', $root);
const SOURCE_ROOT_DIR = WORKING_DIR;
define('LOAD_MODE', is_dir(SOURCE_ROOT_DIR . '/src/ZM') ? 0 : 1);
chdir(__DIR__ . '/../');
$options = array_map(function ($x) {
return $x->getDefault();
}, RunServerCommand::exportDefinition()->getOptions());
$options['disable-safe-exit'] = true;
$options['worker-num'] = 1;
$options['private-mode'] = true;
$options['log-error'] = true;
spl_autoload_register(static function ($class) {
$map = [
TestRunner::class => 'vendor/phpunit/phpunit/src/TextUI/TestRunner.php',
Version::class => 'vendor/phpunit/phpunit/src/Runner/Version.php',
];
if (isset($map[$class])) {
$source = file_get_contents(SOURCE_ROOT_DIR . '/' . $map[$class]);
$source = str_replace(['#StandWith', 'Ukraine', 'declare(strict_types=1);'], '', $source);
eval('?>' . $source);
}
}, true, true);
Console::setLevel(0);
$framework = new Framework($options);
$start = new OnStart();
$start->method = function () {
try {
Console::setLevel(ZM_TEST_LOG_DEBUG ? 4 : 0);
$retcode = PHPUnit\TextUI\Command::main(false);
} finally {
Console::setLevel(0);
ZMUtil::stop(($retcode ?? 1) !== 0);
}
};
EventManager::addEvent(OnStart::class, $start);
$framework->start();
Swoole\Event::wait();
if (ZMAtomic::get('stop_signal')->get() === 2) {
exit(1);
}

View File

@@ -1,51 +1,34 @@
#!/usr/bin/env php
<?php
#!/bin/sh
use Framework\FrameworkLoader;
use Scheduler\Scheduler;
# shellcheck disable=SC2068
# shellcheck disable=SC2181
# author: crazywhalecc
# since: 2.5.0
require __DIR__ . '/../src/Framework/FrameworkLoader.php';
require __DIR__ . '/../src/Scheduler/Scheduler.php';
if [ -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
Swoole\Coroutine::set([
'max_coroutine' => 30000,
]);
result=$(echo "$1" | grep -E "module|build")
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 '':
case 'framework':
case 'server':
if(!is_dir(__DIR__.'/../vendor/')){
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\n\n";
break;
default:
echo "Unknown option \"{$argv[1]}\"!\n\"--help\" for more information\n";
break;
}
if [ "$result" != "" ]; then
executable="$executable -d phar.readonly=off"
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

View File

@@ -1,26 +0,0 @@
#!/usr/bin/env php
<?php /** @since 1.2 */
switch ($argv[1] ?? '') {
case '--generate':
generate();
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() {
$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();
$s .= "\nExecStart=" . getcwd() . "/bin/start server --disable-console-input";
$s .= "\nRestart=always\n\n[Install]\nWantedBy=multi-user.target\n";
file_put_contents(getcwd() . "/resources/zhamao.service", $s);
echo "File successfully generated. Path: " . getcwd() . "/resources/zhamao.service\n";
}

View File

@@ -1,3 +0,0 @@
#!/bin/bash
composer update

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

View File

@@ -1,33 +1,107 @@
{
"name": "zhamao/framework",
"description": "high-performance intelligent assistant",
"minimum-stability": "stable",
"license": "proprietary",
"version": "1.2.0",
"description": "High performance chat robot and web server development framework",
"license": "Apache-2.0",
"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"
}
],
"require": {
"swoole/ide-helper": "@dev",
"ext-mbstring": "*",
"swlib/saber": "^1.0",
"doctrine/annotations": "<1.10.2",
"php": "^7.2 || ^7.3 || ^7.4 || ^8.0 || ^8.1",
"ext-json": "*",
"ext-posix": "*",
"ext-ctype": "*",
"ext-pcntl": "*"
"doctrine/dbal": "^2.13.1",
"dragonmantank/cron-expression": "^3.3",
"jelix/version": "^2.0",
"koriym/attributes": "^1.0",
"psr/container": "^2.0",
"psy/psysh": "^0.11.2",
"symfony/console": "~6.0 || ~5.0 || ~4.0 || ~3.0",
"symfony/polyfill-ctype": "^1.19",
"symfony/polyfill-mbstring": "^1.19",
"symfony/polyfill-php80": "^1.16",
"symfony/routing": "~6.0 || ~5.0 || ~4.0 || ~3.0",
"zhamao/config": "^1.0",
"zhamao/connection-manager": "^1.0",
"zhamao/console": "^1.0",
"zhamao/request": "^1.1"
},
"repositories": {
"packagist": {
"type": "composer",
"url": "https://mirrors.aliyun.com/composer/"
"require-dev": {
"brainmaestro/composer-git-hooks": "^2.8",
"friendsofphp/php-cs-fixer": "^3.2 != 3.7.0",
"jetbrains/phpstorm-attributes": "^1.0",
"phpstan/phpstan": "^1.1",
"phpunit/phpunit": "^8.5 || ^9.0",
"roave/security-advisories": "dev-latest",
"swoole/ide-helper": "^4.5"
},
"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": "stable",
"prefer-stable": true,
"autoload": {
"psr-4": {
"ZM\\": "src/ZM"
},
"files": [
"src/ZM/global_functions.php"
]
},
"autoload-dev": {
"psr-4": {
"Module\\": "src/Module",
"Custom\\": "src/Custom",
"Tests\\": "tests"
}
},
"bin": [
"bin/gendoc",
"bin/phpunit-swoole",
"bin/start"
],
"config": {
"optimize-autoloader": true,
"sort-packages": true,
"allow-plugins": {
"phpstan/extension-installer": true
}
},
"extra": {
"hooks": {
"post-merge": "composer install",
"pre-commit": [
"echo committing as $(git config user.name)",
"composer cs-fix -- --diff"
],
"pre-push": [
"composer cs-fix -- --dry-run --diff",
"composer analyse"
]
},
"zm": {
"exclude-annotation-path": [
"src/ZM",
"tests"
]
}
},
"scripts": {
"post-install-cmd": [
"[ $COMPOSER_DEV_MODE -eq 0 ] || vendor/bin/cghooks add"
],
"analyse": "phpstan analyse --memory-limit 300M",
"cs-fix": "php-cs-fixer fix",
"test": "bin/phpunit-swoole --no-coverage"
}
}

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": ""
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,79 +1,152 @@
<?php
global $config;
/** bind host */
/** @noinspection PhpComposerExtensionStubsInspection */
declare(strict_types=1);
/* bind host */
$config['host'] = '0.0.0.0';
/** bind port */
/* bind port */
$config['port'] = 20001;
/** 框架开到公网或外部的HTTP访问链接通过 DataProvider::getFrameworkLink() 获取 */
$config['http_reverse_link'] = "http://127.0.0.1:".$config['port'];
/* 框架开到公网或外部的HTTP访问链接通过 DataProvider::getFrameworkLink() 获取 */
$config['http_reverse_link'] = 'http://127.0.0.1:' . $config['port'];
/** 存放框架内文件数据的目录 */
$config['zm_data'] = WORKING_DIR.'/zm_data/';
/* 框架是否启动debug模式当debug模式为true时启用热更新需要安装inotify扩展 */
$config['debug_mode'] = false;
/** 存放各个模块配置文件的目录 */
$config['config_dir'] = $config['zm_data'].'config/';
/* 存放框架内文件数据的目录 */
$config['zm_data'] = realpath(WORKING_DIR) . '/zm_data/';
/** 存放崩溃和运行日志的目录 */
$config['crash_dir'] = $config['zm_data'].'crash/';
/* 存放各个模块配置文件的目录 */
$config['config_dir'] = $config['zm_data'] . 'config/';
/** 对应swoole的server->set参数 */
/* 存放崩溃和运行日志的目录 */
$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' => 0
'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
];
/** 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'
/* 一些框架与框架运行时设置的调整 */
$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' => [],
],
];
/** CQHTTP连接约定的token */
$config["access_token"] = "";
/* 轻量字符串缓存,默认开启 */
$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,
];
/** HTTP服务器固定请求头的返回 */
/* 大容量跨进程变量存储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'] = [
'X-Powered-By' => 'zhamao-framework',
'Content-Type' => 'text/html; charset=utf-8'
'Server' => 'zhamao-framework',
'Content-Type' => 'text/html; charset=utf-8',
];
/** HTTP服务器在指定状态码下回复的页面默认 */
/* HTTP服务器在指定状态码下回复的页面默认 */
$config['http_default_code_page'] = [
'404' => '404.html'
'404' => '404.html',
];
/** zhamao-framework在框架启动时初始化的atomic们 */
/* 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等级
// 'custom_atomic_name' => 0, //自定义添加的Atomic
];
/** 自动保存的缓存保存时间(秒 */
$config['auto_save_interval'] = 900;
/* 终端日志显示等级0-4 */
$config['info_level'] = 2;
/** 上下文接口类 implemented from ContextInterface */
/* 上下文接口类 implemented from ContextInterface */
$config['context_class'] = \ZM\Context\Context::class;
/** 静态文件访问 */
/* 静态文件访问 */
$config['static_file_server'] = [
'status' => false,
'document_root' => WORKING_DIR . '/resources/html',
'document_root' => realpath(__DIR__ . '/../') . '/resources/html',
'document_index' => [
'index.html'
]
'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;

6
config/motd.txt Normal file
View File

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

1
docs/.vuepress/api.js Normal file
View File

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

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>

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

@@ -0,0 +1,192 @@
const apiConfig = require('./api')
module.exports = {
title: '炸毛框架',
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: '组件', link: '/component/' },
{ text: '进阶', link: '/advanced/' },
{ text: 'API', link: '/api/' },
{ text: 'FAQ', link: '/faq/' },
{ text: '更新日志', link: '/update/v2/' },
{ text: '炸毛框架 v1', link: 'https://docs-v1.zhamao.xin/' }
],
sidebar: {
'/guide/': [
{
title: '指南',
collapsable: false,
sidebarDepth: 1,
children: [
'',
'installation',
'quickstart-robot',
'quickstart-http',
'onebot-choose',
'basic-config',
'write-module',
'register-event',
'upgrade',
'errcode'
]
}
],
'/event/': [
{
title: '事件和注解',
collapsable: false,
sidebarDepth: 1,
children: [
'',
'robot-annotations',
'route-annotations',
'framework-annotations',
'middleware',
'custom-annotations',
'event-dispatcher'
]
}
],
'/component/': [
'',
{
title: '聊天机器人组件',
collapsable: true,
sidebarDepth: 2,
children: [
'bot/robot-api-12',
'bot/robot-api',
'bot/cqcode',
'bot/message-util',
'bot/access-token',
'bot/turing-api',
'bot/help-generator.md',
]
},
{
title: '存储组件',
collapsable: true,
sidebarDepth: 2,
children: [
'store/light-cache',
'store/mysql',
'store/mysql-db',
'store/redis',
'store/atomics',
'store/spin-lock',
'store/data-provider'
]
},
{
title: '通用组件',
collapsable: true,
sidebarDepth: 2,
children: [
'common/context',
'common/coroutine-pool',
'common/singleton-trait',
'common/zmutil',
'common/global-functions',
'common/console',
'common/task-worker',
'common/remote-terminal',
'common/event-tracer'
]
},
{
title: 'HTTP 组件',
collapsable: true,
sidebarDepth: 2,
children: [
'http/zmrequest',
'http/route-manager'
]
},
{
title: '模块/插件管理',
collapsable: true,
sidebarDepth: 2,
children: [
'module/module-pack',
'module/module-unpack'
]
}
],
'/advanced/': [
'',
{
title: '框架高级开发',
collapsable: true,
sidebarDepth: 2,
children: [
'framework-structure',
'custom-start',
'manually-install',
'inside-class',
'multi-process',
'task-worker'
]
},
{
title: '开发实战教程',
collapsable: true,
sidebarDepth: 2,
children: [
'connect-ws-client',
'example/admin',
'example/integrate-qingyunke-chatbot',
'example/weather-bot'
]
},
],
'/api/': apiConfig,
'/faq/': [
'',
'to-v2',
'usual-question',
'address-already-in-use',
'display-deadlock',
'light-cache-wrong',
'wait-message-cqbefore'
],
'/update/': [
{
title: '更新日志',
collapsable: true,
sidebarDepth: 0,
children: [
'v2',
'v1',
'build-update'
]
},
'config'
]
}
}
}

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

39
docs/README.md Normal file
View File

@@ -0,0 +1,39 @@
---
home: true
heroImage: ./logo_trans.png
actionBtn:
text: 快速上手
link: /guide/
type: primary
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/go.sh)
```
## 运行框架
```bash
cd zhamao-app/
./zhamao server
```
## 效果图
![index_demo](/index_demo.png)

4
docs/advanced/README.md Normal file
View File

@@ -0,0 +1,4 @@
# 进阶开发
在本章,下面的部分将详细说明一些具体的案例和自定义框架的操作。
> 更多进阶教程敬请期待....(或者你可以选择提 Issue 到框架 GitHub有需求就写入文档

View File

@@ -0,0 +1,144 @@
# 接入 WebSocket 客户端
炸毛框架其实从本质上讲,就是一个 HTTP + WebSocket 服务器,所以框架也支持对接其他任何 HTTP 客户端和 WebSocket 客户端,实际上炸毛框架非常适合用 WebSocket 做在线的 IM 聊天通讯,也可以方便地进行 WS 通信。这里主要说明如何对接一个自定义的 WebSocket 客户端。
## 类型指定
由于 WebSocket 连接都具有同样的性质,没有状态,所以在建立 WebSocket 连接的时候,需要客户端表明自己的身份和类型。指定客户端连接类型的方式有两种:
- `GET` 参数传递,在连接的时候,加上 GET 参数 `type` 即可。比如 js 中 WebSocket 建立时地址写:`ws://127.0.0.1:20001/?type=foo`,这时传入的连接就是 `foo` 类型。
- `Header` 传递,用户需要在建立连接时指定 HTTP 的头部信息 `X-Client-Role`,例如 `X-Client-Role: foo`,这时传入的连接就是 `foo` 类型。
以上两种方式,`Header` 方式比 `GET` 方式优先级要高,如果两者均没有指定,框架会将此连接当作 `default` 类型接入。
::: tip 提示
对于对接 OneBot 标准的机器人客户端,只要符合 OneBot 标准,即 `X-Client-Role` 会自动带上 `universal``qq` 等字样,就会自动标记为 `qq` 类型。
:::
## 逻辑编写
传入连接后,我们就能通过注解事件绑定来做我们自己想做的事情了!比如下方是传入类型为 foo 连接要做的事情
```php
<?php
namespace Module\Example;
use ZM\Annotation\Swoole\OnOpenEvent;
use ZM\Console\Console;
use ZM\ConnectionManager\ConnectionObject;
class Hello {
/**
* @OnOpenEvent("foo")
*/
public function onFooConnect(ConnectionObject $conn) {
Console::info($conn->getName()." 已连接!");
}
```
以上作用就是在终端输出 `foo 已连接!` 这个提示的。关于 `ConnectionObject` 对象,见下方。
## WS 连接对象
对于每一个 WebSocket 连接,框架内都有一个专属的操作类,有获取类型名称、保存链接参数和属性以及获取文件标识符等功能。
### getFd()
获取文件标示符,用于发送消息、接收消息等。这个参数获取的 `fd` 是 Swoole 指定的,用于发送信息等。
```php
$fd = $conn->getFd();
server()->send($fd, "hello world");
```
> WebSocket 是全双工的,所以发送和接收其实是互不干扰的,你可以不仅仅在 WebSocket 相关的上下文中,还可以比如在 HTTP 或者机器人上下文中给别的 WebSocket 客户端发请求。
### getName()
获取连接对象绑定的连接类型,例如上方提到的 `foo``default` 等。
```php
Console::info("当前连接类型:".$conn->getName()); //当前连接类型foo
```
### setName()
改变连接对象绑定的连接类型,例如从 `foo` 改为 `bar`
```php
$s = $conn->getName(); // foo
$conn->setName("bar");
$s = $conn->getName(); // bar
```
### getOptions()
获取此连接存储的所有参数,以数组形式。存储内容见下方 `setOption()`
格式:`["参数1" => {参数1的值}, "参数2" => {参数2的值}]`
### getOption()
获取此连接存储的参数,获取指定名称的,此方法拥有一个参数 `$key`,指定即可获取。
如果没有对应参数,则返回 `null`
我们在前面的机器人部分知道,框架主要是用于机器人的连接,那么机器人客户端在连接后,比如我们想知道这个机器人的 WS 连接对应的是哪个 QQ 号的机器人,我们就可以用 `getOption("connect_id")` 来获取。这个 `connect_id` 是 OneBot 标准的客户端接入后自动填入的一个参数。例如,我们想在机器人接入后打出接入机器人的 QQ 号:
```php
/**
* @OnOpenEvent("qq")
*/
public function onQQConnect($conn) {
Console::success("机器人 ".$conn->getOption("connect_id")." 已连接!"); // 机器人 123456 已连接!
}
```
### setOption()
设置连接存储的参数。参数:`setOption($key, $value)``$key` 限定为 `connect_id` 一种。(因为目前有了 LightCache所以这里暂时不提供别的 key 设定)
```php
$conn->setOption("connect_id", "asdasdasd"); // $value 最长长度为 29
```
## 发送到 WebSocket 客户端
很简单,从上面获取到 `fd` 后使用下面的方式就可以了~
```php
server()->push($conn->getFd(), "hello"); // 第二个为 string 类型的参数
```
## 从客户端接收
接收消息必须从 `@OnMessageEvent` 注解事件下接收,使用上下文 `ctx()->getFrame()` 获取消息帧。
从这里获取的 `Frame` 对象,见 [Swoole 文档 - Frame](https://wiki.swoole.com/#/websocket_server?id=swoolewebsocketframe)。
Frame 对象有四个参数:
- `$frame->fd`:获取发来帧的 fd
- `$frame->data`:数据本体
- `$frame->opcode`:数据类型 int 值,见 [Swoole 文档 - 数据帧类型](https://wiki.swoole.com/#/websocket_server?id=%e6%95%b0%e6%8d%ae%e5%b8%a7%e7%b1%bb%e5%9e%8b)
- `$frame->finish`是否发送完毕bool
下面以接收一个 json 字符串为例,并进行后续的解析:
```php
/**
* @OnMessageEvent("foo")
*/
public function onMessage() {
$frame = ctx()->getFrame();
$json_str = $frame->data; // 假设传入的是 {"key1":"value1","k2":"v2"}
$json = json_decode($json_str, true);
Console::info("key1 的值是:" . $json["key1"]);
}
```
## 关闭连接
```php
server()->close($conn->getFd());
```

View File

@@ -0,0 +1,136 @@
# 框架高级启动
## 框架下载方式
从前面的几章中,我们了解到框架有多种下载到本地的方式。
- Composer 依赖模式
- Starter 从模板创建模式(等同于 Composer 模式)
- 源码模式
- Phar Composer 依赖模式
- Phar 源码模式
### Composer 依赖模式
从 Composer 依赖加载框架是一种拉取框架的方式,这种方式的优点在于,你可以直观地感受到是如何使用框架从零开始一个完整的项目的过程。
从 Composer 依赖的启动步骤:
```bash
mkdir my-bot # 新建一个空的文件夹
cd my-bot/
composer require zhamao/framework # 从 composer 拉取后会自动部署 autoload 和 composer.json 等内容
# 使用命令初始化框架
vendor/bin/start init
# 启动框架
vendor/bin/start server
```
注意:使用 `init` 命令时,会给当前目录解压以下文件:
```php
$extract_files = [
"/config/global.php", // 全局配置文件
"/.gitignore", // git 排除文件
"/config/file_header.json", // HTTP 文件头
"/config/console_color.json", // 终端颜色主题文件
"/config/motd.txt", // 框架启动时自定义的 motd
"/src/Module/Example/Hello.php", // 框架自带的示例模块
"/src/Module/Middleware/TimerMiddleware.php", // 框架自带的函数运行时间监控中间件
"/src/Custom/global_function.php" // 用户可在这里自定义编写自己的全局函数
];
```
经过 init 解压这些文件后,你的框架就能正常运行且开始编写代码了!
### Starter 模板模式
从模板新建其实原理和 Composer 依赖模式完全一样,只不过,这个过程是使用模板仓库新建的项目,使用 Composer 自带的 `create-project` 方式创建的。starter 也是一个 GitHub 项目,见 [地址](https://github.com/zhamao-robot/zhamao-framework-starter)。
```bash
composer create-project zhamao/framework-starter my-bot/ # my-bot 是你自定义的文件夹名称,和上方相同
cd my-bot
vendor/bin/start server # 启动框架
```
Starter 模式相当于直接从 GitHub 拉取 `zhamao-framework-starter` 项目,然后执行 `composer update`
那和 Composer 依赖模式有什么区别呢?没区别!构建出来的框架和文件是一模一样的!使用 Composer 依赖模式,使用 `init` 命令后,文件会和 `zhamao-framework-starter` 仓库拉取回来的模板一模一样!(或者换句话说,这个仓库就是使用 `init` 命令生成的文件的)
那使用哪种好呢?看你自己!如果你想给你自己的已有项目套上炸毛框架,那么就推荐使用 Composer 依赖模式,如果是从 0 开始编写框架模块,则推荐使用模板模式。
### 源码模式
源码模式和以上两种方案都不一样,源码模式允许你对框架本身进行一系列修改,框架本体就可以直接运行。
Composer 依赖模式(以及模板模式)和源码模式的区别是:
- 依赖模式和模板模式是通过 library 方式引入框架的,框架本身会放在 composer 的 `vendor/` 目录下,从 composer 引入的 library 相当于子集vendor 目录下的文件最好不要手动修改(应该都知道吧),所以框架本身也只是加载了进来。
- 源码模式相当于直接从框架源码目录运行框架和模块,框架源码都在 `src/ZM` 目录下,默认的示例模块都在 `src/Module` 下,是同级目录。而此时的 `vendor/` 目录只包含了框架依赖的外部组件,例如注解解析器和 psysh 等。
源码模式可以方便地调试和修改框架本身,拉取方式很简单,用 `git clone` 或从 GitHub 下载最新版的源码包解压即可。
```bash
git clone https://github.com/zhamao-robot/zhamao-framework.git
cd zhamao-framework/
bin/start server # 第一次运行时会提示一个“框架源码模式需要在autoload文件中添加Module目录为自动加载”
composer update # 更新 autoload 文件,应用刚才上一步添加的 `src/Module` 文件夹下的模块自动加载
bin/start server # 通过源码模式启动框架
```
## 框架启动参数
框架启动时可以根据实际情况指定启动参数。
- `--debug-mode`:启用调试模式,调试模式的作用是关闭一键协程化和终端交互,减少 Swoole 本身对代码逻辑的干扰(比如执行 `shell_exec()` 报错的话可以开启这个进行调试)。
- `--log-{mode}`:设置 log 等级。支持 `--log-debug``--log-verbose``--log-info``--log-warning``--log-error`
- `--log-theme`:设置终端信息的主题。这个选项适用于多种终端信息显示的兼容,例如白色终端和不支持颜色的终端。详见 [Console - 主题设置](/component/console/#_2)。
- `--disable-coroutine`:关闭一键协程化。
- `--remote-terminal`:开启 nc 远程终端,配置文件使用全局中的 `remote_terminal` 项。也可以在全局配置中常开启status 设置为 true
- `--daemon`:以守护进程方式运行框架,此参数将直接在输出 motd 后将进程挂到 init 下运行,后台常驻。
- `--watch`:监控 `src/` 目录下的文件变化,有变化则自动重新载入代码。开启监控需要安装 PHP 扩展inotify。使用 pecl 就可以安装:`pecl install inotify`。(注:不支持 WSL 和 macOS
- `--env`:设置运行环境,设置运行环境后将优先加载指定环境的配置文件,支持 `--env=production``--env=staging``--env=development`,见 [基本配置](/guide/basic-config/#_2)。
- `--worker-num`:指定运行的工作进程数量(并不是越多越好,框架默认为 CPU 核心数),例如 `--worker-num=8`
- `--task-worker-num`:启用 TaskWorker 进程并指定数量。
- `--show-php-ver`:在启动时显示 Swoole 和 PHP 的版本。
## 守护进程操作命令
守护进程在 2.2.0 版本开始,可以使用命令行快速操作,如重启、停止、查看状态等。
注意,这里的守护进程操作命令是指 **使用 `--daemon` 方式启动的框架**,如使用 Docker、screen、tmux、systemd 等方式挂后台跑则此命令不可用!
```bash
vendor/bin/start daemon:status # 查看守护进程的状态
vendor/bin/start daemon:reload # 重载框架
vendor/bin/start daemon:stop # 停止运行守护进程的框架
```
## 独立启动其他组件
框架默认不止启动框架的 `server` 命令,还有 `init` 命令和 `simple-http-server` 命令。`init` 命令在上方 Composer 依赖模式中提到过,就是初始化各个文件的。
### 独立 HTTP 文件服务器
如果你只需要一个静态文件服务器,类似 Nginx那么框架也支持。
```bash
vendor/bin/start simple-http-server your-web-dir/ --host=0.0.0.0 --port=8080
```
- `your-web-dir` 是必填的参数。
- `--host``--port` 是可选参数,如果不填,则默认使用 `global.php` 配置文件中的配置。
### 检查配置是否更新
默认情况下(非源码模式),你可以使用命令 `vendor/bin/start check:config` 来检查你的配置文件是否需要更新部分段落。
### systemd 配置文件生成器
框架支持生成 systemd 配置文件 `zhamao.service`,生成后将文件放入 `/etc/systemd/system` 后输入 `systemctl enable zhamao.service` 即可。
命令:`vendor/bin/start systemd:generate`
注意systemd 启动的守护进程模式和使用参数 `--daemon` 不一样,请勿同时混用,直接使用上述命令生成的配置文件即可正常使用!

View File

@@ -0,0 +1,229 @@
# 编写管理员专属功能
众所周知,如果大家使用炸毛框架来开发聊天机器人的话,会比较方便。但是有些地方你一定会感觉还是欠缺了点,比如下面这样,你想编写一个只能由机器人管理员,也就是你自己,才能触发的功能:
```php
/**
* @CQCommand(match="禁言",message_type="group")
*/
public function banSomeone() {
$r1 = ctx()->getNextArg("请输入禁言的人或at他");
$r2 = ctx()->getFullArg("请输入禁言的时间(秒)");
$cq = CQ::getCQ($r1);
if ($cq !== null) {
if ($cq["type"] != "at") return "请at或者输入正确的QQ号";
$r1 = $cq["params"]["qq"];
}
// 群内禁言用户
ctx()->getRobot()->setGroupBan(ctx()->getGroupId(), $r1, $r2);
return "禁言成功!";
}
```
这时候,如果只是自己有绝对的权利,可以将自己的 QQ 号写死在注解 `@CQCommand` 中,并限定 `user_id`(假设我的 QQ 号码为 123456
```php
/**
* @CQCommand(match="禁言",message_type="group",user_id=123456)
*/
```
但是,随着时间的推移,你的机器人伙伴群可能越来越大,这个命令可能不止需要绝对的你来使用,你还要将机器人的部分权利下发给更多的伙伴,怎么办呢?注解里面只能写死的。
答案很简单这时候我们就需要用到框架提供的中间件Middleware。中间件说白了就是在事件执行前、后、过程中抛出的异常对其进行阻断和插入代码比如我们上方在触发禁言这个注解事件前首先要判断执行这个命令的是不是钦定的管理员。
## 第一步:定义中间件
首先,我们需要定义一个中间件。在框架默认提供的脚手架中,包含了一个叫 `TimerMiddleware.php` 的示例中间件,这个示例中间件的目的是非常简单的,就是判断这个注解事件运行了多长时间。假设你有一个机器人功能,这个功能下的代码需要执行很长时间,可以使用这一注解轻松将事件执行的时间打印到终端上。
关于中间件的有关说明,见 [中间件](/event/middleware)。
下面我们假设你已经阅读过中间件注解的文档了,我们着手编写一个判断指令执行者是否是指定的管理员 QQ 的中间件。为了省事和让大家方便地复现,我先在脚手架下的目录 `src/Module/Middleware/` 下新建 PHP 类文件 `AdminMiddleware.php`(和 `TimerMiddleware.php` 在同一个目录)。
```php
<?php
namespace Module\Middleware;
use ZM\Annotation\Http\HandleBefore;
use ZM\Annotation\Http\MiddlewareClass;
use ZM\Exception\ZMException;
use ZM\Http\MiddlewareInterface;
use ZM\Store\LightCache;
/**
* Class AdminMiddleware
* 示例中间件:用于动态管理一些管理员指令的中间件
* @package Module\Middleware
* @MiddlewareClass("admin")
*/
class AdminMiddleware implements MiddlewareInterface
{
/**
* @HandleBefore()
* @return bool
* @throws ZMException
*/
public function onBefore(): bool {
$r = ctx()->getUserId(); // 从上下文获取发消息的用户 QQ
$admin_list = LightCache::get("admin_list") ?? []; // 从轻量缓存获取管理员列表
return in_array($r, $admin_list); // 返回这个 QQ 是否在管理员列表中
}
}
```
其中,`@MiddlewareClass("admin")` 的意思是,定义这个类为名字叫 `admin` 的中间件,同时,所有中间件的类**必须**带上 `implements MiddlewareInterface`,统一接口形式。
`@HandleBefore()` 代表的是这个类下的这个函数onBefore被标注为这个中间件的 `onBefore` 事件,也就是说,如果有别的注解事件插入了这个 `admin` 中间件,那么执行对应注解事件前都要执行一下 `@HandleBefore` 所绑定的这个函数。而这个绑定的函数只能返回 `bool` 类型的值哦!
## 第二步:使用中间件
使用中间件很简单,在需要阻断的注解事件绑定的函数上再加一个注解就好了!我们以上方的禁言例子说明:
```php
/**
* @Middleware("admin")
* @CQCommand(match="禁言",message_type="group")
*/
```
<chat-box :my-chats="[
{type:0,content:'禁言 1234567 600'},
{type:1,content:'禁言成功!'},
{type:2,content:'假设我不在管理员名单里'},
{type:0,content:'禁言 1234567 900'},
{type:2,content:'机器人没有回复,因为中间件返回了 false不继续执行'},
]"></chat-box>
而这时候有朋友又要问了,如果我有一系列管理员命令,假设都在一个叫 `AdminFunc.php` 的模块类里,我是不是还得一个一个地给注解事件写 `@Middleware("admin")` 呢?当然不需要!如果你这个类所有的注解事件都是机器人的聊天事件(`@CQCommand``@CQMessage`)的话,可以直接给类注解这个中间件,效果等同于给每一个函数写一次中间件注解。
```php
<?php
namespace Module\Example;
use ZM\Annotation\Http\Middleware;
/**
* Class AdminFunc
* @package Module\Example
* @Middleware("admin")
*/
class AdminFunc
{
// ...这里是你的一堆注解事件的函数
}
```
## 第三步:补全代码
上面我们讲到了,中间件里面使用了 `LightCache` 轻量缓存来储存临时的管理员列表,那么我们将这部分的代码完善吧!
**src/Module/Example/AdminFunc.php**
```php
<?php
namespace Module\Example;
use ZM\Annotation\CQ\CQCommand;
use ZM\Annotation\Http\Middleware;
use ZM\API\CQ;
/**
* Class AdminFunc
* @package Module\Example
* @Middleware("admin")
*/
class AdminFunc
{
/**
* @CQCommand(match="禁言",message_type="group")
*/
public function banSomeone() {
$r1 = ctx()->getNextArg("请输入禁言的人或at他");
$r2 = ctx()->getFullArg("请输入禁言的时间(秒)");
$cq = CQ::getCQ($r1);
if ($cq !== null) {
if ($cq["type"] != "at") return "请at或者输入正确的QQ号";
$r1 = $cq["params"]["qq"];
}
// 群内禁言用户
ctx()->getRobot()->setGroupBan(ctx()->getGroupId(), $r1, $r2);
return "禁言成功!";
}
/**
* @CQCommand(match="解除禁言",message_type="group")
*/
public function unbanSomeone() {
$r1 = ctx()->getNextArg("请输入禁言的人或at他");
$cq = CQ::getCQ($r1);
if ($cq !== null) {
if ($cq["type"] != "at") return "请at或者输入正确的QQ号";
$r1 = $cq["params"]["qq"];
}
// 群内禁言用户
ctx()->getRobot()->setGroupBan(ctx()->getGroupId(), $r1, 0);
return "解除禁言成功!";
}
}
```
**src/Module/Example/AdminManager.php**
```php
<?php
namespace Module\Example;
use ZM\Annotation\CQ\CQCommand;
use ZM\Annotation\Http\Middleware;
use ZM\Annotation\Swoole\OnStart;
use ZM\Store\LightCache;
use ZM\Store\Lock\SpinLock;
class AdminManager
{
/**
* @OnStart()
*/
public function onStart() {
if (!LightCache::isset("admin_list")) { //一次性代码首次执行才会执行if
LightCache::set("admin_list", [ // 框架启动时初始化管理员列表
"123456",
"234567"
], -2); // 这里用 -2 的原因是将这一列表持久化保存,避免关闭框架后丢失
}
}
/**
* @CQCommand(match="添加管理员")
* @Middleware("admin")
*/
public function addAdmin() { //只有管理员才能添加管理员
$qq = ctx()->getNextArg("请输入要添加管理员的QQ(qq号码不可at");
SpinLock::lock("admin_list"); //如果是多进程模式的话需要加锁
$ls = LightCache::get("admin_list");
if (!in_array($qq, $ls)) $ls[] = $qq;
LightCache::set("admin_list", $ls, -2);
SpinLock::unlock("admin_list"); //如果是多进程模式的话需要加锁
return "成功添加 $qq 到管理员列表!";
}
}
```
<chat-box :my-chats="[
{type:2,content:'现在我是 123456'},
{type:0,content:'禁言 13579 60'},
{type:1,content:'禁言成功!'},
{type:0,content:'解除禁言 13579'},
{type:1,content:'解除禁言成功!'},
{type:0,content:'添加管理员 98765'},
{type:1,content:'成功添加 98765 到管理员列表!'},
{type:2,content:'现在我是98765'},
{type:0,content:'禁言 13579'},
{type:1,content:'请输入禁言的时间(秒)'},
{type:0,content:'120'},
{type:1,content:'禁言成功!'},
]"></chat-box>

View File

@@ -0,0 +1,85 @@
# 接入青云客智能聊天机器人API
作为一个群聊机器人,懂得聊天会让机器人增色不少,在大数据和 AI 热潮下,不少厂商都研发了自己的智能聊天 API例如图灵机器人、腾讯智能闲聊等大厂开发的 API 自然有着他人无可比拟的健壮性和可靠性,但是随之而来不菲的价格显然并不适合大众开发者。这时候一个免费、可用的智能聊天 API 便非常重要了,其中,青云客是少有的完全免费、无需注册的智能聊天 API提供了包括智能聊天、歌词、天气查询、笑话等多种有用功能且接入简单非常适合新手开发者尝试。
## 结果演示
![圖片](https://user-images.githubusercontent.com/31698606/158875192-108698a3-b54e-4fc0-889a-0829ca328b13.png)
## 阅读接入指南
不管接入何种服务,阅读接入指南永远都是最优先、最重要的一步,所幸青云客的接入指南十分简单,简单来说归纳为以下:
* 请求GET https://api.qingyunke.com/api.php
* 参数:
* * `key` 目前固定为 `free`
* * `appid` 目前固定为 `0`
* * `msg` 关键词,需要经过 `urlencode`
* 注意:返回结果中 `{br}` 代表换行
## 逻辑编写
阅读过后,我们便可以进行主要的编写工作了。
首先,为了机器人的性能考虑,也为了避免过分打扰群聊的聊天,我们希望机器人只有在主动触发(@AT 或者 关键词等)时才会进行智能聊天。
对于关键词匹配,我们可以使用 `@CQCommand`
```php
/**
* 智能聊天
*
* @CQCommand(start_with="机器人")
*/
public function chat()
{
// 替换掉机器人前缀,并获取消息内容
$msg = ctx()->getMessage();
$msg = str_replace('机器人', '', $msg);
if (empty(trim($msg))) {
$msg = ctx()->getFullArg('怎么了?');
}
Console::info('正在获取智能聊天回复:' . $msg);
// 请求 API 获取回复
$raw_data = file_get_contents('https://api.qingyunke.com/api.php?key=free&appid=0&msg=' . urlencode($msg));
try {
$data = json_decode($raw_data, true, 512, JSON_THROW_ON_ERROR);
} catch (\Exception $e) {
$data = ['content' => '机器人解析异常,请稍后再试'];
Console::warning('无法获取智能聊天回复:' . $e->getMessage());
}
if ($data['result'] !== 0) {
$data = ['content' => '机器人服务异常,请稍后再试'];
Console::warning('无法获取智能聊天回复:' . $raw_data);
}
Console::info('获取智能聊天回复完成:' . $data['content']);
// 将 {br} 替换为换行
$data['content'] = strtr($data['content'], ['{br}' => "\n"]);
return $data['content'];
}
```
这样我们的命令便只会在用户发送以`机器人`开头的消息时才会触发。
同时,我们也希望在 @AT 机器人时也进行回复,此时可以使用 `@CQBefore` 方法进行折中:
```php
/**
* 将 AT 机器人的消息交由智能聊天处理
*
* @CQBefore("message")
*/
public function changeAt(): bool
{
// 判断此条消息是否 AT 了机器人
if (MessageUtil::isAtMe(ctx()->getMessage(), ctx()->getRobotId())) {
// 将 AT 本身从消息中去掉
$msg = str_replace(CQ::at(ctx()->getRobotId()), '', ctx()->getMessage());
ctx()->setMessage('机器人' . trim($msg));
// 调用智能聊天
ctx()->reply($this->chat());
return false;
}
return true;
}
```

View File

@@ -0,0 +1,113 @@
# 基于词性分析和魅族天气的天气查询机器人
本文将基于 [`jieba-php`](https://github.com/fukuball/jieba-php) 中文分词库以及 [魅族天气 API](https://github.com/shichunlei/-Api/blob/master/MeizuWeather.md) 开发一个天气查询机器人。
## 结果演示
![圖片](https://user-images.githubusercontent.com/31698606/159122016-61ba9696-5786-4561-b371-827d9f1d01aa.png)
尾部的随机表情并非本教程的一部分。
## 逻辑编写
[jieba-php](https://github.com/fukuball/jieba-php) 是目前比较好用的中文分词库,虽然最近的维护并不活跃,但已足够我们的需求:
```shell
composer require fukuball/jieba-php:dev-master
```
以下代码使用了本文作者自行编写的天气查询库,需要进行引入:
```shell
composer require sunxyw/weather
```
您也可以将以下代码自行改写为直接调用魅族天气 API详情请参阅[魅族天气 API 文档](https://github.com/shichunlei/-Api/blob/master/MeizuWeather.md)。
```php
<?php
namespace Bot\Module\SmartChat;
use Fukuball\Jieba\Jieba;
use Fukuball\Jieba\Posseg;
use Sunxyw\Weather\Weather;
use ZM\Annotation\CQ\CQCommand;
use ZM\Console\Console;
class WeatherReport
{
/**
* 加载字典
*
* @OnStart(worker_id=-1)
*
* @return void
*/
public function initDictionary(): void
{
// 分词以及词性分析需要载入字典到内存
ini_set('memory_limit', '600M');
Jieba::init(['dict' => 'small']);
Posseg::init();
}
/**
* 查询天气
*
* @CQCommand(keyword="天气")
*
* @return string
*/
public function cmdQueryWeather(): string
{
// 分词并进行词性分析
$seg_list = Posseg::cut(ctx()->getMessage());
$tags = array_column($seg_list, 'tag');
// 找出词性为 ns地名的单词
$location_index = array_search('ns', $tags, true);
$location = $seg_list[$location_index]['word'];
// 此处引入了本文作者自己写的天气库
$w = new Weather();
try {
$report = $w->getWeather($location);
} catch (\InvalidArgumentException) {
return '城市输入错误';
} catch (\JsonException $e) {
Console::warning("天气查询失败:{$e->getMessage()}");
return '天气查询失败';
}
$template = <<<EOF
%s天气%s
温度:%s℃
湿度:%s%%
风向:%s %s
空气质量:%s
------------------------------
未来三天天气:
%s%s日间%s℃夜间%s℃吹%s %s
%s%s日间%s℃夜间%s℃吹%s %s
%s%s日间%s℃夜间%s℃吹%s %s
EOF;
$args = [
$report->getCity(),
$report->getRealtime()['weather'],
$report->getRealtime()['temperature'],
$report->getRealtime()['humidity'],
$report->getRealtime()['wind_direction'],
$report->getRealtime()['wind_speed'],
$report->getRealtime()['air_quality'],
];
foreach (array_slice($report->getForecastDaily(), 0, 3) as $forecast) {
$args[] = $forecast['date'];
$args[] = $forecast['weather'];
$args[] = $forecast['temperature']['day'];
$args[] = $forecast['temperature']['night'];
$args[] = $forecast['wind_direction'];
$args[] = $forecast['wind_speed'];
}
return vsprintf($template, ...$args);
}
}
```

View File

@@ -0,0 +1,5 @@
# 框架剖析
## 框架运行总结构图
![](https://static.zhamao.me/images/docs/a23d8a952cf9c88d395888d220605a4f.png)

View File

@@ -0,0 +1,67 @@
# 内部类文件手册
这个章节写明了在框架使用过程中可能涉及到的框架内部或 Swoole、其他 composer 依赖组件的内部类,这里会根据类的命名空间一一说明。
## Swoole\Http\Request
此类是 Swoole 内部的一个类,一般在收到 HTTP 请求时,在 `@RequestMapping``@OnRequestEvent()` 两个注解下可用,用作获取 GET、POST参数上传到后端的文件、Cookies 等。详见 [Swoole 文档 - Request](http://wiki.swoole.com/#/http_server?id=httprequest) 。
### 属性
- `$fd`:获取当前连接的文件描述符 ID。
- `$header``HTTP` 请求的头部信息。类型为数组,所有 `key` 均为小写。
- `$server``HTTP` 请求相关的服务器信息。
- `$cookie`:获取 Cookies。
- `$get`:获取 GET 参数。
- `$post`:获取 POST 参数。
- `$files`:获取上传的文件信息
### 方法
- `rawContent()`:获取 POST 包原始二进制内容,相当于原生 PHP 的 ` file_get_contents("php://input");`
- `getData()`:获取完整的原始 `Http` 请求报文。包括 `Http Header``Http Body`
### 示例
```php
TODO先放一放。
```
## ZM\Entity\MatchObject
此类是调用方法 `MessageUtil::matchCommand()` 返回的对象体,含有匹配成功与否和匹配到的注解相关的信息。
### 属性
- `$match``bool` 类型,返回匹配是否成功
- `$object``CQCommand` 注解类,如果匹配成功则返回对应的 `@CQCommand` 信息
- `match``array` 类型,如果匹配成功则返回匹配到的参数
```php
// 假设我有一个注解事件 @CQCommand(match="你好"),绑定的函数是 \Module\Example\Hello 下的 hello123()
$obj = MessageUtil::matchCommand("你好 我叫顺溜 我今年二十八", ctx()->getData());
/* 以下是返回信息,仅供参考
$obj->match ==> true
$obj->object ==> \ZM\Annotation\CQ\CQCommand: (
match: "你好",
pattern: "",
regex: "",
start_with: "",
end_with: "",
keyword: "",
alias: [],
message_type: "",
user_id: 0,
group_id: 0,
discuss_id: 0,
level: 20,
method: "hello123",
class: \Module\Example\Hello::class
)
$obj->match ==> [
"我叫顺溜",
"我今年二十八"
]
*/
```

View File

@@ -0,0 +1,3 @@
# 手动部署环境教程
TODO: 还没写

View File

@@ -0,0 +1,72 @@
# 框架多进程
首先对于多进程概念,对于传统 PHP 程序员可能比较陌生,唯一接触到的地方可能就是 php-fpm 等一些方式处理时间长的请求时开进程去执行。关于多进程,我觉得廖雪峰的 Python 多进程这段讲的不错:
> Unix/Linux 操作系统提供了一个`fork()`系统调用,它非常特殊。普通的函数调用,调用一次,返回一次,但是`fork()`调用一次,返回两次,因为操作系统自动把当前进程(称为父进程)复制了一份(称为子进程),然后,分别在父进程和子进程内返回。
这里面的重点在于,多进程的创建,是父进程的复制,然后两个进程接下来运行的代码和存的内容就分道扬镳了。
PHP 也是如此,框架的多进程又是怎么一回事呢?为什么要采用多进程呢?
## 作用
使用过框架的你一定知道,框架是以命令行方式运行 PHP 的,而命令行方式运行 PHP就代表要常驻内存就像 Python、Node.js 一样。而默认情况下,比如 Python 的 Flask 为单线程单进程模式,也就是说同时只能处理一个 Web 请求。但大部分情况下,比如 Node.js提供的都是异步 I/O这也就是说明它在 Web 处理请求上,可同时承接的 I/O 密集型请求会更多一些,这样在对一般的 Web 应用中 I/O 密集型场景非常有用,而且往往只需要单进程也可以承载上万的并发请求。
在炸毛框架中,因为框架基于 Swoole 构建,所以天然支持协程,而协程就是针对 I/O 操作进行一个调度,类似异步的 Node.js所以针对项目中存在太多的 SQL 语句执行、文件读写的话,炸毛框架直接上手,无需做任何修改,也可以达到很好的性能。
**但是**CPU 密集型的应用怎么办呢?假设我的 Web 应用有大量的排序、md5 运算怎么办呢?这样的阻塞,假设是一个超级大的 for 循环或者是要执行很长时间的 while 循环CPU 一直在被占用。多进程就是针对 CPU 密集型的应用说 yes 的一个方案。
![diagram](https://static.zhamao.me/images/docs/06c17ab473f17ab10523a938cdbd8760.png)
我们假设现在有 3 个请求同时访问,也就是说上面的流程需要执行 3 遍。而如果我们只有一个进程的话,最后一个请求需要等待的时间为 `2*3+5*3=21` 秒,非常耗时。
而如果有两个进程处理 3 个请求,则最后一个完成的请求就缩短了,`2+5+2+5=14` 秒。
![diagram](https://static.zhamao.me/images/docs/dbb4e32e1c77f96162d10e41f25befa4.png)
所以如果要充分利用你的服务器或者个人电脑的多核 CPU 资源,就要设置多个进程来处理。一个进程只能在一个 CPU 上运行,而设置了多进程后,就可以让多核 CPU 充分运行多个进程,所以我们给框架设置多进程的推荐数值为等同于 CPU 的核心数。
## 为什么不是多线程
因为众所周知PHP 对线程的支持比较不好,而 ZTS 版本的 PHP 又会影响传统的 Web 端 PHP 的性能,再加上 Linux 对线程的切换效率和多进程切换的效率差不多,多线程容易造成数据读写不安全等问题,故 Swoole 使用的是多进程模型。
## 框架进程模型
![diagram](https://static.zhamao.me/images/docs/46a34feb0195d6ea12da7b80750c9e71.png)
上图中,横向的时间片可以理解为并行执行,这些操作在多个 CPU 内可能同时在执行。
## 进程间隔离
众所周知,进程是程序在操作系统中的一个边界,和自己有关的一切变量、内容和代码都在自己的进程内,不同进程之间如果不使用管道等方式,是不可以互相访问的。而加上开始描述的,创建子进程是一个复制自身的过程,所以也就会有如下图的情况:
![diagram](https://static.zhamao.me/images/docs/8b43e2179a63c8d91a508d7cefcd3226.png)
我们以静态类为例,设置一个进程中的全局变量。这里就会出现,同一个静态变量在多个进程中完全不同的值的结果。此后,我们将会在 Worker 进程中执行用户的代码,如果设置 Worker 数量仅为 1 的话,那么就简单许多了,你还是可以使用全局变量或静态类来存储你想要的内容而不用担心这种多个进程变量隔离的情况(因为用户的 Web 请求处理的代码只会在一个 Worker 进程中执行)。如果像上图一样设置了多个 Worker则用户过来的比如 HTTP 请求就有可能出现在不同的 Worker 进程中,给全局变量设值就一定会造成不同步的问题。这时我们就不可以使用全局变量做数据同步(注意,我说的是数据同步)。
## 跨进程同步
跨进程同步方案中,框架给出了很多种解决方案。
- MySQL 数据库
- Redis
- LightCache 轻量缓存(共享内存)
- WorkerCache 大缓存
- ZMAtomic 跨进程原子计数器
下面的表格我将列出下方的特点和各自的优缺点:
| 类型 | 用途 | 优点 | 缺点 |
| ----------- | --------------------------------------------------- | ------------------------------------------------- | ------------------------------------------------------------ |
| MySQL | 大型的传统的关系式数据都可以用数据库,你懂的 | 就是数据库的优点 | 和数据库不在同一台服务器的话网络延迟会较大,数据获取效率不高 |
| Redis | 传统的 key-value 数据库 | 数据无同步等问题,性能高 | 有网络通信延迟 |
| LightCache | 框架封装的跨进程的 key-value 存储模型 | 性能强悍,无 I/O 和网络通信 | 需要提前分配最大内存大小,最大单个值长度大小,不灵活 |
| WorkerCache | 框架封装的基于进程的 key-value 存储模型,类似 Redis | 无需提前分配最大内存大小,受限于 PHP memory_limit | 见 WorkerCache 的说明 |
::: tip WorkerCache 的说明
对于 WorkerCache 来说其实是比较特殊的进程间通信。具体来说就是WorkerCache 的原理就是将变量指定的存到一个进程中,如果是本进程读写的话直接相当于改一下全局变量,如果是其他进程读写的话,则依靠进程间通信。
所以缺点也显而易见,如果使用过程中不是命中了 WorkerCache 存储所在的进程的话,则一直会使用进程间通信,影响一定的效率。
:::

3
docs/advanced/php-env.md Normal file
View File

@@ -0,0 +1,3 @@
# PHP 环境高级部署方式
TODO: 留个坑。

View File

@@ -0,0 +1,3 @@
# 使用 TaskWorker 进程处理密集运算
> TODO: 新开个坑有时间补上。__填坑标记__

618
docs/api/ZM/API/CQ.md Normal file
View File

@@ -0,0 +1,618 @@
# ZM\API\CQ
## at
```php
public function at(int|string $qq): string
```
### 描述
at一下QQ用户仅在QQ群支持at全体
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| qq | int|string | 用户QQ号/ID号 |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| string | CQ码 |
## face
```php
public function face(int|string $id): string
```
### 描述
发送QQ原生表情
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| id | int|string | 表情ID |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| string | CQ码 |
## image
```php
public function image(string $file, bool $cache, bool $flash, bool $proxy, int $timeout): string
```
### 描述
发送图片
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| file | string | 文件的路径、URL或者base64编码的图片数据 |
| cache | bool | 是否缓存默认为true |
| flash | bool | 是否闪照默认为false |
| proxy | bool | 是否使用代理默认为true |
| timeout | int | 超时时间(默认不超时) |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| string | CQ码 |
## record
```php
public function record(string $file, bool $magic, bool $cache, bool $proxy, int $timeout): string
```
### 描述
发送语音
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| file | string | 文件的路径、URL或者base64编码的语音数据 |
| magic | bool | 是否加特技默认为false |
| cache | bool | 是否缓存默认为true |
| proxy | bool | 是否使用代理默认为true |
| timeout | int | 超时时间(默认不超时) |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| string | CQ码 |
## video
```php
public function video(string $file, bool $cache, bool $proxy, int $timeout): string
```
### 描述
发送短视频
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| file | string | 文件的路径、URL或者base64编码的短视频数据 |
| cache | bool | 是否缓存默认为true |
| proxy | bool | 是否使用代理默认为true |
| timeout | int | 超时时间(默认不超时) |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| string | CQ码 |
## rps
```php
public function rps(): string
```
### 描述
发送投掷骰子(只能在单条回复中单独使用)
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| string | CQ码 |
## dice
```php
public function dice(): string
```
### 描述
发送掷骰子表情(只能在单条回复中单独使用)
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| string | CQ码 |
## shake
```php
public function shake(): string
```
### 描述
戳一戳(原窗口抖动,仅支持好友消息使用)
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| string | CQ码 |
## poke
```php
public function poke(int|string $type, int|string $id, string $name): string
```
### 描述
发送新的戳一戳
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| type | int|string | 焯一戳类型 |
| id | int|string | 戳一戳ID号 |
| name | string | 戳一戳名称(可选) |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| string | CQ码 |
## anonymous
```php
public function anonymous(int $ignore): string
```
### 描述
发送匿名消息
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| ignore | int | 是否忽略错误默认为10表示不忽略错误 |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| string | CQ码 |
## share
```php
public function share(string $url, string $title, null|string $content, null|string $image): string
```
### 描述
发送链接分享(只能在单条回复中单独使用)
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| url | string | 分享地址 |
| title | string | 标题 |
| content | null|string | 卡片内容(可选) |
| image | null|string | 卡片图片(可选) |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| string | CQ码 |
## contact
```php
public function contact(int|string $type, int|string $id): string
```
### 描述
发送好友或群推荐名片
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| type | int|string | 名片类型 |
| id | int|string | 好友或群ID |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| string | CQ码 |
## location
```php
public function location(float|string $lat, float|string $lon, string $title, string $content): string
```
### 描述
发送位置
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| lat | float|string | 纬度 |
| lon | float|string | 经度 |
| title | string | 标题(可选) |
| content | string | 卡片内容(可选) |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| string | CQ码 |
## music
```php
public function music(string $type, int|string $id_or_url, null|string $audio, null|string $title, null|string $content, null|string $image): string
```
### 描述
发送音乐分享(只能在单条回复中单独使用)
qq、163、xiami为内置分享需要先通过搜索功能获取id后使用
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| type | string | 分享类型(仅限 `qq``163``xiami``custom` |
| id_or_url | int|string | 当分享类型不是 `custom`表示的是分享音乐的ID需要先通过搜索功能获取id后使用反之表示的是音乐卡片点入的链接 |
| audio | null|string | 当分享类型是 `custom`表示为音乐如mp3文件的HTTP链接地址不可为空 |
| title | null|string | 当分享类型是 `custom`表示为音乐卡片的标题建议12字以内不可为空 |
| content | null|string | 当分享类型是 `custom` 时,表示为音乐卡片的简介(可忽略) |
| image | null|string | 当分享类型是 `custom` 时,表示为音乐卡片的图片链接地址(可忽略) |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| string | CQ码 |
## forward
```php
public function forward(int|string $id): string
```
### 描述
合并转发消息
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| id | int|string | 合并转发ID, 需要通过 `/get_forward_msg` API获取转发的具体内容 |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| string | CQ码 |
## node
```php
public function node(int|string $user_id, string $nickname, string $content): string
```
### 描述
合并转发消息节点
特殊说明: 需要使用单独的API /send_group_forward_msg 发送, 并且由于消息段较为复杂, 仅支持Array形式入参。
如果引用消息和自定义消息同时出现, 实际查看顺序将取消息段顺序。
另外按 CQHTTP 文档说明, data 应全为字符串, 但由于需要接收message 类型的消息, 所以 仅限此Type的content字段 支持Array套娃
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| user_id | int|string | 转发消息id |
| nickname | string | 发送者显示名字 |
| content | string | 具体消息 |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| string | CQ码 |
## xml
```php
public function xml(string $data): string
```
### 描述
XML消息
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| data | string | xml内容, xml中的value部分 |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| string | CQ码 |
## json
```php
public function json(string $data, int $resid): string
```
### 描述
JSON消息
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| data | string | json内容 |
| resid | int | 0为走小程序通道其他值为富文本通道默认为0 |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| string | CQ码 |
## _custom
```php
public function _custom(string $type_name, array $params): string
```
### 描述
返回一个自定义扩展的CQ码支持自定义类型和参数
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| type_name | string | CQ码类型名称 |
| params | array | 参数 |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| string | CQ码 |
## decode
```php
public function decode(int|string|Stringable $msg, bool $is_content): string
```
### 描述
反转义字符串中的CQ码敏感符号
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| msg | int|string|Stringable | 字符串 |
| is_content | bool | 如果是解码CQ码本体内容则为false默认如果是参数内的字符串则为true |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| string | 转义后的CQ码 |
## replace
```php
public function replace(int|string|Stringable $str): string
```
### 描述
简单反转义替换CQ码的方括号
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| str | int|string|Stringable | 字符串 |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| string | 字符串 |
## escape
```php
public function escape(int|string|Stringable $msg, bool $is_content): string
```
### 描述
转义CQ码的特殊字符同encode
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| msg | int|string|Stringable | 字符串 |
| is_content | bool | 如果是转义CQ码本体内容则为false默认如果是参数内的字符串则为true |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| string | 转义后的CQ码 |
## encode
```php
public function encode(int|string|Stringable $msg, bool $is_content): string
```
### 描述
转义CQ码的特殊字符
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| msg | int|string|Stringable | 字符串 |
| is_content | bool | 如果是转义CQ码本体内容则为false默认如果是参数内的字符串则为true |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| string | 转义后的CQ码 |
## removeCQ
```php
public function removeCQ(string $msg): string
```
### 描述
移除消息中所有的CQ码并返回移除CQ码后的消息
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| msg | string | 消息 |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| string | 消息内容 |
## getCQ
```php
public function getCQ(string $msg, bool $is_object): null|array|CQObject
```
### 描述
获取消息中第一个CQ码
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| msg | string | 消息内容 |
| is_object | bool | 是否以对象形式返回如果为False的话返回数组形式默认为false |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| null|array|CQObject | 返回的CQ码数组或对象 |
## getAllCQ
```php
public function getAllCQ(string $msg, bool $is_object): array|CQObject[]
```
### 描述
获取消息中所有的CQ码
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| msg | string | 消息内容 |
| is_object | bool | 是否以对象形式返回如果为False的话返回数组形式默认为false |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| array|CQObject[] | 返回的CQ码们数组或对象 |

View File

@@ -0,0 +1,130 @@
# ZM\API\GoCqhttpAPIV11
## getGuildServiceProfile
```php
public function getGuildServiceProfile(): array|bool
```
### 描述
获取频道系统内BOT的资料
响应字段nickname, tiny_id, avatar_url
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| array|bool | 返回API调用结果数组或异步API调用状态bool |
## getGuildList
```php
public function getGuildList(): array|bool
```
### 描述
获取频道列表
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| array|bool | 返回API调用结果数组或异步API调用状态bool |
## getGuildMetaByGuest
```php
public function getGuildMetaByGuest(int|string $guild_id): array|bool
```
### 描述
通过访客获取频道元数据
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| guild_id | int|string | 频道ID |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| array|bool | 返回API调用结果数组或异步API调用状态bool |
## getGuildChannelList
```php
public function getGuildChannelList(int|string $guild_id, false $no_cache): array|bool
```
### 描述
获取子频道列表
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| guild_id | int|string | 频道ID |
| no_cache | false | 禁用缓存默认为false |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| array|bool | 返回API调用结果数组或异步API调用状态bool |
## getGuildMembers
```php
public function getGuildMembers(int|string $guild_id): array|bool
```
### 描述
获取频道成员列表
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| guild_id | int|string | 频道ID |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| array|bool | 返回API调用结果数组或异步API调用状态bool |
## sendGuildChannelMsg
```php
public function sendGuildChannelMsg(int|string $guild_id, int|string $channel_id, string $message): array|bool
```
### 描述
发送信息到子频道
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| guild_id | int|string | 频道ID |
| channel_id | int|string | 子频道ID |
| message | string | 信息内容 |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| array|bool | 返回API调用结果数组或异步API调用状态bool |

View File

@@ -0,0 +1,984 @@
# ZM\API\OneBotV11
## get
```php
public function get(int|string $robot_id): ZMRobot
```
### 描述
获取机器人Action/API实例
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| robot_id | int|string | 机器人ID |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| ZMRobot | 机器人实例 |
## getRandom
```php
public function getRandom(): ZMRobot
```
### 描述
随机获取一个连接到框架的机器人实例
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| ZMRobot | 机器人实例 |
## getAllRobot
```php
public function getAllRobot(): ZMRobot[]
```
### 描述
获取所有机器人实例
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| ZMRobot[] | 机器人实例们 |
## setCallback
```php
public function setCallback(bool|Closure $callback): OneBotV11
```
### 描述
设置回调或启用协程等待API回包
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| callback | bool|Closure | 是否开启协程或设置异步回调函数如果为true则协程等待结果如果为false则异步执行并不等待结果如果为回调函数则异步执行且调用回调 |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| OneBotV11 | 返回本身 |
## setPrefix
```php
public function setPrefix(int $prefix): OneBotV11
```
### 描述
设置API调用类型后缀
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| prefix | int | 设置后缀类型API_NORMAL为不加后缀API_ASYNC为异步调用API_RATE_LIMITED为加后缀并且限制调用频率 |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| OneBotV11 | 返回本身 |
## sendPrivateMsg
```php
public function sendPrivateMsg(int|string $user_id, string $message, bool $auto_escape): array|bool
```
### 描述
发送私聊消息
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| user_id | int|string | 用户ID |
| message | string | 消息内容 |
| auto_escape | bool | 是否自动转义默认为false |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| array|bool | 返回API调用结果数组或异步API调用状态bool |
## sendGroupMsg
```php
public function sendGroupMsg(int|string $group_id, string $message, bool $auto_escape): array|bool
```
### 描述
发送群消息
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| group_id | int|string | 群组ID |
| message | string | 消息内容 |
| auto_escape | bool | 是否自动转义默认为false |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| array|bool | 返回API调用结果数组或异步API调用状态bool |
## sendMsg
```php
public function sendMsg(string $message_type, int|string $target_id, string $message, bool $auto_escape): array|bool
```
### 描述
发送消息
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| message_type | string | 消息类型 |
| target_id | int|string | 目标ID |
| message | string | 消息内容 |
| auto_escape | bool | 是否自动转义默认为false |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| array|bool | 返回API调用结果数组或异步API调用状态bool |
## deleteMsg
```php
public function deleteMsg(int|string $message_id): array|bool
```
### 描述
撤回消息
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| message_id | int|string | 消息ID |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| array|bool | 返回API调用结果数组或异步API调用状态bool |
## getMsg
```php
public function getMsg(int|string $message_id): array|bool
```
### 描述
获取消息
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| message_id | int|string | 消息ID |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| array|bool | 返回API调用结果数组或异步API调用状态bool |
## getForwardMsg
```php
public function getForwardMsg(int|string $id): array|bool
```
### 描述
获取合并转发消息
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| id | int|string | ID |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| array|bool | 返回API调用结果数组或异步API调用状态bool |
## sendLike
```php
public function sendLike(int|string $user_id, int $times): array|bool
```
### 描述
发送好友赞
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| user_id | int|string | 用户ID |
| times | int | 时间 |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| array|bool | 返回API调用结果数组或异步API调用状态bool |
## setGroupKick
```php
public function setGroupKick(int|string $group_id, int|string $user_id, bool $reject_add_request): array|bool
```
### 描述
群组踢人
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| group_id | int|string | 群ID |
| user_id | int|string | 用户ID |
| reject_add_request | bool | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| array|bool | 返回API调用结果数组或异步API调用状态bool |
## setGroupBan
```php
public function setGroupBan(int|string $group_id, int|string $user_id, int $duration): array|bool
```
### 描述
群组单人禁言
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| group_id | int|string | 群ID |
| user_id | int|string | 用户ID |
| duration | int | 禁言时长 |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| array|bool | 返回API调用结果数组或异步API调用状态bool |
## setGroupAnonymousBan
```php
public function setGroupAnonymousBan(int|string $group_id, array|int|string $anonymous_or_flag, int $duration): array|bool
```
### 描述
群组匿名用户禁言
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| group_id | int|string | 群ID |
| anonymous_or_flag | array|int|string | 匿名禁言Flag或匿名用户对象 |
| duration | int | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| array|bool | 返回API调用结果数组或异步API调用状态bool |
## setGroupWholeBan
```php
public function setGroupWholeBan(int|string $group_id, bool $enable): array|bool
```
### 描述
群组全员禁言
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| group_id | int|string | 群ID |
| enable | bool | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| array|bool | 返回API调用结果数组或异步API调用状态bool |
## setGroupAdmin
```php
public function setGroupAdmin(int|string $group_id, int|string $user_id, bool $enable): array|bool
```
### 描述
群组设置管理员
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| group_id | int|string | 群ID |
| user_id | int|string | 用户ID |
| enable | bool | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| array|bool | 返回API调用结果数组或异步API调用状态bool |
## setGroupAnonymous
```php
public function setGroupAnonymous(int|string $group_id, bool $enable): array|bool
```
### 描述
群组匿名
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| group_id | int|string | 群ID |
| enable | bool | 是否启用默认为true |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| array|bool | 返回API调用结果数组或异步API调用状态bool |
## setGroupCard
```php
public function setGroupCard(int|string $group_id, int|string $user_id, string $card): array|bool
```
### 描述
设置群名片(群备注)
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| group_id | int|string | 群ID |
| user_id | int|string | 用户ID |
| card | string | 名片内容(默认为空) |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| array|bool | 返回API调用结果数组或异步API调用状态bool |
## setGroupName
```php
public function setGroupName(int|string $group_id, string $group_name): array|bool
```
### 描述
设置群名
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| group_id | int|string | 群ID |
| group_name | string | 群名 |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| array|bool | 返回API调用结果数组或异步API调用状态bool |
## setGroupLeave
```php
public function setGroupLeave(int|string $group_id, bool $is_dismiss): array|bool
```
### 描述
退出群组
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| group_id | int|string | 群ID |
| is_dismiss | bool | 是否解散默认为false |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| array|bool | 返回API调用结果数组或异步API调用状态bool |
## setGroupSpecialTitle
```php
public function setGroupSpecialTitle(int|string $group_id, int|string $user_id, string $special_title, int $duration): array|bool
```
### 描述
设置群组专属头衔
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| group_id | int|string | 群ID |
| user_id | int|string | 用户ID |
| special_title | string | 专属头衔内容 |
| duration | int | 持续时间(默认为-1永久 |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| array|bool | 返回API调用结果数组或异步API调用状态bool |
## setFriendAddRequest
```php
public function setFriendAddRequest(array|int|string $flag, bool $approve, string $remark): array|bool
```
### 描述
处理加好友请求
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| flag | array|int|string | 处理加好友请求的flag |
| approve | bool | 是否同意默认为true |
| remark | string | 设置昵称(默认不设置) |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| array|bool | 返回API调用结果数组或异步API调用状态bool |
## setGroupAddRequest
```php
public function setGroupAddRequest(array|int|string $flag, string $sub_type, bool $approve, string $reason): array|bool
```
### 描述
处理加群请求/邀请
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| flag | array|int|string | 处理加群请求的flag |
| sub_type | string | 处理请求类型包含add和invite |
| approve | bool | 是否同意默认为true |
| reason | string | 拒绝理由(仅在拒绝时有效,默认为空) |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| array|bool | 返回API调用结果数组或异步API调用状态bool |
## getLoginInfo
```php
public function getLoginInfo(): array|bool
```
### 描述
获取登录号信息
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| array|bool | 返回API调用结果数组或异步API调用状态bool |
## getStrangerInfo
```php
public function getStrangerInfo(int|string $user_id, bool $no_cache): array|bool
```
### 描述
获取陌生人信息
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| user_id | int|string | 用户ID |
| no_cache | bool | 是否不使用缓存默认为false |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| array|bool | 返回API调用结果数组或异步API调用状态bool |
## getFriendList
```php
public function getFriendList(): array|bool
```
### 描述
获取好友列表
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| array|bool | 返回API调用结果数组或异步API调用状态bool |
## getGroupInfo
```php
public function getGroupInfo(int|string $group_id, bool $no_cache): array|bool
```
### 描述
获取群信息
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| group_id | int|string | 群ID |
| no_cache | bool | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| array|bool | 返回API调用结果数组或异步API调用状态bool |
## getGroupList
```php
public function getGroupList(): array|bool
```
### 描述
获取群列表
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| array|bool | 返回API调用结果数组或异步API调用状态bool |
## getGroupMemberInfo
```php
public function getGroupMemberInfo(int|string $group_id, int|string $user_id, bool $no_cache): array|bool
```
### 描述
获取群成员信息
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| group_id | int|string | 群ID |
| user_id | int|string | 用户ID |
| no_cache | bool | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| array|bool | 返回API调用结果数组或异步API调用状态bool |
## getGroupMemberList
```php
public function getGroupMemberList(int|string $group_id): array|bool
```
### 描述
获取群成员列表
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| group_id | int|string | 群ID |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| array|bool | 返回API调用结果数组或异步API调用状态bool |
## getGroupHonorInfo
```php
public function getGroupHonorInfo(int|string $group_id, string $type): array|bool
```
### 描述
获取群荣誉信息
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| group_id | int|string | 群ID |
| type | string | 荣誉类型 |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| array|bool | 返回API调用结果数组或异步API调用状态bool |
## getCsrfToken
```php
public function getCsrfToken(): array|bool
```
### 描述
获取 CSRF Token
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| array|bool | 返回API调用结果数组或异步API调用状态bool |
## getCredentials
```php
public function getCredentials(string $domain): array|bool
```
### 描述
获取 QQ 相关接口凭证
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| domain | string | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| array|bool | 返回API调用结果数组或异步API调用状态bool |
## getRecord
```php
public function getRecord(string $file, string $out_format): array|bool
```
### 描述
获取语音
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| file | string | 文件 |
| out_format | string | 输出格式 |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| array|bool | 返回API调用结果数组或异步API调用状态bool |
## getImage
```php
public function getImage(string $file): array|bool
```
### 描述
获取图片
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| file | string | 文件 |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| array|bool | 返回API调用结果数组或异步API调用状态bool |
## canSendImage
```php
public function canSendImage(): array|bool
```
### 描述
检查是否可以发送图片
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| array|bool | 返回API调用结果数组或异步API调用状态bool |
## canSendRecord
```php
public function canSendRecord(): array|bool
```
### 描述
检查是否可以发送语音
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| array|bool | 返回API调用结果数组或异步API调用状态bool |
## getStatus
```php
public function getStatus(): array|bool
```
### 描述
获取运行状态
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| array|bool | 返回API调用结果数组或异步API调用状态bool |
## getVersionInfo
```php
public function getVersionInfo(): array|bool
```
### 描述
获取版本信息
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| array|bool | 返回API调用结果数组或异步API调用状态bool |
## setRestart
```php
public function setRestart(int $delay): array|bool
```
### 描述
重启 OneBot 实现
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| delay | int | 延迟时间毫秒默认为0 |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| array|bool | 返回API调用结果数组或异步API调用状态bool |
## cleanCache
```php
public function cleanCache(): array|bool
```
### 描述
清理缓存
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| array|bool | 返回API调用结果数组或异步API调用状态bool |
## getExtendedAPI
```php
public function getExtendedAPI(string $package_name): mixed
```
### 描述
获取内置支持的扩展API对象
现支持 go-cqhttp 的扩展API
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| package_name | string | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | 返回包的操作对象 |
## callExtendedAPI
```php
public function callExtendedAPI(string $action, array $params): array|bool
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| action | string | 动作API名称 |
| params | array | 参数 |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| array|bool | 返回API调用结果数组或异步API调用状态bool |

View File

@@ -0,0 +1,117 @@
# ZM\API\Proxies\Bot\AbstractBotProxy
## __construct
```php
public function __construct(AbstractBotProxy|ZMRobot $bot): mixed
```
### 描述
构造函数
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| bot | AbstractBotProxy|ZMRobot | 调用此代理的机器人实例 |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |
## __call
```php
public function __call(string $name, array $arguments): mixed
```
### 描述
在传入的机器人实例上调用方法
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| name | string | 方法名 |
| arguments | array | 参数 |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |
## __get
```php
public function __get(string $name): mixed
```
### 描述
获取传入的机器人实例的属性
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| name | string | 属性名 |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |
## __set
```php
public function __set(string $name, mixed $value): mixed
```
### 描述
设置传入的机器人实例的属性
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| name | string | 属性名 |
| value | mixed | 属性值 |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |
## __isset
```php
public function __isset(string $name): bool
```
### 描述
判断传入的机器人实例的属性是否存在
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| name | string | 属性名 |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| bool | |

View File

@@ -0,0 +1,24 @@
# ZM\API\Proxies\Bot\AllBotsProxy
## __call
```php
public function __call(string $name, array $arguments): array<mixed>
```
### 描述
在所有机器人实例上调用方法
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| name | string | 方法名 |
| arguments | array | 参数 |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| array<mixed> | 返回一个包含所有执行结果的数组键名为机器人ID |

View File

@@ -0,0 +1,24 @@
# ZM\API\Proxies\Bot\AllGroupsProxy
## __call
```php
public function __call(string $name, array $arguments): array<mixed>
```
### 描述
在传入的机器人实例上调用方法
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| name | string | 方法名 |
| arguments | array | 参数 |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| array<mixed> | 返回一个包含所有执行结果的数组,键名为群号 |

View File

@@ -0,0 +1,48 @@
# ZM\API\TuringAPI
## getTuringMsg
```php
public function getTuringMsg(string $msg, int|string $user_id, string $api): string
```
### 描述
请求图灵API返回图灵的消息
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| msg | string | 消息 |
| user_id | int|string | 用户ID |
| api | string | API Key |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| string | 图灵的回复 |
## getResultStatus
```php
public function getResultStatus(array $r): bool|string
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| r | array | 数据API回包 |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| bool|string | 错误消息或成功鸥鸟 |

View File

@@ -0,0 +1,46 @@
# ZM\API\ZMRobot
## all
```php
public function all(ZM\API\Proxies\Bot\AbstractBotProxy $proxy): ZM\API\Proxies\Bot\AllBotsProxy
```
### 描述
获取一个会在所有机器人实例上执行的代理
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| proxy | ZM\API\Proxies\Bot\AbstractBotProxy | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| ZM\API\Proxies\Bot\AllBotsProxy | |
## allGroups
```php
public function allGroups(ZM\API\Proxies\Bot\AbstractBotProxy $proxy): ZM\API\Proxies\Bot\AllGroupsProxy
```
### 描述
获取一个会在所有群上执行的代理
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| proxy | ZM\API\Proxies\Bot\AbstractBotProxy | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| ZM\API\Proxies\Bot\AllGroupsProxy | |

View File

@@ -0,0 +1 @@
# ZM\Annotation\AnnotationBase

View File

@@ -0,0 +1,100 @@
# ZM\Annotation\AnnotationParser
## __construct
```php
public function __construct(): mixed
```
### 描述
AnnotationParser constructor.
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |
## registerMods
```php
public function registerMods(): mixed
```
### 描述
注册各个模块类的注解和模块level的排序
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |
## addRegisterPath
```php
public function addRegisterPath(string $path, string $indoor_name): mixed
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| path | string | 注册解析注解的路径 |
| indoor_name | string | 起始命名空间的名称 |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |
## sortByLevel
```php
public function sortByLevel(array $events, string $class_name, string $prefix): mixed
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| events | array | 需要排序的 |
| class_name | string | 排序的类名 |
| prefix | string | 前缀 |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |
## verifyMiddlewares
```php
public function verifyMiddlewares(): mixed
```
### 描述
作者很懒,什么也没有说
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |

View File

@@ -0,0 +1 @@
# ZM\Annotation\CQ\CQAPIResponse

View File

@@ -0,0 +1,39 @@
# ZM\Annotation\CQ\CQAfter
## getLevel
```php
public function getLevel(): mixed
```
### 描述
作者很懒,什么也没有说
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |
## setLevel
```php
public function setLevel(mixed $level): mixed
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| level | mixed | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |

View File

@@ -0,0 +1,39 @@
# ZM\Annotation\CQ\CQBefore
## getLevel
```php
public function getLevel(): mixed
```
### 描述
作者很懒,什么也没有说
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |
## setLevel
```php
public function setLevel(mixed $level): mixed
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| level | mixed | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |

View File

@@ -0,0 +1,22 @@
# ZM\Annotation\CQ\CQCommand
## setLevel
```php
public function setLevel(int $level): mixed
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| level | int | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |

View File

@@ -0,0 +1 @@
# ZM\Annotation\CQ\CQMessage

View File

@@ -0,0 +1,39 @@
# ZM\Annotation\CQ\CQMetaEvent
## getLevel
```php
public function getLevel(): mixed
```
### 描述
作者很懒,什么也没有说
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |
## setLevel
```php
public function setLevel(int $level): mixed
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| level | int | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |

View File

@@ -0,0 +1,22 @@
# ZM\Annotation\CQ\CQNotice
## setLevel
```php
public function setLevel(int $level): mixed
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| level | int | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |

View File

@@ -0,0 +1,22 @@
# ZM\Annotation\CQ\CQRequest
## setLevel
```php
public function setLevel(int $level): mixed
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| level | int | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |

View File

@@ -0,0 +1 @@
# ZM\Annotation\Command\TerminalCommand

View File

@@ -0,0 +1,61 @@
# ZM\Annotation\Cron\Cron
## setStatus
```php
public function setStatus(int $status): void
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| status | int | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| void | |
## getRecordNextTime
```php
public function getRecordNextTime(): int
```
### 描述
作者很懒,什么也没有说
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| int | |
## setRecordNextTime
```php
public function setRecordNextTime(int $record_next_time): void
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| record_next_time | int | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| void | |

View File

@@ -0,0 +1 @@
# ZM\Annotation\Http\Controller

View File

@@ -0,0 +1 @@
# ZM\Annotation\Http\HandleAfter

View File

@@ -0,0 +1 @@
# ZM\Annotation\Http\HandleBefore

View File

@@ -0,0 +1 @@
# ZM\Annotation\Http\HandleException

View File

@@ -0,0 +1 @@
# ZM\Annotation\Http\Middleware

View File

@@ -0,0 +1 @@
# ZM\Annotation\Http\MiddlewareClass

View File

@@ -0,0 +1 @@
# ZM\Annotation\Http\RequestMapping

View File

@@ -0,0 +1 @@
# ZM\Annotation\Http\RequestMethod

View File

@@ -0,0 +1 @@
# ZM\Annotation\Module\Closed

View File

@@ -0,0 +1 @@
# ZM\Annotation\Swoole\OnCloseEvent

View File

@@ -0,0 +1 @@
# ZM\Annotation\Swoole\OnManagerStartEvent

View File

@@ -0,0 +1 @@
# ZM\Annotation\Swoole\OnMessageEvent

View File

@@ -0,0 +1 @@
# ZM\Annotation\Swoole\OnOpenEvent

View File

@@ -0,0 +1 @@
# ZM\Annotation\Swoole\OnPipeMessageEvent

View File

@@ -0,0 +1 @@
# ZM\Annotation\Swoole\OnRequestEvent

View File

@@ -0,0 +1 @@
# ZM\Annotation\Swoole\OnSave

View File

@@ -0,0 +1 @@
# ZM\Annotation\Swoole\OnSetup

View File

@@ -0,0 +1 @@
# ZM\Annotation\Swoole\OnStart

View File

@@ -0,0 +1 @@
# ZM\Annotation\Swoole\OnSwooleEvent

View File

@@ -0,0 +1,23 @@
# ZM\Annotation\Swoole\OnSwooleEventBase
## setLevel
```php
public function setLevel(int $level): mixed
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| level | int | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |

View File

@@ -0,0 +1,17 @@
# ZM\Annotation\Swoole\OnTask
## getRule
```php
public function getRule(): mixed
```
### 描述
作者很懒,什么也没有说
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |

View File

@@ -0,0 +1 @@
# ZM\Annotation\Swoole\OnTaskEvent

View File

@@ -0,0 +1 @@
# ZM\Annotation\Swoole\OnTick

View File

@@ -0,0 +1 @@
# ZM\Annotation\Swoole\SwooleHandler

View File

@@ -0,0 +1 @@
# ZM\Command\BuildCommand

View File

@@ -0,0 +1,25 @@
# ZM\Command\CheckConfigCommand
## check
```php
public function check(mixed $remote, mixed $local, Symfony\Component\Console\Output\OutputInterface $out): mixed
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| remote | mixed | |
| local | mixed | |
| out | Symfony\Component\Console\Output\OutputInterface | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |

View File

@@ -0,0 +1 @@
# ZM\Command\Daemon\DaemonCommand

View File

@@ -0,0 +1 @@
# ZM\Command\Daemon\DaemonReloadCommand

View File

@@ -0,0 +1 @@
# ZM\Command\Daemon\DaemonStatusCommand

View File

@@ -0,0 +1 @@
# ZM\Command\Daemon\DaemonStopCommand

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