mirror of
https://github.com/zhamao-robot/zhamao-framework.git
synced 2026-07-03 23:05:37 +08:00
Compare commits
251 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f0cba01bd7 | ||
|
|
ea83ea2cce | ||
|
|
21f310852a | ||
|
|
6173cf2e37 | ||
|
|
4791099a78 | ||
|
|
9d1952f5f8 | ||
|
|
6543574695 | ||
|
|
5b1c771a2d | ||
|
|
29d7d07c8e | ||
|
|
e85e1e57b1 | ||
|
|
90a4c6803e | ||
|
|
ff1b43ad89 | ||
|
|
cdd273808c | ||
|
|
f8bcc359da | ||
|
|
ccc0280d2f | ||
|
|
bd98608d2e | ||
|
|
90b6580e80 | ||
|
|
64899a50c1 | ||
|
|
d12f0bf317 | ||
|
|
422dd81bbf | ||
|
|
3a6c821249 | ||
|
|
a12b5eadf3 | ||
|
|
27c5debcb0 | ||
|
|
594b7f5f82 | ||
|
|
2c28ed9ab8 | ||
|
|
5f3a626557 | ||
|
|
1ebcfa8e7e | ||
|
|
3edab143c3 | ||
|
|
9cd5f24d2f | ||
|
|
34919afb36 | ||
|
|
6282da4972 | ||
|
|
de4748860c | ||
|
|
c7736a7c3e | ||
|
|
3f9493ae7e | ||
|
|
dbda5dc299 | ||
|
|
c9ab695a9e | ||
|
|
bb57efc149 | ||
|
|
76543d5ec0 | ||
|
|
598f568b8c | ||
|
|
fc8c0b540a | ||
|
|
af75fc2f94 | ||
|
|
b94bbbca20 | ||
|
|
784fc1697b | ||
|
|
190eba585b | ||
|
|
f97b87d5e5 | ||
|
|
2c1a158d3e | ||
|
|
90de54c6a3 | ||
|
|
d596c315f2 | ||
|
|
52afaa3fb9 | ||
|
|
47cca37854 | ||
|
|
0fa49171b9 | ||
|
|
ea1d14ba00 | ||
|
|
a01791ddbe | ||
|
|
51a9c5c4e8 | ||
|
|
b1e37943df | ||
|
|
5459d1c5ff | ||
|
|
21373097bb | ||
|
|
f4f7327695 | ||
|
|
36fc2cb4cd | ||
|
|
b7469b9dd4 | ||
|
|
e7e77c99d0 | ||
|
|
6fbd35ed33 | ||
|
|
fba2339280 | ||
|
|
bd8270a4ae | ||
|
|
5299061c87 | ||
|
|
e843aeac55 | ||
|
|
19c792209b | ||
|
|
277d442634 | ||
|
|
51bec043e3 | ||
|
|
b7595f6f22 | ||
|
|
55181d583f | ||
|
|
b5a5a4f32e | ||
|
|
a746779efa | ||
|
|
736b6ea0a5 | ||
|
|
884f07baa6 | ||
|
|
b496c3136e | ||
|
|
bbfb40f973 | ||
|
|
a73e1fc164 | ||
|
|
ef7acb7fa0 | ||
|
|
fcd108adbe | ||
|
|
c9c76bfd10 | ||
|
|
d9302a3120 | ||
|
|
0cb3308dd1 | ||
|
|
583b9d7cf7 | ||
|
|
d7728ebc25 | ||
|
|
b6742526aa | ||
|
|
4defd8ac1b | ||
|
|
d28672e2ad | ||
|
|
94d6a51358 | ||
|
|
54eabc948f | ||
|
|
6c9e26ce83 | ||
|
|
a934037179 | ||
|
|
396444a089 | ||
|
|
699444abdd | ||
|
|
088031f807 | ||
|
|
8ce6e2c111 | ||
|
|
e7f36b9fcf | ||
|
|
dab91f526e | ||
|
|
35e23a7cbc | ||
|
|
7df05df48f | ||
|
|
707a1ae628 | ||
|
|
a65fc4076b | ||
|
|
f487897cf2 | ||
|
|
869d9ed543 | ||
|
|
8f61ed7561 | ||
|
|
8cb6a32341 | ||
|
|
687260e53c | ||
|
|
a919ce4554 | ||
|
|
d19d7acedd | ||
|
|
a393b3aff5 | ||
|
|
8c2036b6b4 | ||
|
|
dc081861ad | ||
|
|
ec76d2ba7d | ||
|
|
47ce0a8e9c | ||
|
|
f1c730962b | ||
|
|
d95a5131f6 | ||
|
|
69637cf482 | ||
|
|
25d6ec3a92 | ||
|
|
8bf5ff4e7f | ||
|
|
fd4e4be3a8 | ||
|
|
e0a01ea2ca | ||
|
|
256ccb96a6 | ||
|
|
bfffdc7d21 | ||
|
|
3bbe21268b | ||
|
|
1537e88a74 | ||
|
|
0d9711e62d | ||
|
|
0a7c5f06c6 | ||
|
|
e7a8a32b73 | ||
|
|
62b703f2e4 | ||
|
|
f44921d136 | ||
|
|
cd42545c7d | ||
|
|
0df3fd7bed | ||
|
|
56241da281 | ||
|
|
05a04104dd | ||
|
|
50d27ee186 | ||
|
|
371926b5a6 | ||
|
|
97face2406 | ||
|
|
ea64b40011 | ||
|
|
6d23e489aa | ||
|
|
f4d75e211f | ||
|
|
48f6cc644d | ||
|
|
33f517333f | ||
|
|
7253a309c7 | ||
|
|
f2aff5882d | ||
|
|
0dd61a7270 | ||
|
|
420b8e6d67 | ||
|
|
9e08919ce0 | ||
|
|
a7324f6c49 | ||
|
|
721c0834db | ||
|
|
e37629aaea | ||
|
|
a43a4a429e | ||
|
|
f5d34198e7 | ||
|
|
46604293e9 | ||
|
|
58e405cccd | ||
|
|
1deea5bebc | ||
|
|
cad5636f92 | ||
|
|
90290bee94 | ||
|
|
9f7ebceeb9 | ||
|
|
60ea2c7e12 | ||
|
|
441c866160 | ||
|
|
33d3341bb3 | ||
|
|
1d778fd78e | ||
|
|
0cd73a6304 | ||
|
|
2fedfe5b18 | ||
|
|
77c140bee6 | ||
|
|
c06e38d71f | ||
|
|
9b59cec22a | ||
|
|
306e992789 | ||
|
|
8335cfed69 | ||
|
|
4702aa1987 | ||
|
|
145e1b31a0 | ||
|
|
f2e28de20c | ||
|
|
bcaaf88edb | ||
|
|
120698fb43 | ||
|
|
dd88585ffa | ||
|
|
93a8c450ad | ||
|
|
3451434997 | ||
|
|
0bab2e74b0 | ||
|
|
c1a877489b | ||
|
|
520099aaba | ||
|
|
9bd02b3dd2 | ||
|
|
ba64f2c189 | ||
|
|
fbb194a6c5 | ||
|
|
30b2d2134b | ||
|
|
7eea71e282 | ||
|
|
e40b3029e0 | ||
|
|
17492c78fa | ||
|
|
a9276d3f72 | ||
|
|
eecbe49955 | ||
|
|
be9874a9ad | ||
|
|
b4fcc057c5 | ||
|
|
d9499dc56b | ||
|
|
f6806c88ab | ||
|
|
2caca545ad | ||
|
|
ff0f11da7f | ||
|
|
daa1822bc5 | ||
|
|
d490892092 | ||
|
|
182a4e7b06 | ||
|
|
e9beed03ea | ||
|
|
8351527aea | ||
|
|
ddff663b0b | ||
|
|
31b4fb9201 | ||
|
|
1f7f0da383 | ||
|
|
9fa1079248 | ||
|
|
ae0cf5e3d7 | ||
|
|
672369c598 | ||
|
|
73687f248b | ||
|
|
65cc2a948a | ||
|
|
299f36dcc0 | ||
|
|
f5cbce5195 | ||
|
|
a3780667b2 | ||
|
|
a21742a326 | ||
|
|
40aacb2e61 | ||
|
|
ba18869c85 | ||
|
|
a454f2c523 | ||
|
|
7caebaa6ba | ||
|
|
580abd7317 | ||
|
|
3187431611 | ||
|
|
81c37c9a0a | ||
|
|
ba5bca20da | ||
|
|
533fe187bd | ||
|
|
c4da26c19d | ||
|
|
ca7bfcc8c6 | ||
|
|
6c7b582faf | ||
|
|
6f2e6135f1 | ||
|
|
37a92e03c1 | ||
|
|
35385f8916 | ||
|
|
a2fbdd8e0a | ||
|
|
bab610722f | ||
|
|
4cabc8d132 | ||
|
|
e8bd381907 | ||
|
|
42aac802dd | ||
|
|
d748a20445 | ||
|
|
5db3ff934d | ||
|
|
9bfa3ede20 | ||
|
|
127466e546 | ||
|
|
16aa30cac7 | ||
|
|
05a3d0111b | ||
|
|
9f4b5fb14a | ||
|
|
a716e68f87 | ||
|
|
2e127771ed | ||
|
|
c6bbba6051 | ||
|
|
443ed115b0 | ||
|
|
f450b8d863 | ||
|
|
acf570e652 | ||
|
|
4e9199c68e | ||
|
|
6f5575b155 | ||
|
|
700b854434 | ||
|
|
37b5d954e9 | ||
|
|
ac50e96568 | ||
|
|
86174c2e9f |
15
.editorconfig
Normal file
15
.editorconfig
Normal 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
|
||||
30
.github/workflows/build.yml
vendored
30
.github/workflows/build.yml
vendored
@@ -1,30 +0,0 @@
|
||||
name: Build
|
||||
|
||||
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: 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 change
|
||||
run: |
|
||||
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"
|
||||
git push
|
||||
69
.github/workflows/increment-build-number.yml
vendored
Normal file
69
.github/workflows/increment-build-number.yml
vendored
Normal 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
|
||||
52
.github/workflows/integration-test.yml
vendored
52
.github/workflows/integration-test.yml
vendored
@@ -1,12 +1,11 @@
|
||||
name: Integration Test
|
||||
name: Integration and Style Test
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
paths-ignore:
|
||||
- '**.md'
|
||||
- 'docs/**'
|
||||
paths:
|
||||
- '**/**.php'
|
||||
pull_request:
|
||||
branches:
|
||||
- master
|
||||
@@ -16,9 +15,8 @@ on:
|
||||
- reopened
|
||||
- ready_for_review
|
||||
- review_requested
|
||||
paths-ignore:
|
||||
- '**.md'
|
||||
- 'docs/**'
|
||||
paths:
|
||||
- '**/**.php'
|
||||
|
||||
jobs:
|
||||
integration:
|
||||
@@ -37,6 +35,8 @@ jobs:
|
||||
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"
|
||||
@@ -61,5 +61,41 @@ jobs:
|
||||
- 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: "./vendor/bin/php-cs-fixer fix --dry-run --diff"
|
||||
run: "composer cs-fix -- --dry-run --diff"
|
||||
|
||||
13
.github/workflows/vuepress-deploy.yml
vendored
13
.github/workflows/vuepress-deploy.yml
vendored
@@ -1,8 +1,11 @@
|
||||
name: VuePress Auto Deploy
|
||||
name: Docs and Script Auto Deploy
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
paths:
|
||||
- 'docs/**'
|
||||
- 'ext/**'
|
||||
|
||||
jobs:
|
||||
build:
|
||||
@@ -30,3 +33,11 @@ jobs:
|
||||
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 }}
|
||||
|
||||
70
.gitignore
vendored
70
.gitignore
vendored
@@ -1,21 +1,26 @@
|
||||
.idea/
|
||||
/src/test/
|
||||
/src/webconsole/config/
|
||||
/vendor/
|
||||
### Zhamao Framework ###
|
||||
/zm_data/
|
||||
composer.lock
|
||||
/resources/server.phar
|
||||
/distribute/
|
||||
/bin/.phpunit.result.cache
|
||||
/resources/zhamao.service
|
||||
.phpunit.result.cache
|
||||
.daemon_pid
|
||||
/runtime/
|
||||
/tmp/
|
||||
/temp/
|
||||
/site/
|
||||
|
||||
# go-cqhttp快速安装启动相关(可能被废弃)
|
||||
# 框架审计文件
|
||||
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
|
||||
@@ -23,12 +28,53 @@ composer.lock
|
||||
/ext/go-cqhttp/go-cqhttp
|
||||
/ext/go-cqhttp/session.token
|
||||
|
||||
.zm_worker_*.pid
|
||||
### Git ###
|
||||
# 备份文件
|
||||
*.orig
|
||||
|
||||
# Git Hook 的相关锁文件
|
||||
# 解决 Merge 冲突时可能会自动生成的文件
|
||||
*.BACKUP.*
|
||||
*.BASE.*
|
||||
*.LOCAL.*
|
||||
*.REMOTE.*
|
||||
*_BACKUP_*.txt
|
||||
*_BASE_*.txt
|
||||
*_LOCAL_*.txt
|
||||
*_REMOTE_*.txt
|
||||
|
||||
# Git Hooks
|
||||
cghooks.lock
|
||||
|
||||
# Vuepress 相关文件
|
||||
### 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
|
||||
|
||||
@@ -6,70 +6,80 @@ declare(strict_types=1);
|
||||
* @since 2.7.0
|
||||
*/
|
||||
|
||||
$rules = [
|
||||
'@PSR12' => true,
|
||||
'@Symfony' => true,
|
||||
'@PhpCsFixer' => true,
|
||||
'array_syntax' => [
|
||||
'syntax' => 'short',
|
||||
],
|
||||
'list_syntax' => [
|
||||
'syntax' => 'short',
|
||||
],
|
||||
'concat_space' => [
|
||||
'spacing' => 'one',
|
||||
],
|
||||
'blank_line_before_statement' => [
|
||||
'statements' => [
|
||||
'declare',
|
||||
],
|
||||
],
|
||||
'ordered_imports' => [
|
||||
'imports_order' => [
|
||||
'class',
|
||||
'function',
|
||||
'const',
|
||||
],
|
||||
'sort_algorithm' => 'alpha',
|
||||
],
|
||||
'single_line_comment_style' => [
|
||||
'comment_types' => [
|
||||
],
|
||||
],
|
||||
'yoda_style' => [
|
||||
'always_move_variable' => false,
|
||||
'equal' => false,
|
||||
'identical' => false,
|
||||
],
|
||||
'multiline_whitespace_before_semicolons' => [
|
||||
'strategy' => 'no_multi_line',
|
||||
],
|
||||
'constant_case' => [
|
||||
'case' => 'lower',
|
||||
],
|
||||
'class_attributes_separation' => true,
|
||||
'combine_consecutive_unsets' => true,
|
||||
'declare_strict_types' => true,
|
||||
'linebreak_after_opening_tag' => true,
|
||||
'lowercase_static_reference' => true,
|
||||
'no_useless_else' => true,
|
||||
'no_unused_imports' => true,
|
||||
'not_operator_with_successor_space' => false,
|
||||
'not_operator_with_space' => false,
|
||||
'ordered_class_elements' => true,
|
||||
'php_unit_strict' => false,
|
||||
'phpdoc_separation' => false,
|
||||
'single_quote' => true,
|
||||
'standardize_not_equals' => true,
|
||||
'multiline_comment_opening_closing' => true,
|
||||
'phpdoc_summary' => false,
|
||||
'php_unit_test_class_requires_covers' => false,
|
||||
'global_namespace_import' => false,
|
||||
'phpdoc_order' => false,
|
||||
];
|
||||
|
||||
if (PHP_VERSION_ID > 70400) {
|
||||
$rules['no_useless_concat_operator'] = false;
|
||||
}
|
||||
|
||||
// 'no_useless_concat_operator' => false,
|
||||
|
||||
return (new PhpCsFixer\Config())
|
||||
->setRiskyAllowed(true)
|
||||
->setRules([
|
||||
'@PSR12' => true,
|
||||
'@Symfony' => true,
|
||||
'@PhpCsFixer' => true,
|
||||
'array_syntax' => [
|
||||
'syntax' => 'short',
|
||||
],
|
||||
'list_syntax' => [
|
||||
'syntax' => 'short',
|
||||
],
|
||||
'concat_space' => [
|
||||
'spacing' => 'one',
|
||||
],
|
||||
'blank_line_before_statement' => [
|
||||
'statements' => [
|
||||
'declare',
|
||||
],
|
||||
],
|
||||
'ordered_imports' => [
|
||||
'imports_order' => [
|
||||
'class',
|
||||
'function',
|
||||
'const',
|
||||
],
|
||||
'sort_algorithm' => 'alpha',
|
||||
],
|
||||
'single_line_comment_style' => [
|
||||
'comment_types' => [
|
||||
],
|
||||
],
|
||||
'yoda_style' => [
|
||||
'always_move_variable' => false,
|
||||
'equal' => false,
|
||||
'identical' => false,
|
||||
],
|
||||
'multiline_whitespace_before_semicolons' => [
|
||||
'strategy' => 'no_multi_line',
|
||||
],
|
||||
'constant_case' => [
|
||||
'case' => 'lower',
|
||||
],
|
||||
'class_attributes_separation' => true,
|
||||
'combine_consecutive_unsets' => true,
|
||||
'declare_strict_types' => true,
|
||||
'linebreak_after_opening_tag' => true,
|
||||
'lowercase_static_reference' => true,
|
||||
'no_useless_else' => true,
|
||||
'no_unused_imports' => true,
|
||||
'not_operator_with_successor_space' => false,
|
||||
'not_operator_with_space' => false,
|
||||
'ordered_class_elements' => true,
|
||||
'php_unit_strict' => false,
|
||||
'phpdoc_separation' => false,
|
||||
'single_quote' => true,
|
||||
'standardize_not_equals' => true,
|
||||
'multiline_comment_opening_closing' => true,
|
||||
'phpdoc_summary' => false,
|
||||
])
|
||||
->setRules($rules)
|
||||
->setFinder(
|
||||
PhpCsFixer\Finder::create()
|
||||
->exclude('vendor')
|
||||
->exclude('docs')
|
||||
->in(__DIR__ . '/src')
|
||||
->in(__DIR__ . '/tests')
|
||||
)
|
||||
->setUsingCache(false);
|
||||
|
||||
78
README.md
78
README.md
@@ -3,14 +3,42 @@
|
||||
<h2>炸毛框架</h2>
|
||||
炸毛框架 (zhamao-framework) 是一个协程高性能的聊天机器人 + Web 服务器开发框架<br><br>
|
||||
|
||||
[](http://wpa.qq.com/msgrd?v=3&uin=627577391&site=qq&menu=yes)
|
||||
[](https://github.com/zhamao-robot/zhamao-framework/blob/master/LICENSE)
|
||||
[](https://packagist.org/packages/zhamao/framework)
|
||||
[](https://github.com/howmanybots/onebot)
|
||||

|
||||
<p align="center">
|
||||
<a href="https://onebot.dev/">
|
||||
<img src="https://img.shields.io/badge/OneBot-11-black?style=flat-square" alt="OneBot">
|
||||
</a>
|
||||
|
||||
[](https://github.com/zhamao-robot/zhamao-framework/search?q=AnnotationBase)
|
||||
[](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>
|
||||
|
||||
<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>
|
||||
|
||||
@@ -18,7 +46,7 @@
|
||||
|
||||
**如果有愿意一起开发框架本身的开发者,请提出 PR 或 Issue 参与开发!如果对框架本身的核心设计有更好的想法,可与作者成立开发组(目前仅 2 人),参与 OneBot V12 生态和框架本身的开发。**
|
||||
|
||||
**相关正在进行的版本任务见 Projects 一栏!**
|
||||
**3.0已进入Alpha阶段**
|
||||
|
||||
## 简介
|
||||
|
||||
@@ -46,18 +74,32 @@ public function index() {
|
||||
|
||||
## 开始
|
||||
|
||||
如果你是初学者,可以直接使用以下脚本部署 PHP 环境和安装框架的脚手架:
|
||||
框架目前支持 Linux、WSL、macOS 环境直接运行,上述环境可直接使用下方一键安装脚本。
|
||||
|
||||
> 如果你想在其他环境安装部署,可使用 Docker、Cygwin,详见文档。
|
||||
|
||||
```bash
|
||||
# 新建一个自己喜欢名字的文件夹,运行一键安装脚本 (仅限 x86-64(AMD64) 和 AArch64(ARM64) 平台)
|
||||
mkdir zhamao-app/
|
||||
cd zhamao-app/
|
||||
# 默认安装的 PHP 版本为 7.4,如需使用其他版本,请设置环境变量 ZM_DOWN_PHP_VERSION 为对应的 PHP 版本,例如:
|
||||
# export ZM_DOWN_PHP_VERSION=8.1
|
||||
bash -c "$(curl -fsSL https://api.zhamao.xin/go.sh)"
|
||||
# 检测PHP环境、安装框架
|
||||
bash <(curl -fsSL https://zhamao.xin/go.sh)
|
||||
|
||||
# 启动
|
||||
./zhamao server:start
|
||||
# 启动框架
|
||||
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) 。
|
||||
@@ -108,7 +150,7 @@ bash -c "$(curl -fsSL https://api.zhamao.xin/go.sh)"
|
||||
|
||||
框架和 SDK 是 炸毛机器人 项目的核心框架开源部分。炸毛机器人是作者写的一个高性能机器人,曾获全国计算机设计大赛一等奖。
|
||||
|
||||
作者的炸毛机器人已从2018年初起稳定运行了**四年半**,并且持续迭代。
|
||||
作者的炸毛机器人已从2018年初起稳定运行了**五年**,并且持续迭代。
|
||||
|
||||
欢迎随时在 HTTP-API 插件群里提问,当然更好的话可以加作者 QQ([627577391](http://wpa.qq.com/msgrd?v=3&uin=627577391&site=qq&menu=yes))
|
||||
或提交 [Issue](https://github.com/zhamao-robot/zhamao-framework/issues/new/choose) 进行疑难解答。
|
||||
|
||||
19
bin/gendoc
19
bin/gendoc
@@ -5,7 +5,6 @@
|
||||
* 决定是否忽略该类
|
||||
*
|
||||
* @param ReflectionClass $class 准备生成的类的反射类
|
||||
* @return bool
|
||||
*/
|
||||
function should_ignore_class(ReflectionClass $class): bool
|
||||
{
|
||||
@@ -70,7 +69,7 @@ if (file_exists($root . '/vendor/jasny/phpdoc-parser/composer.json')) {
|
||||
foreach ($composers as $composer) {
|
||||
if (check_composer_executable($composer)) {
|
||||
echo '正在使用 ' . $composer . ' 安装 PHPDoc 解析库,请稍候...' . PHP_EOL;
|
||||
passthru("$composer require --quiet jasny/phpdoc-parser", $exit_code);
|
||||
passthru("{$composer} require --quiet jasny/phpdoc-parser", $exit_code);
|
||||
if ($exit_code === 0) {
|
||||
$phpdoc_package_temp_installed = true;
|
||||
break;
|
||||
@@ -92,14 +91,15 @@ use Jasny\PhpdocParser\Set\PhpDocumentor;
|
||||
use Jasny\PhpdocParser\Tag\Summery;
|
||||
use ZM\Console\Console;
|
||||
|
||||
$opts = getopt('', ['show-warnings']);
|
||||
$opts = getopt('', ['show-warnings', 'show-debug']);
|
||||
|
||||
if (array_key_exists('show-warnings', $opts)) {
|
||||
$show_warnings = true;
|
||||
} else {
|
||||
$show_warnings = false;
|
||||
}
|
||||
|
||||
Console::init(2);
|
||||
Console::init(array_key_exists('show-debug', $opts) ? 4 : 2);
|
||||
|
||||
$errors = [];
|
||||
$warnings = [];
|
||||
@@ -231,7 +231,7 @@ function get_class_metas(string $class_name, PhpdocParser $parser): array
|
||||
* 将方法的元数据转换为 Markdown 格式
|
||||
*
|
||||
* @param string $method 方法名
|
||||
* @param array $meta 元数据
|
||||
* @param array $meta 元数据
|
||||
*/
|
||||
function convert_meta_to_markdown(string $method, array $meta): string
|
||||
{
|
||||
@@ -264,6 +264,7 @@ function convert_meta_to_markdown(string $method, array $meta): string
|
||||
foreach ($meta['params'] as $param_name => $param_meta) {
|
||||
$markdown .= '| ' . $param_name . ' | ' . $param_meta['type'] . ' | ' . $param_meta['description'] . ' |' . "\n";
|
||||
}
|
||||
$markdown .= "\n";
|
||||
}
|
||||
|
||||
// 返回值
|
||||
@@ -296,12 +297,16 @@ foreach (new \RecursiveIteratorIterator($fs) as $file) {
|
||||
// 过滤不包含类的文件
|
||||
$tokens = token_get_all(file_get_contents($path));
|
||||
$found = false;
|
||||
foreach ($tokens as $token) {
|
||||
foreach ($tokens as $k => $token) {
|
||||
if (!is_array($token)) {
|
||||
continue;
|
||||
}
|
||||
if ($token[0] === T_CLASS) {
|
||||
if ($token[0] === T_CLASS && $tokens[$k - 2][0] !== T_NEW) {
|
||||
$found = true;
|
||||
break;
|
||||
}
|
||||
if ($k >= 100) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!$found) {
|
||||
|
||||
142
bin/phpunit-swoole
Normal file → Executable file
142
bin/phpunit-swoole
Normal file → Executable file
@@ -1,69 +1,111 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
/**
|
||||
* Copyright: Swlib
|
||||
* Author: Twosee <twose@qq.com>
|
||||
* Date: 2018/4/14 下午10:58
|
||||
*/
|
||||
/** 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
|
||||
'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');
|
||||
}
|
||||
|
||||
foreach ([
|
||||
__DIR__ . '/../../../autoload.php',
|
||||
__DIR__ . '/../../autoload.php',
|
||||
__DIR__ . '/../vendor/autoload.php',
|
||||
__DIR__ . '/vendor/autoload.php'
|
||||
] as $file
|
||||
) {
|
||||
if (file_exists($file)) {
|
||||
define('PHPUNIT_COMPOSER_INSTALL', $file);
|
||||
break;
|
||||
}
|
||||
}
|
||||
require $root . '/vendor/autoload.php';
|
||||
|
||||
if (!defined('PHPUNIT_COMPOSER_INSTALL')) {
|
||||
fwrite(
|
||||
STDERR,
|
||||
'You need to set up the project dependencies using Composer:' . PHP_EOL . PHP_EOL .
|
||||
' composer install' . PHP_EOL . PHP_EOL .
|
||||
'You can learn all about Composer on https://getcomposer.org/.' . PHP_EOL
|
||||
);
|
||||
const ZM_VERSION_ID = ConsoleApplication::VERSION_ID;
|
||||
const ZM_VERSION = ConsoleApplication::VERSION;
|
||||
|
||||
die(1);
|
||||
} else {
|
||||
if (array_reverse(explode('/', __DIR__))[0] ?? '' === 'test') {
|
||||
$vendor_dir = dirname(PHPUNIT_COMPOSER_INSTALL);
|
||||
$bin_unit = "{$vendor_dir}/bin/phpunit";
|
||||
$unit_uint = "{$vendor_dir}/phpunit/phpunit/phpunit";
|
||||
if (file_exists($bin_unit)) {
|
||||
@unlink($bin_unit);
|
||||
@symlink(__FILE__, $bin_unit);
|
||||
}
|
||||
if (file_exists($unit_uint)) {
|
||||
@unlink($unit_uint);
|
||||
@symlink(__FILE__, $unit_uint);
|
||||
}
|
||||
// 模拟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);
|
||||
}
|
||||
}
|
||||
/** @noinspection PhpIncludeInspection */
|
||||
require PHPUNIT_COMPOSER_INSTALL;
|
||||
$starttime = microtime(true);
|
||||
go(function () {
|
||||
}, true, true);
|
||||
|
||||
Console::setLevel(0);
|
||||
$framework = new Framework($options);
|
||||
$start = new OnStart();
|
||||
$start->method = function () {
|
||||
try {
|
||||
require_once __DIR__.'/../test/bootstrap.php';
|
||||
PHPUnit\TextUI\Command::main(false);
|
||||
} catch (Exception $e) {
|
||||
echo $e->getMessage() . PHP_EOL;
|
||||
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();
|
||||
echo "Took " . round(microtime(true) - $starttime, 4) . "s\n";
|
||||
if (ZMAtomic::get('stop_signal')->get() === 2) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
@@ -1,38 +1,17 @@
|
||||
{
|
||||
"name": "zhamao/framework",
|
||||
"description": "High performance chat robot and web server development framework",
|
||||
"minimum-stability": "stable",
|
||||
"license": "Apache-2.0",
|
||||
"extra": {
|
||||
"zm": {
|
||||
"exclude-annotation-path": [
|
||||
"src/ZM"
|
||||
]
|
||||
},
|
||||
"hooks": {
|
||||
"post-merge": "composer install",
|
||||
"pre-commit": [
|
||||
"echo committing as $(git config user.name)",
|
||||
"./vendor/bin/php-cs-fixer fix --dry-run --diff ./src"
|
||||
],
|
||||
"pre-push": [
|
||||
"./vendor/bin/php-cs-fixer fix --dry-run --diff ./src",
|
||||
"composer analyse"
|
||||
]
|
||||
}
|
||||
},
|
||||
"authors": [
|
||||
{
|
||||
"name": "jerry",
|
||||
"email": "admin@zhamao.me"
|
||||
},
|
||||
{
|
||||
"name": "sunxyw",
|
||||
"email": "dev@sunxyw.xyz"
|
||||
}
|
||||
],
|
||||
"prefer-stable": true,
|
||||
"bin": [
|
||||
"bin/start",
|
||||
"bin/phpunit-swoole",
|
||||
"bin/gendoc"
|
||||
],
|
||||
"require": {
|
||||
"php": "^7.2 || ^7.3 || ^7.4 || ^8.0 || ^8.1",
|
||||
"ext-json": "*",
|
||||
@@ -41,17 +20,27 @@
|
||||
"dragonmantank/cron-expression": "^3.3",
|
||||
"jelix/version": "^2.0",
|
||||
"koriym/attributes": "^1.0",
|
||||
"psr/container": "^2.0",
|
||||
"psy/psysh": "^0.11.2",
|
||||
"symfony/console": "~5.0 || ~4.0 || ~3.0",
|
||||
"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": "~5.0 || ~4.0 || ~3.0",
|
||||
"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"
|
||||
},
|
||||
"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",
|
||||
@@ -59,6 +48,8 @@
|
||||
"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"
|
||||
@@ -70,25 +61,47 @@
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"Module\\": "src/Module",
|
||||
"Custom\\": "src/Custom"
|
||||
"Custom\\": "src/Custom",
|
||||
"Tests\\": "tests"
|
||||
}
|
||||
},
|
||||
"bin": [
|
||||
"bin/gendoc",
|
||||
"bin/phpunit-swoole",
|
||||
"bin/start"
|
||||
],
|
||||
"config": {
|
||||
"optimize-autoloader": true,
|
||||
"sort-packages": true
|
||||
"sort-packages": true,
|
||||
"allow-plugins": {
|
||||
"phpstan/extension-installer": true
|
||||
}
|
||||
},
|
||||
"require-dev": {
|
||||
"brainmaestro/composer-git-hooks": "^2.8",
|
||||
"friendsofphp/php-cs-fixer": "^3.2 != 3.7.0",
|
||||
"phpstan/phpstan": "^1.1",
|
||||
"phpunit/phpunit": "^8.5 || ^9.0",
|
||||
"swoole/ide-helper": "^4.5"
|
||||
"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 -l 0 ./src",
|
||||
"cs-fix": "php-cs-fixer fix $1"
|
||||
"analyse": "phpstan analyse --memory-limit 300M",
|
||||
"cs-fix": "php-cs-fixer fix",
|
||||
"test": "bin/phpunit-swoole --no-coverage"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,6 +50,8 @@ $config['runtime'] = [
|
||||
],
|
||||
'namespace' => [],
|
||||
],
|
||||
'inside_table_size' => 65536 // 内部表字符串最大长度(需要2的倍数)
|
||||
// 正常不要低于65536,如果群数量过多可能出现会size不够。若swoole日志出现WARNING TableRow::set_value(): [key=wait_api,field=value]string value is too long可以将该值往大设置。
|
||||
];
|
||||
|
||||
/* 轻量字符串缓存,默认开启 */
|
||||
|
||||
@@ -1 +1 @@
|
||||
module.exports = [{"title":"ZM","collapsable":true,"children":["ZM/ZMServer","ZM/ConsoleApplication","ZM/Framework"]},{"title":"ZM/API","collapsable":true,"children":["ZM/API/CQ","ZM/API/OneBotV11","ZM/API/TuringAPI","ZM/API/GoCqhttpAPIV11"]},{"title":"ZM/Annotation","collapsable":true,"children":["ZM/Annotation/AnnotationParser"]},{"title":"ZM/Annotation/Swoole","collapsable":true,"children":["ZM/Annotation/Swoole/OnSwooleEventBase"]},{"title":"ZM/Command","collapsable":true,"children":["ZM/Command/CheckConfigCommand"]},{"title":"ZM/Command/Generate","collapsable":true,"children":["ZM/Command/Generate/APIDocsGenerateCommand"]},{"title":"ZM/Context","collapsable":true,"children":["ZM/Context/Context"]},{"title":"ZM/DB","collapsable":true,"children":["ZM/DB/Table","ZM/DB/DeleteBody","ZM/DB/UpdateBody","ZM/DB/DB","ZM/DB/SelectBody","ZM/DB/InsertBody"]},{"title":"ZM/Event","collapsable":true,"children":["ZM/Event/EventManager","ZM/Event/EventTracer","ZM/Event/EventDispatcher"]},{"title":"ZM/Event/SwooleEvent","collapsable":true,"children":["ZM/Event/SwooleEvent/OnWorkerStart","ZM/Event/SwooleEvent/OnTask"]},{"title":"ZM/Http","collapsable":true,"children":["ZM/Http/Response"]},{"title":"ZM/Module","collapsable":true,"children":["ZM/Module/ModuleUnpacker","ZM/Module/ModulePacker","ZM/Module/ModuleBase","ZM/Module/QQBot"]},{"title":"ZM/MySQL","collapsable":true,"children":["ZM/MySQL/MySQLStatementWrapper","ZM/MySQL/MySQLQueryBuilder","ZM/MySQL/MySQLWrapper","ZM/MySQL/MySQLPool"]},{"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/Terminal","ZM/Utils/MessageUtil","ZM/Utils/DataProvider","ZM/Utils/SignalListener","ZM/Utils/ZMUtil","ZM/Utils/HttpUtil","ZM/Utils/CoMessage"]},{"title":"ZM/Utils/Manager","collapsable":true,"children":["ZM/Utils/Manager/CronManager","ZM/Utils/Manager/ModuleManager","ZM/Utils/Manager/WorkerManager"]}]
|
||||
module.exports = [{"title":"ZM","collapsable":true,"children":["ZM/ZMServer"]},{"title":"ZM/API","collapsable":true,"children":["ZM/API/CQ","ZM/API/ZMRobot","ZM/API/TuringAPI","ZM/API/GoCqhttpAPIV11","ZM/API/OneBotV11"]},{"title":"ZM/API/Proxies/Bot","collapsable":true,"children":["ZM/API/Proxies/Bot/AllGroupsProxy","ZM/API/Proxies/Bot/AbstractBotProxy","ZM/API/Proxies/Bot/AllBotsProxy"]},{"title":"ZM/Annotation/Swoole","collapsable":true,"children":["ZM/Annotation/Swoole/OnSwooleEventBase"]},{"title":"ZM/Command","collapsable":true,"children":["ZM/Command/CheckConfigCommand"]},{"title":"ZM/Command/Module","collapsable":true,"children":["ZM/Command/Module/ModulePackCommand","ZM/Command/Module/ModuleListCommand"]},{"title":"ZM/Container","collapsable":true,"children":["ZM/Container/BoundMethod","ZM/Container/WorkerContainer","ZM/Container/Container"]},{"title":"ZM/DB","collapsable":true,"children":["ZM/DB/UpdateBody","ZM/DB/DB","ZM/DB/InsertBody","ZM/DB/DeleteBody","ZM/DB/Table","ZM/DB/SelectBody"]},{"title":"ZM/Event","collapsable":true,"children":["ZM/Event/EventDispatcher","ZM/Event/EventTracer","ZM/Event/EventManager"]},{"title":"ZM/Event/SwooleEvent","collapsable":true,"children":["ZM/Event/SwooleEvent/OnMessage","ZM/Event/SwooleEvent/OnTask"]},{"title":"ZM/Http","collapsable":true,"children":["ZM/Http/Response"]},{"title":"ZM/Module","collapsable":true,"children":["ZM/Module/ModuleUnpacker","ZM/Module/ModuleBase","ZM/Module/ModulePacker"]},{"title":"ZM/MySQL","collapsable":true,"children":["ZM/MySQL/MySQLPool","ZM/MySQL/MySQLWrapper","ZM/MySQL/MySQLStatementWrapper","ZM/MySQL/MySQLQueryBuilder","ZM/MySQL/MySQLConnection","ZM/MySQL/MySQLStatement"]},{"title":"ZM/Store","collapsable":true,"children":["ZM/Store/LightCacheInside","ZM/Store/ZMAtomic","ZM/Store/LightCache"]},{"title":"ZM/Store/Redis","collapsable":true,"children":["ZM/Store/Redis/ZMRedis"]},{"title":"ZM/Utils","collapsable":true,"children":["ZM/Utils/CommandInfoUtil","ZM/Utils/Terminal","ZM/Utils/DataProvider","ZM/Utils/SignalListener","ZM/Utils/CoMessage","ZM/Utils/ReflectionUtil","ZM/Utils/MessageUtil","ZM/Utils/ZMUtil","ZM/Utils/HttpUtil"]},{"title":"ZM/Utils/Manager","collapsable":true,"children":["ZM/Utils/Manager/ModuleManager","ZM/Utils/Manager/WorkerManager","ZM/Utils/Manager/CronManager"]}]
|
||||
@@ -4,7 +4,7 @@
|
||||
<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="http://api.btstu.cn/sjtx/api.php" alt=""/>
|
||||
<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=""/>
|
||||
@@ -138,4 +138,4 @@ export default {
|
||||
height: 36px !important;
|
||||
border-radius: 18px;
|
||||
}
|
||||
</style>
|
||||
</style>
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
const apiConfig = require('./api')
|
||||
|
||||
module.exports = {
|
||||
title: '炸毛框架',
|
||||
description: '一个聊天机器人 + Web 框架',
|
||||
title: '炸毛框架(v2 旧版)',
|
||||
description: '一个高性能聊天机器人 + Web 框架',
|
||||
theme: 'antdocs',
|
||||
markdown: {
|
||||
lineNumbers: true
|
||||
@@ -34,7 +34,7 @@ module.exports = {
|
||||
{ text: 'API', link: '/api/' },
|
||||
{ text: 'FAQ', link: '/faq/' },
|
||||
{ text: '更新日志', link: '/update/v2/' },
|
||||
{ text: '炸毛框架 v1', link: 'https://docs-v1.zhamao.xin/' }
|
||||
{ text: '炸毛框架 v3(最新版)', link: 'https://framework.zhamao.xin/' }
|
||||
],
|
||||
sidebar: {
|
||||
'/guide/': [
|
||||
@@ -189,4 +189,4 @@ module.exports = {
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1 +1 @@
|
||||
framework.zhamao.me
|
||||
docs-v2.zhamao.me
|
||||
|
||||
@@ -1,18 +1,17 @@
|
||||
---
|
||||
home: true
|
||||
heroImage: ./logo_trans.png
|
||||
actionBtn:
|
||||
text: 快速上手
|
||||
link: /guide/
|
||||
type: primary
|
||||
size: large
|
||||
actions:
|
||||
- theme: brand
|
||||
text: 快速上手
|
||||
link: /guide/
|
||||
features:
|
||||
- title: 高性能
|
||||
details: 基于 PHP 的 Swoole 高性能扩展,利用 WebSocket 进行与 OneBot 协议兼容的聊天机器人软件的通信,还有数据库连接池、内存缓存、多任务进程等特色,大幅增强性能。
|
||||
- title: 易于开发
|
||||
details: 所有功能采用模块化设计,除特殊情况外几乎所有功能都不需要修改框架内任意代码,框架采用灵活的注解进行各类事件绑定,同时支持下断点调试。
|
||||
- title: 接口直观
|
||||
details: 支持命令、普通文本、正则匹配、自然语言处理等多种对话解析方式,利用协程巧妙实现了直观的交互式会话模式,同时支持多种富文本的处理。
|
||||
- title: 高性能
|
||||
details: 基于 PHP 的 Swoole 高性能扩展,利用 WebSocket 进行与 OneBot 协议兼容的聊天机器人软件的通信,还有数据库连接池、内存缓存、多任务进程等特色,大幅增强性能。
|
||||
- title: 易于开发
|
||||
details: 所有功能采用模块化设计,除特殊情况外几乎所有功能都不需要修改框架内任意代码,框架采用灵活的注解进行各类事件绑定,同时支持下断点调试。
|
||||
- title: 接口直观
|
||||
details: 支持命令、普通文本、正则匹配、自然语言处理等多种对话解析方式,利用协程巧妙实现了直观的交互式会话模式,同时支持多种富文本的处理。
|
||||
footer: |
|
||||
Apache-2.0 Licensed | Copyright © 2019-2022 Zhamao Developer Team | <a href="http://beian.miit.gov.cn">沪ICP备2021010446号-1</a>
|
||||
---
|
||||
@@ -21,17 +20,16 @@ footer: |
|
||||
|
||||
## 安装框架和环境
|
||||
|
||||
此命令可一键以模板安装 `zhamao-framework` 和 `PHP` 独立环境到目录下,无需 root!(仅限 Linux)
|
||||
此命令可一键以模板安装框架!(仅限 Linux 和 macOS)
|
||||
|
||||
```bash
|
||||
mkdir my-app
|
||||
cd my-app
|
||||
bash -c "$(curl -fsSL https://api.zhamao.xin/go.sh)"
|
||||
bash <(curl -fsSL https://zhamao.xin/go.sh)
|
||||
```
|
||||
|
||||
## 运行框架
|
||||
|
||||
```bash
|
||||
cd zhamao-app/
|
||||
./zhamao server
|
||||
```
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
## at
|
||||
|
||||
```php
|
||||
public function at(mixed $qq): string
|
||||
public function at(int|string $qq): string
|
||||
```
|
||||
|
||||
### 描述
|
||||
@@ -14,18 +14,19 @@ at一下QQ用户(仅在QQ群支持at全体)
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| qq | mixed | |
|
||||
| qq | int|string | 用户QQ号/ID号 |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| string | |
|
||||
| string | CQ码 |
|
||||
|
||||
|
||||
## face
|
||||
|
||||
```php
|
||||
public function face(mixed $id): string
|
||||
public function face(int|string $id): string
|
||||
```
|
||||
|
||||
### 描述
|
||||
@@ -36,18 +37,19 @@ public function face(mixed $id): string
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| id | mixed | |
|
||||
| id | int|string | 表情ID |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| string | |
|
||||
| string | CQ码 |
|
||||
|
||||
|
||||
## image
|
||||
|
||||
```php
|
||||
public function image(mixed $file, bool $cache, bool $flash, bool $proxy, int $timeout): string
|
||||
public function image(string $file, bool $cache, bool $flash, bool $proxy, int $timeout): string
|
||||
```
|
||||
|
||||
### 描述
|
||||
@@ -58,22 +60,23 @@ public function image(mixed $file, bool $cache, bool $flash, bool $proxy, int $t
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| file | mixed | |
|
||||
| cache | bool | |
|
||||
| flash | bool | |
|
||||
| proxy | bool | |
|
||||
| timeout | int | |
|
||||
| file | string | 文件的路径、URL或者base64编码的图片数据 |
|
||||
| cache | bool | 是否缓存(默认为true) |
|
||||
| flash | bool | 是否闪照(默认为false) |
|
||||
| proxy | bool | 是否使用代理(默认为true) |
|
||||
| timeout | int | 超时时间(默认不超时) |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| string | |
|
||||
| string | CQ码 |
|
||||
|
||||
|
||||
## record
|
||||
|
||||
```php
|
||||
public function record(mixed $file, bool $magic, bool $cache, bool $proxy, int $timeout): string
|
||||
public function record(string $file, bool $magic, bool $cache, bool $proxy, int $timeout): string
|
||||
```
|
||||
|
||||
### 描述
|
||||
@@ -84,22 +87,23 @@ public function record(mixed $file, bool $magic, bool $cache, bool $proxy, int $
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| file | mixed | |
|
||||
| magic | bool | |
|
||||
| cache | bool | |
|
||||
| proxy | bool | |
|
||||
| timeout | int | |
|
||||
| file | string | 文件的路径、URL或者base64编码的语音数据 |
|
||||
| magic | bool | 是否加特技(默认为false) |
|
||||
| cache | bool | 是否缓存(默认为true) |
|
||||
| proxy | bool | 是否使用代理(默认为true) |
|
||||
| timeout | int | 超时时间(默认不超时) |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| string | |
|
||||
| string | CQ码 |
|
||||
|
||||
|
||||
## video
|
||||
|
||||
```php
|
||||
public function video(mixed $file, bool $cache, bool $proxy, int $timeout): string
|
||||
public function video(string $file, bool $cache, bool $proxy, int $timeout): string
|
||||
```
|
||||
|
||||
### 描述
|
||||
@@ -110,15 +114,16 @@ public function video(mixed $file, bool $cache, bool $proxy, int $timeout): stri
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| file | mixed | |
|
||||
| cache | bool | |
|
||||
| proxy | bool | |
|
||||
| timeout | int | |
|
||||
| file | string | 文件的路径、URL或者base64编码的短视频数据 |
|
||||
| cache | bool | 是否缓存(默认为true) |
|
||||
| proxy | bool | 是否使用代理(默认为true) |
|
||||
| timeout | int | 超时时间(默认不超时) |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| string | |
|
||||
| string | CQ码 |
|
||||
|
||||
|
||||
## rps
|
||||
@@ -135,7 +140,7 @@ public function rps(): string
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| string | |
|
||||
| string | CQ码 |
|
||||
|
||||
|
||||
## dice
|
||||
@@ -152,7 +157,7 @@ public function dice(): string
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| string | |
|
||||
| string | CQ码 |
|
||||
|
||||
|
||||
## shake
|
||||
@@ -169,13 +174,13 @@ public function shake(): string
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| string | |
|
||||
| string | CQ码 |
|
||||
|
||||
|
||||
## poke
|
||||
|
||||
```php
|
||||
public function poke(mixed $type, mixed $id, string $name): string
|
||||
public function poke(int|string $type, int|string $id, string $name): string
|
||||
```
|
||||
|
||||
### 描述
|
||||
@@ -186,14 +191,15 @@ public function poke(mixed $type, mixed $id, string $name): string
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| type | mixed | |
|
||||
| id | mixed | |
|
||||
| name | string | |
|
||||
| type | int|string | 焯一戳类型 |
|
||||
| id | int|string | 戳一戳ID号 |
|
||||
| name | string | 戳一戳名称(可选) |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| string | |
|
||||
| string | CQ码 |
|
||||
|
||||
|
||||
## anonymous
|
||||
@@ -210,18 +216,19 @@ public function anonymous(int $ignore): string
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| ignore | int | |
|
||||
| ignore | int | 是否忽略错误(默认为1,0表示不忽略错误) |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| string | |
|
||||
| string | CQ码 |
|
||||
|
||||
|
||||
## share
|
||||
|
||||
```php
|
||||
public function share(mixed $url, mixed $title, null $content, null $image): string
|
||||
public function share(string $url, string $title, null|string $content, null|string $image): string
|
||||
```
|
||||
|
||||
### 描述
|
||||
@@ -232,21 +239,22 @@ public function share(mixed $url, mixed $title, null $content, null $image): str
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| url | mixed | |
|
||||
| title | mixed | |
|
||||
| content | null | |
|
||||
| image | null | |
|
||||
| url | string | 分享地址 |
|
||||
| title | string | 标题 |
|
||||
| content | null|string | 卡片内容(可选) |
|
||||
| image | null|string | 卡片图片(可选) |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| string | |
|
||||
| string | CQ码 |
|
||||
|
||||
|
||||
## contact
|
||||
|
||||
```php
|
||||
public function contact(mixed $type, mixed $id): string
|
||||
public function contact(int|string $type, int|string $id): string
|
||||
```
|
||||
|
||||
### 描述
|
||||
@@ -257,19 +265,20 @@ public function contact(mixed $type, mixed $id): string
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| type | mixed | |
|
||||
| id | mixed | |
|
||||
| type | int|string | 名片类型 |
|
||||
| id | int|string | 好友或群ID |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| string | |
|
||||
| string | CQ码 |
|
||||
|
||||
|
||||
## location
|
||||
|
||||
```php
|
||||
public function location(mixed $lat, mixed $lon, string $title, string $content): string
|
||||
public function location(float|string $lat, float|string $lon, string $title, string $content): string
|
||||
```
|
||||
|
||||
### 描述
|
||||
@@ -280,56 +289,173 @@ public function location(mixed $lat, mixed $lon, string $title, string $content)
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| lat | mixed | |
|
||||
| lon | mixed | |
|
||||
| title | string | |
|
||||
| content | string | |
|
||||
| lat | float|string | 纬度 |
|
||||
| lon | float|string | 经度 |
|
||||
| title | string | 标题(可选) |
|
||||
| content | string | 卡片内容(可选) |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| string | |
|
||||
| string | CQ码 |
|
||||
|
||||
|
||||
## music
|
||||
|
||||
```php
|
||||
public function music(mixed $type, mixed $id_or_url, null $audio, null $title, null $content, null $image): string
|
||||
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后使用
|
||||
custom为自定义分享
|
||||
当为自定义分享时:
|
||||
$id_or_url 为音乐卡片点进去打开的链接(一般是音乐介绍界面啦什么的)
|
||||
$audio 为音乐(如mp3文件)的HTTP链接地址(不可为空)
|
||||
$title 为音乐卡片的标题,建议12字以内(不可为空)
|
||||
$content 为音乐卡片的简介(可忽略)
|
||||
$image 为音乐卡片的图片链接地址(可忽略)
|
||||
|
||||
### 参数
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| type | mixed | |
|
||||
| id_or_url | mixed | |
|
||||
| audio | null | |
|
||||
| title | null | |
|
||||
| content | null | |
|
||||
| image | null | |
|
||||
| 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 | |
|
||||
| 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(mixed $msg, mixed $is_content): mixed
|
||||
public function decode(int|string|Stringable $msg, bool $is_content): string
|
||||
```
|
||||
|
||||
### 描述
|
||||
@@ -340,19 +466,43 @@ public function decode(mixed $msg, mixed $is_content): mixed
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| msg | mixed | |
|
||||
| is_content | mixed | |
|
||||
| msg | int|string|Stringable | 字符串 |
|
||||
| is_content | bool | 如果是解码CQ码本体内容,则为false(默认),如果是参数内的字符串,则为true |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| mixed | |
|
||||
| string | 转义后的CQ码 |
|
||||
|
||||
|
||||
## replace
|
||||
|
||||
```php
|
||||
public function replace(int|string|Stringable $str): string
|
||||
```
|
||||
|
||||
### 描述
|
||||
|
||||
简单反转义替换CQ码的方括号
|
||||
|
||||
### 参数
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| str | int|string|Stringable | 字符串 |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| string | 字符串 |
|
||||
|
||||
|
||||
## escape
|
||||
|
||||
```php
|
||||
public function escape(mixed $msg, mixed $is_content): mixed
|
||||
public function escape(int|string|Stringable $msg, bool $is_content): string
|
||||
```
|
||||
|
||||
### 描述
|
||||
@@ -363,19 +513,20 @@ public function escape(mixed $msg, mixed $is_content): mixed
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| msg | mixed | |
|
||||
| is_content | mixed | |
|
||||
| msg | int|string|Stringable | 字符串 |
|
||||
| is_content | bool | 如果是转义CQ码本体内容,则为false(默认),如果是参数内的字符串,则为true |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| mixed | |
|
||||
| string | 转义后的CQ码 |
|
||||
|
||||
|
||||
## encode
|
||||
|
||||
```php
|
||||
public function encode(mixed $msg, mixed $is_content): mixed
|
||||
public function encode(int|string|Stringable $msg, bool $is_content): string
|
||||
```
|
||||
|
||||
### 描述
|
||||
@@ -386,19 +537,20 @@ public function encode(mixed $msg, mixed $is_content): mixed
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| msg | mixed | |
|
||||
| is_content | mixed | |
|
||||
| msg | int|string|Stringable | 字符串 |
|
||||
| is_content | bool | 如果是转义CQ码本体内容,则为false(默认),如果是参数内的字符串,则为true |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| mixed | |
|
||||
| string | 转义后的CQ码 |
|
||||
|
||||
|
||||
## removeCQ
|
||||
|
||||
```php
|
||||
public function removeCQ(mixed $msg): string
|
||||
public function removeCQ(string $msg): string
|
||||
```
|
||||
|
||||
### 描述
|
||||
@@ -409,18 +561,19 @@ public function removeCQ(mixed $msg): string
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| msg | mixed | |
|
||||
| msg | string | 消息 |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| string | |
|
||||
| string | 消息内容 |
|
||||
|
||||
|
||||
## getCQ
|
||||
|
||||
```php
|
||||
public function getCQ(mixed $msg, mixed $is_object): mixed
|
||||
public function getCQ(string $msg, bool $is_object): null|array|CQObject
|
||||
```
|
||||
|
||||
### 描述
|
||||
@@ -431,19 +584,20 @@ public function getCQ(mixed $msg, mixed $is_object): mixed
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| msg | mixed | |
|
||||
| is_object | mixed | |
|
||||
| msg | string | 消息内容 |
|
||||
| is_object | bool | 是否以对象形式返回,如果为False的话,返回数组形式(默认为false) |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| mixed | |
|
||||
| null|array|CQObject | 返回的CQ码(数组或对象) |
|
||||
|
||||
|
||||
## getAllCQ
|
||||
|
||||
```php
|
||||
public function getAllCQ(mixed $msg, mixed $is_object): mixed
|
||||
public function getAllCQ(string $msg, bool $is_object): array|CQObject[]
|
||||
```
|
||||
|
||||
### 描述
|
||||
@@ -454,10 +608,11 @@ public function getAllCQ(mixed $msg, mixed $is_object): mixed
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| msg | mixed | |
|
||||
| is_object | mixed | |
|
||||
| msg | string | 消息内容 |
|
||||
| is_object | bool | 是否以对象形式返回,如果为False的话,返回数组形式(默认为false) |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| mixed | |
|
||||
| array|CQObject[] | 返回的CQ码们(数组或对象) |
|
||||
|
||||
@@ -15,7 +15,7 @@ public function getGuildServiceProfile(): array|bool
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| array|bool | |
|
||||
| array|bool | 返回API调用结果(数组)或异步API调用状态(bool) |
|
||||
|
||||
|
||||
## getGuildList
|
||||
@@ -32,13 +32,13 @@ public function getGuildList(): array|bool
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| array|bool | |
|
||||
| array|bool | 返回API调用结果(数组)或异步API调用状态(bool) |
|
||||
|
||||
|
||||
## getGuildMetaByGuest
|
||||
|
||||
```php
|
||||
public function getGuildMetaByGuest(mixed $guild_id): array|bool
|
||||
public function getGuildMetaByGuest(int|string $guild_id): array|bool
|
||||
```
|
||||
|
||||
### 描述
|
||||
@@ -49,18 +49,19 @@ public function getGuildMetaByGuest(mixed $guild_id): array|bool
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| guild_id | mixed | |
|
||||
| guild_id | int|string | 频道ID |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| array|bool | |
|
||||
| array|bool | 返回API调用结果(数组)或异步API调用状态(bool) |
|
||||
|
||||
|
||||
## getGuildChannelList
|
||||
|
||||
```php
|
||||
public function getGuildChannelList(mixed $guild_id, false $no_cache): array|bool
|
||||
public function getGuildChannelList(int|string $guild_id, false $no_cache): array|bool
|
||||
```
|
||||
|
||||
### 描述
|
||||
@@ -71,19 +72,20 @@ public function getGuildChannelList(mixed $guild_id, false $no_cache): array|boo
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| guild_id | mixed | |
|
||||
| no_cache | false | |
|
||||
| guild_id | int|string | 频道ID |
|
||||
| no_cache | false | 禁用缓存(默认为false) |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| array|bool | |
|
||||
| array|bool | 返回API调用结果(数组)或异步API调用状态(bool) |
|
||||
|
||||
|
||||
## getGuildMembers
|
||||
|
||||
```php
|
||||
public function getGuildMembers(mixed $guild_id): array|bool
|
||||
public function getGuildMembers(int|string $guild_id): array|bool
|
||||
```
|
||||
|
||||
### 描述
|
||||
@@ -94,18 +96,19 @@ public function getGuildMembers(mixed $guild_id): array|bool
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| guild_id | mixed | |
|
||||
| guild_id | int|string | 频道ID |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| array|bool | |
|
||||
| array|bool | 返回API调用结果(数组)或异步API调用状态(bool) |
|
||||
|
||||
|
||||
## sendGuildChannelMsg
|
||||
|
||||
```php
|
||||
public function sendGuildChannelMsg(mixed $guild_id, mixed $channel_id, mixed $message): array|bool
|
||||
public function sendGuildChannelMsg(int|string $guild_id, int|string $channel_id, string $message): array|bool
|
||||
```
|
||||
|
||||
### 描述
|
||||
@@ -116,59 +119,12 @@ public function sendGuildChannelMsg(mixed $guild_id, mixed $channel_id, mixed $m
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| guild_id | mixed | |
|
||||
| channel_id | mixed | |
|
||||
| message | mixed | |
|
||||
| guild_id | int|string | 频道ID |
|
||||
| channel_id | int|string | 子频道ID |
|
||||
| message | string | 信息内容 |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| array|bool | |
|
||||
|
||||
|
||||
## processAPI
|
||||
|
||||
```php
|
||||
public function processAPI(mixed $connection, mixed $reply, |null $function): array|bool
|
||||
```
|
||||
|
||||
### 描述
|
||||
|
||||
作者很懒,什么也没有说
|
||||
|
||||
### 参数
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| connection | mixed | |
|
||||
| reply | mixed | |
|
||||
| function | |null | |
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| array|bool | |
|
||||
|
||||
|
||||
## processHttpAPI
|
||||
|
||||
```php
|
||||
public function processHttpAPI(mixed $connection, mixed $reply, null $function): bool
|
||||
```
|
||||
|
||||
### 描述
|
||||
|
||||
作者很懒,什么也没有说
|
||||
|
||||
### 参数
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| connection | mixed | |
|
||||
| reply | mixed | |
|
||||
| function | null | |
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| bool | |
|
||||
| array|bool | 返回API调用结果(数组)或异步API调用状态(bool) |
|
||||
|
||||
@@ -3,23 +3,24 @@
|
||||
## get
|
||||
|
||||
```php
|
||||
public function get(mixed $robot_id): ZMRobot
|
||||
public function get(int|string $robot_id): ZMRobot
|
||||
```
|
||||
|
||||
### 描述
|
||||
|
||||
作者很懒,什么也没有说
|
||||
获取机器人Action/API实例
|
||||
|
||||
### 参数
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| robot_id | mixed | |
|
||||
| robot_id | int|string | 机器人ID |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| ZMRobot | |
|
||||
| ZMRobot | 机器人实例 |
|
||||
|
||||
|
||||
## getRandom
|
||||
@@ -30,13 +31,13 @@ public function getRandom(): ZMRobot
|
||||
|
||||
### 描述
|
||||
|
||||
作者很懒,什么也没有说
|
||||
随机获取一个连接到框架的机器人实例
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| ZMRobot | |
|
||||
| ZMRobot | 机器人实例 |
|
||||
|
||||
|
||||
## getAllRobot
|
||||
@@ -47,19 +48,65 @@ public function getAllRobot(): ZMRobot[]
|
||||
|
||||
### 描述
|
||||
|
||||
作者很懒,什么也没有说
|
||||
获取所有机器人实例
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| 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(mixed $user_id, mixed $message, bool $auto_escape): null|array|bool
|
||||
public function sendPrivateMsg(int|string $user_id, string $message, bool $auto_escape): array|bool
|
||||
```
|
||||
|
||||
### 描述
|
||||
@@ -70,20 +117,21 @@ public function sendPrivateMsg(mixed $user_id, mixed $message, bool $auto_escape
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| user_id | mixed | |
|
||||
| message | mixed | |
|
||||
| auto_escape | bool | |
|
||||
| user_id | int|string | 用户ID |
|
||||
| message | string | 消息内容 |
|
||||
| auto_escape | bool | 是否自动转义(默认为false) |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| null|array|bool | |
|
||||
| array|bool | 返回API调用结果(数组)或异步API调用状态(bool) |
|
||||
|
||||
|
||||
## sendGroupMsg
|
||||
|
||||
```php
|
||||
public function sendGroupMsg(mixed $group_id, mixed $message, bool $auto_escape): null|array|bool
|
||||
public function sendGroupMsg(int|string $group_id, string $message, bool $auto_escape): array|bool
|
||||
```
|
||||
|
||||
### 描述
|
||||
@@ -94,20 +142,21 @@ public function sendGroupMsg(mixed $group_id, mixed $message, bool $auto_escape)
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| group_id | mixed | |
|
||||
| message | mixed | |
|
||||
| auto_escape | bool | |
|
||||
| group_id | int|string | 群组ID |
|
||||
| message | string | 消息内容 |
|
||||
| auto_escape | bool | 是否自动转义(默认为false) |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| null|array|bool | |
|
||||
| array|bool | 返回API调用结果(数组)或异步API调用状态(bool) |
|
||||
|
||||
|
||||
## sendMsg
|
||||
|
||||
```php
|
||||
public function sendMsg(mixed $message_type, mixed $target_id, mixed $message, bool $auto_escape): null|array|bool
|
||||
public function sendMsg(string $message_type, int|string $target_id, string $message, bool $auto_escape): array|bool
|
||||
```
|
||||
|
||||
### 描述
|
||||
@@ -118,21 +167,22 @@ public function sendMsg(mixed $message_type, mixed $target_id, mixed $message, b
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| message_type | mixed | |
|
||||
| target_id | mixed | |
|
||||
| message | mixed | |
|
||||
| auto_escape | bool | |
|
||||
| message_type | string | 消息类型 |
|
||||
| target_id | int|string | 目标ID |
|
||||
| message | string | 消息内容 |
|
||||
| auto_escape | bool | 是否自动转义(默认为false) |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| null|array|bool | |
|
||||
| array|bool | 返回API调用结果(数组)或异步API调用状态(bool) |
|
||||
|
||||
|
||||
## deleteMsg
|
||||
|
||||
```php
|
||||
public function deleteMsg(mixed $message_id): null|array|bool
|
||||
public function deleteMsg(int|string $message_id): array|bool
|
||||
```
|
||||
|
||||
### 描述
|
||||
@@ -143,18 +193,19 @@ public function deleteMsg(mixed $message_id): null|array|bool
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| message_id | mixed | |
|
||||
| message_id | int|string | 消息ID |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| null|array|bool | |
|
||||
| array|bool | 返回API调用结果(数组)或异步API调用状态(bool) |
|
||||
|
||||
|
||||
## getMsg
|
||||
|
||||
```php
|
||||
public function getMsg(mixed $message_id): null|array|bool
|
||||
public function getMsg(int|string $message_id): array|bool
|
||||
```
|
||||
|
||||
### 描述
|
||||
@@ -165,18 +216,19 @@ public function getMsg(mixed $message_id): null|array|bool
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| message_id | mixed | |
|
||||
| message_id | int|string | 消息ID |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| null|array|bool | |
|
||||
| array|bool | 返回API调用结果(数组)或异步API调用状态(bool) |
|
||||
|
||||
|
||||
## getForwardMsg
|
||||
|
||||
```php
|
||||
public function getForwardMsg(mixed $id): null|array|bool
|
||||
public function getForwardMsg(int|string $id): array|bool
|
||||
```
|
||||
|
||||
### 描述
|
||||
@@ -187,18 +239,19 @@ public function getForwardMsg(mixed $id): null|array|bool
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| id | mixed | |
|
||||
| id | int|string | ID |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| null|array|bool | |
|
||||
| array|bool | 返回API调用结果(数组)或异步API调用状态(bool) |
|
||||
|
||||
|
||||
## sendLike
|
||||
|
||||
```php
|
||||
public function sendLike(mixed $user_id, int $times): null|array|bool
|
||||
public function sendLike(int|string $user_id, int $times): array|bool
|
||||
```
|
||||
|
||||
### 描述
|
||||
@@ -209,19 +262,20 @@ public function sendLike(mixed $user_id, int $times): null|array|bool
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| user_id | mixed | |
|
||||
| times | int | |
|
||||
| user_id | int|string | 用户ID |
|
||||
| times | int | 时间 |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| null|array|bool | |
|
||||
| array|bool | 返回API调用结果(数组)或异步API调用状态(bool) |
|
||||
|
||||
|
||||
## setGroupKick
|
||||
|
||||
```php
|
||||
public function setGroupKick(mixed $group_id, mixed $user_id, bool $reject_add_request): null|array|bool
|
||||
public function setGroupKick(int|string $group_id, int|string $user_id, bool $reject_add_request): array|bool
|
||||
```
|
||||
|
||||
### 描述
|
||||
@@ -232,20 +286,21 @@ public function setGroupKick(mixed $group_id, mixed $user_id, bool $reject_add_r
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| group_id | mixed | |
|
||||
| user_id | mixed | |
|
||||
| group_id | int|string | 群ID |
|
||||
| user_id | int|string | 用户ID |
|
||||
| reject_add_request | bool | |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| null|array|bool | |
|
||||
| array|bool | 返回API调用结果(数组)或异步API调用状态(bool) |
|
||||
|
||||
|
||||
## setGroupBan
|
||||
|
||||
```php
|
||||
public function setGroupBan(mixed $group_id, mixed $user_id, int $duration): null|array|bool
|
||||
public function setGroupBan(int|string $group_id, int|string $user_id, int $duration): array|bool
|
||||
```
|
||||
|
||||
### 描述
|
||||
@@ -256,20 +311,21 @@ public function setGroupBan(mixed $group_id, mixed $user_id, int $duration): nul
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| group_id | mixed | |
|
||||
| user_id | mixed | |
|
||||
| duration | int | |
|
||||
| group_id | int|string | 群ID |
|
||||
| user_id | int|string | 用户ID |
|
||||
| duration | int | 禁言时长 |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| null|array|bool | |
|
||||
| array|bool | 返回API调用结果(数组)或异步API调用状态(bool) |
|
||||
|
||||
|
||||
## setGroupAnonymousBan
|
||||
|
||||
```php
|
||||
public function setGroupAnonymousBan(mixed $group_id, mixed $anonymous_or_flag, int $duration): null|array|bool
|
||||
public function setGroupAnonymousBan(int|string $group_id, array|int|string $anonymous_or_flag, int $duration): array|bool
|
||||
```
|
||||
|
||||
### 描述
|
||||
@@ -280,20 +336,21 @@ public function setGroupAnonymousBan(mixed $group_id, mixed $anonymous_or_flag,
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| group_id | mixed | |
|
||||
| anonymous_or_flag | mixed | |
|
||||
| group_id | int|string | 群ID |
|
||||
| anonymous_or_flag | array|int|string | 匿名禁言Flag或匿名用户对象 |
|
||||
| duration | int | |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| null|array|bool | |
|
||||
| array|bool | 返回API调用结果(数组)或异步API调用状态(bool) |
|
||||
|
||||
|
||||
## setGroupWholeBan
|
||||
|
||||
```php
|
||||
public function setGroupWholeBan(mixed $group_id, bool $enable): null|array|bool
|
||||
public function setGroupWholeBan(int|string $group_id, bool $enable): array|bool
|
||||
```
|
||||
|
||||
### 描述
|
||||
@@ -304,19 +361,20 @@ public function setGroupWholeBan(mixed $group_id, bool $enable): null|array|bool
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| group_id | mixed | |
|
||||
| group_id | int|string | 群ID |
|
||||
| enable | bool | |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| null|array|bool | |
|
||||
| array|bool | 返回API调用结果(数组)或异步API调用状态(bool) |
|
||||
|
||||
|
||||
## setGroupAdmin
|
||||
|
||||
```php
|
||||
public function setGroupAdmin(mixed $group_id, mixed $user_id, bool $enable): null|array|bool
|
||||
public function setGroupAdmin(int|string $group_id, int|string $user_id, bool $enable): array|bool
|
||||
```
|
||||
|
||||
### 描述
|
||||
@@ -327,20 +385,21 @@ public function setGroupAdmin(mixed $group_id, mixed $user_id, bool $enable): nu
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| group_id | mixed | |
|
||||
| user_id | mixed | |
|
||||
| group_id | int|string | 群ID |
|
||||
| user_id | int|string | 用户ID |
|
||||
| enable | bool | |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| null|array|bool | |
|
||||
| array|bool | 返回API调用结果(数组)或异步API调用状态(bool) |
|
||||
|
||||
|
||||
## setGroupAnonymous
|
||||
|
||||
```php
|
||||
public function setGroupAnonymous(mixed $group_id, bool $enable): null|array|bool
|
||||
public function setGroupAnonymous(int|string $group_id, bool $enable): array|bool
|
||||
```
|
||||
|
||||
### 描述
|
||||
@@ -351,19 +410,20 @@ public function setGroupAnonymous(mixed $group_id, bool $enable): null|array|boo
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| group_id | mixed | |
|
||||
| enable | bool | |
|
||||
| group_id | int|string | 群ID |
|
||||
| enable | bool | 是否启用(默认为true) |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| null|array|bool | |
|
||||
| array|bool | 返回API调用结果(数组)或异步API调用状态(bool) |
|
||||
|
||||
|
||||
## setGroupCard
|
||||
|
||||
```php
|
||||
public function setGroupCard(mixed $group_id, mixed $user_id, string $card): null|array|bool
|
||||
public function setGroupCard(int|string $group_id, int|string $user_id, string $card): array|bool
|
||||
```
|
||||
|
||||
### 描述
|
||||
@@ -374,20 +434,21 @@ public function setGroupCard(mixed $group_id, mixed $user_id, string $card): nul
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| group_id | mixed | |
|
||||
| user_id | mixed | |
|
||||
| card | string | |
|
||||
| group_id | int|string | 群ID |
|
||||
| user_id | int|string | 用户ID |
|
||||
| card | string | 名片内容(默认为空) |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| null|array|bool | |
|
||||
| array|bool | 返回API调用结果(数组)或异步API调用状态(bool) |
|
||||
|
||||
|
||||
## setGroupName
|
||||
|
||||
```php
|
||||
public function setGroupName(mixed $group_id, mixed $group_name): null|array|bool
|
||||
public function setGroupName(int|string $group_id, string $group_name): array|bool
|
||||
```
|
||||
|
||||
### 描述
|
||||
@@ -398,19 +459,20 @@ public function setGroupName(mixed $group_id, mixed $group_name): null|array|boo
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| group_id | mixed | |
|
||||
| group_name | mixed | |
|
||||
| group_id | int|string | 群ID |
|
||||
| group_name | string | 群名 |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| null|array|bool | |
|
||||
| array|bool | 返回API调用结果(数组)或异步API调用状态(bool) |
|
||||
|
||||
|
||||
## setGroupLeave
|
||||
|
||||
```php
|
||||
public function setGroupLeave(mixed $group_id, bool $is_dismiss): null|array|bool
|
||||
public function setGroupLeave(int|string $group_id, bool $is_dismiss): array|bool
|
||||
```
|
||||
|
||||
### 描述
|
||||
@@ -421,19 +483,20 @@ public function setGroupLeave(mixed $group_id, bool $is_dismiss): null|array|boo
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| group_id | mixed | |
|
||||
| is_dismiss | bool | |
|
||||
| group_id | int|string | 群ID |
|
||||
| is_dismiss | bool | 是否解散(默认为false) |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| null|array|bool | |
|
||||
| array|bool | 返回API调用结果(数组)或异步API调用状态(bool) |
|
||||
|
||||
|
||||
## setGroupSpecialTitle
|
||||
|
||||
```php
|
||||
public function setGroupSpecialTitle(mixed $group_id, mixed $user_id, string $special_title, int $duration): null|array|bool
|
||||
public function setGroupSpecialTitle(int|string $group_id, int|string $user_id, string $special_title, int $duration): array|bool
|
||||
```
|
||||
|
||||
### 描述
|
||||
@@ -444,21 +507,22 @@ public function setGroupSpecialTitle(mixed $group_id, mixed $user_id, string $sp
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| group_id | mixed | |
|
||||
| user_id | mixed | |
|
||||
| special_title | string | |
|
||||
| duration | int | |
|
||||
| group_id | int|string | 群ID |
|
||||
| user_id | int|string | 用户ID |
|
||||
| special_title | string | 专属头衔内容 |
|
||||
| duration | int | 持续时间(默认为-1,永久) |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| null|array|bool | |
|
||||
| array|bool | 返回API调用结果(数组)或异步API调用状态(bool) |
|
||||
|
||||
|
||||
## setFriendAddRequest
|
||||
|
||||
```php
|
||||
public function setFriendAddRequest(mixed $flag, bool $approve, string $remark): null|array|bool
|
||||
public function setFriendAddRequest(array|int|string $flag, bool $approve, string $remark): array|bool
|
||||
```
|
||||
|
||||
### 描述
|
||||
@@ -469,20 +533,21 @@ public function setFriendAddRequest(mixed $flag, bool $approve, string $remark):
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| flag | mixed | |
|
||||
| approve | bool | |
|
||||
| remark | string | |
|
||||
| flag | array|int|string | 处理加好友请求的flag |
|
||||
| approve | bool | 是否同意(默认为true) |
|
||||
| remark | string | 设置昵称(默认不设置) |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| null|array|bool | |
|
||||
| array|bool | 返回API调用结果(数组)或异步API调用状态(bool) |
|
||||
|
||||
|
||||
## setGroupAddRequest
|
||||
|
||||
```php
|
||||
public function setGroupAddRequest(mixed $flag, mixed $sub_type, bool $approve, string $reason): null|array|bool
|
||||
public function setGroupAddRequest(array|int|string $flag, string $sub_type, bool $approve, string $reason): array|bool
|
||||
```
|
||||
|
||||
### 描述
|
||||
@@ -493,21 +558,22 @@ public function setGroupAddRequest(mixed $flag, mixed $sub_type, bool $approve,
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| flag | mixed | |
|
||||
| sub_type | mixed | |
|
||||
| approve | bool | |
|
||||
| reason | string | |
|
||||
| flag | array|int|string | 处理加群请求的flag |
|
||||
| sub_type | string | 处理请求类型(包含add和invite) |
|
||||
| approve | bool | 是否同意(默认为true) |
|
||||
| reason | string | 拒绝理由(仅在拒绝时有效,默认为空) |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| null|array|bool | |
|
||||
| array|bool | 返回API调用结果(数组)或异步API调用状态(bool) |
|
||||
|
||||
|
||||
## getLoginInfo
|
||||
|
||||
```php
|
||||
public function getLoginInfo(): null|array|bool
|
||||
public function getLoginInfo(): array|bool
|
||||
```
|
||||
|
||||
### 描述
|
||||
@@ -518,13 +584,13 @@ public function getLoginInfo(): null|array|bool
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| null|array|bool | |
|
||||
| array|bool | 返回API调用结果(数组)或异步API调用状态(bool) |
|
||||
|
||||
|
||||
## getStrangerInfo
|
||||
|
||||
```php
|
||||
public function getStrangerInfo(mixed $user_id, bool $no_cache): null|array|bool
|
||||
public function getStrangerInfo(int|string $user_id, bool $no_cache): array|bool
|
||||
```
|
||||
|
||||
### 描述
|
||||
@@ -535,19 +601,20 @@ public function getStrangerInfo(mixed $user_id, bool $no_cache): null|array|bool
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| user_id | mixed | |
|
||||
| no_cache | bool | |
|
||||
| user_id | int|string | 用户ID |
|
||||
| no_cache | bool | 是否不使用缓存(默认为false) |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| null|array|bool | |
|
||||
| array|bool | 返回API调用结果(数组)或异步API调用状态(bool) |
|
||||
|
||||
|
||||
## getFriendList
|
||||
|
||||
```php
|
||||
public function getFriendList(): null|array|bool
|
||||
public function getFriendList(): array|bool
|
||||
```
|
||||
|
||||
### 描述
|
||||
@@ -558,13 +625,13 @@ public function getFriendList(): null|array|bool
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| null|array|bool | |
|
||||
| array|bool | 返回API调用结果(数组)或异步API调用状态(bool) |
|
||||
|
||||
|
||||
## getGroupInfo
|
||||
|
||||
```php
|
||||
public function getGroupInfo(mixed $group_id, bool $no_cache): null|array|bool
|
||||
public function getGroupInfo(int|string $group_id, bool $no_cache): array|bool
|
||||
```
|
||||
|
||||
### 描述
|
||||
@@ -575,19 +642,20 @@ public function getGroupInfo(mixed $group_id, bool $no_cache): null|array|bool
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| group_id | mixed | |
|
||||
| group_id | int|string | 群ID |
|
||||
| no_cache | bool | |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| null|array|bool | |
|
||||
| array|bool | 返回API调用结果(数组)或异步API调用状态(bool) |
|
||||
|
||||
|
||||
## getGroupList
|
||||
|
||||
```php
|
||||
public function getGroupList(): null|array|bool
|
||||
public function getGroupList(): array|bool
|
||||
```
|
||||
|
||||
### 描述
|
||||
@@ -598,13 +666,13 @@ public function getGroupList(): null|array|bool
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| null|array|bool | |
|
||||
| array|bool | 返回API调用结果(数组)或异步API调用状态(bool) |
|
||||
|
||||
|
||||
## getGroupMemberInfo
|
||||
|
||||
```php
|
||||
public function getGroupMemberInfo(mixed $group_id, mixed $user_id, bool $no_cache): null|array|bool
|
||||
public function getGroupMemberInfo(int|string $group_id, int|string $user_id, bool $no_cache): array|bool
|
||||
```
|
||||
|
||||
### 描述
|
||||
@@ -615,20 +683,21 @@ public function getGroupMemberInfo(mixed $group_id, mixed $user_id, bool $no_cac
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| group_id | mixed | |
|
||||
| user_id | mixed | |
|
||||
| group_id | int|string | 群ID |
|
||||
| user_id | int|string | 用户ID |
|
||||
| no_cache | bool | |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| null|array|bool | |
|
||||
| array|bool | 返回API调用结果(数组)或异步API调用状态(bool) |
|
||||
|
||||
|
||||
## getGroupMemberList
|
||||
|
||||
```php
|
||||
public function getGroupMemberList(mixed $group_id): null|array|bool
|
||||
public function getGroupMemberList(int|string $group_id): array|bool
|
||||
```
|
||||
|
||||
### 描述
|
||||
@@ -639,18 +708,19 @@ public function getGroupMemberList(mixed $group_id): null|array|bool
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| group_id | mixed | |
|
||||
| group_id | int|string | 群ID |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| null|array|bool | |
|
||||
| array|bool | 返回API调用结果(数组)或异步API调用状态(bool) |
|
||||
|
||||
|
||||
## getGroupHonorInfo
|
||||
|
||||
```php
|
||||
public function getGroupHonorInfo(mixed $group_id, mixed $type): null|array|bool
|
||||
public function getGroupHonorInfo(int|string $group_id, string $type): array|bool
|
||||
```
|
||||
|
||||
### 描述
|
||||
@@ -661,19 +731,20 @@ public function getGroupHonorInfo(mixed $group_id, mixed $type): null|array|bool
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| group_id | mixed | |
|
||||
| type | mixed | |
|
||||
| group_id | int|string | 群ID |
|
||||
| type | string | 荣誉类型 |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| null|array|bool | |
|
||||
| array|bool | 返回API调用结果(数组)或异步API调用状态(bool) |
|
||||
|
||||
|
||||
## getCsrfToken
|
||||
|
||||
```php
|
||||
public function getCsrfToken(): null|array|bool
|
||||
public function getCsrfToken(): array|bool
|
||||
```
|
||||
|
||||
### 描述
|
||||
@@ -684,13 +755,13 @@ public function getCsrfToken(): null|array|bool
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| null|array|bool | |
|
||||
| array|bool | 返回API调用结果(数组)或异步API调用状态(bool) |
|
||||
|
||||
|
||||
## getCredentials
|
||||
|
||||
```php
|
||||
public function getCredentials(string $domain): null|array|bool
|
||||
public function getCredentials(string $domain): array|bool
|
||||
```
|
||||
|
||||
### 描述
|
||||
@@ -702,17 +773,18 @@ public function getCredentials(string $domain): null|array|bool
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| domain | string | |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| null|array|bool | |
|
||||
| array|bool | 返回API调用结果(数组)或异步API调用状态(bool) |
|
||||
|
||||
|
||||
## getRecord
|
||||
|
||||
```php
|
||||
public function getRecord(mixed $file, mixed $out_format): null|array|bool
|
||||
public function getRecord(string $file, string $out_format): array|bool
|
||||
```
|
||||
|
||||
### 描述
|
||||
@@ -723,19 +795,20 @@ public function getRecord(mixed $file, mixed $out_format): null|array|bool
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| file | mixed | |
|
||||
| out_format | mixed | |
|
||||
| file | string | 文件 |
|
||||
| out_format | string | 输出格式 |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| null|array|bool | |
|
||||
| array|bool | 返回API调用结果(数组)或异步API调用状态(bool) |
|
||||
|
||||
|
||||
## getImage
|
||||
|
||||
```php
|
||||
public function getImage(mixed $file): null|array|bool
|
||||
public function getImage(string $file): array|bool
|
||||
```
|
||||
|
||||
### 描述
|
||||
@@ -746,18 +819,19 @@ public function getImage(mixed $file): null|array|bool
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| file | mixed | |
|
||||
| file | string | 文件 |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| null|array|bool | |
|
||||
| array|bool | 返回API调用结果(数组)或异步API调用状态(bool) |
|
||||
|
||||
|
||||
## canSendImage
|
||||
|
||||
```php
|
||||
public function canSendImage(): null|array|bool
|
||||
public function canSendImage(): array|bool
|
||||
```
|
||||
|
||||
### 描述
|
||||
@@ -768,13 +842,13 @@ public function canSendImage(): null|array|bool
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| null|array|bool | |
|
||||
| array|bool | 返回API调用结果(数组)或异步API调用状态(bool) |
|
||||
|
||||
|
||||
## canSendRecord
|
||||
|
||||
```php
|
||||
public function canSendRecord(): null|array|bool
|
||||
public function canSendRecord(): array|bool
|
||||
```
|
||||
|
||||
### 描述
|
||||
@@ -785,13 +859,13 @@ public function canSendRecord(): null|array|bool
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| null|array|bool | |
|
||||
| array|bool | 返回API调用结果(数组)或异步API调用状态(bool) |
|
||||
|
||||
|
||||
## getStatus
|
||||
|
||||
```php
|
||||
public function getStatus(): null|array|bool
|
||||
public function getStatus(): array|bool
|
||||
```
|
||||
|
||||
### 描述
|
||||
@@ -802,13 +876,13 @@ public function getStatus(): null|array|bool
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| null|array|bool | |
|
||||
| array|bool | 返回API调用结果(数组)或异步API调用状态(bool) |
|
||||
|
||||
|
||||
## getVersionInfo
|
||||
|
||||
```php
|
||||
public function getVersionInfo(): null|array|bool
|
||||
public function getVersionInfo(): array|bool
|
||||
```
|
||||
|
||||
### 描述
|
||||
@@ -819,13 +893,13 @@ public function getVersionInfo(): null|array|bool
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| null|array|bool | |
|
||||
| array|bool | 返回API调用结果(数组)或异步API调用状态(bool) |
|
||||
|
||||
|
||||
## setRestart
|
||||
|
||||
```php
|
||||
public function setRestart(int $delay): null|array|bool
|
||||
public function setRestart(int $delay): array|bool
|
||||
```
|
||||
|
||||
### 描述
|
||||
@@ -836,18 +910,19 @@ public function setRestart(int $delay): null|array|bool
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| delay | int | |
|
||||
| delay | int | 延迟时间(毫秒,默认为0) |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| null|array|bool | |
|
||||
| array|bool | 返回API调用结果(数组)或异步API调用状态(bool) |
|
||||
|
||||
|
||||
## cleanCache
|
||||
|
||||
```php
|
||||
public function cleanCache(): null|array|bool
|
||||
public function cleanCache(): array|bool
|
||||
```
|
||||
|
||||
### 描述
|
||||
@@ -858,7 +933,7 @@ public function cleanCache(): null|array|bool
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| null|array|bool | |
|
||||
| array|bool | 返回API调用结果(数组)或异步API调用状态(bool) |
|
||||
|
||||
|
||||
## getExtendedAPI
|
||||
@@ -877,17 +952,18 @@ public function getExtendedAPI(string $package_name): mixed
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| package_name | string | |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| mixed | |
|
||||
| mixed | 返回包的操作对象 |
|
||||
|
||||
|
||||
## processAPI
|
||||
## callExtendedAPI
|
||||
|
||||
```php
|
||||
public function processAPI(mixed $connection, mixed $reply, |null $function): array|bool
|
||||
public function callExtendedAPI(string $action, array $params): array|bool
|
||||
```
|
||||
|
||||
### 描述
|
||||
@@ -898,35 +974,11 @@ public function processAPI(mixed $connection, mixed $reply, |null $function): ar
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| connection | mixed | |
|
||||
| reply | mixed | |
|
||||
| function | |null | |
|
||||
| action | string | 动作(API)名称 |
|
||||
| params | array | 参数 |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| array|bool | |
|
||||
|
||||
|
||||
## processHttpAPI
|
||||
|
||||
```php
|
||||
public function processHttpAPI(mixed $connection, mixed $reply, null $function): bool
|
||||
```
|
||||
|
||||
### 描述
|
||||
|
||||
作者很懒,什么也没有说
|
||||
|
||||
### 参数
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| connection | mixed | |
|
||||
| reply | mixed | |
|
||||
| function | null | |
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| bool | |
|
||||
| array|bool | 返回API调用结果(数组)或异步API调用状态(bool) |
|
||||
|
||||
117
docs/api/ZM/API/Proxies/Bot/AbstractBotProxy.md
Normal file
117
docs/api/ZM/API/Proxies/Bot/AbstractBotProxy.md
Normal 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 | |
|
||||
24
docs/api/ZM/API/Proxies/Bot/AllBotsProxy.md
Normal file
24
docs/api/ZM/API/Proxies/Bot/AllBotsProxy.md
Normal 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 |
|
||||
24
docs/api/ZM/API/Proxies/Bot/AllGroupsProxy.md
Normal file
24
docs/api/ZM/API/Proxies/Bot/AllGroupsProxy.md
Normal 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> | 返回一个包含所有执行结果的数组,键名为群号 |
|
||||
@@ -3,7 +3,7 @@
|
||||
## getTuringMsg
|
||||
|
||||
```php
|
||||
public function getTuringMsg(mixed $msg, mixed $user_id, mixed $api): string
|
||||
public function getTuringMsg(string $msg, int|string $user_id, string $api): string
|
||||
```
|
||||
|
||||
### 描述
|
||||
@@ -14,11 +14,35 @@ public function getTuringMsg(mixed $msg, mixed $user_id, mixed $api): string
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| msg | mixed | |
|
||||
| user_id | mixed | |
|
||||
| api | mixed | |
|
||||
| msg | string | 消息 |
|
||||
| user_id | int|string | 用户ID |
|
||||
| api | string | API Key |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| string | |
|
||||
| string | 图灵的回复 |
|
||||
|
||||
|
||||
## getResultStatus
|
||||
|
||||
```php
|
||||
public function getResultStatus(array $r): bool|string
|
||||
```
|
||||
|
||||
### 描述
|
||||
|
||||
作者很懒,什么也没有说
|
||||
|
||||
### 参数
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| r | array | 数据API回包 |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| bool|string | 错误消息或成功鸥鸟 |
|
||||
|
||||
@@ -1 +1,46 @@
|
||||
# ZM\API\ZMRobot
|
||||
# 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 | |
|
||||
|
||||
@@ -37,7 +37,7 @@ public function registerMods(): mixed
|
||||
## addRegisterPath
|
||||
|
||||
```php
|
||||
public function addRegisterPath(mixed $path, mixed $indoor_name): mixed
|
||||
public function addRegisterPath(string $path, string $indoor_name): mixed
|
||||
```
|
||||
|
||||
### 描述
|
||||
@@ -48,8 +48,9 @@ public function addRegisterPath(mixed $path, mixed $indoor_name): mixed
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| path | mixed | |
|
||||
| indoor_name | mixed | |
|
||||
| path | string | 注册解析注解的路径 |
|
||||
| indoor_name | string | 起始命名空间的名称 |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
@@ -60,7 +61,7 @@ public function addRegisterPath(mixed $path, mixed $indoor_name): mixed
|
||||
## sortByLevel
|
||||
|
||||
```php
|
||||
public function sortByLevel(mixed $events, string $class_name, string $prefix): mixed
|
||||
public function sortByLevel(array $events, string $class_name, string $prefix): mixed
|
||||
```
|
||||
|
||||
### 描述
|
||||
@@ -71,9 +72,10 @@ public function sortByLevel(mixed $events, string $class_name, string $prefix):
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| events | mixed | |
|
||||
| class_name | string | |
|
||||
| prefix | string | |
|
||||
| events | array | 需要排序的 |
|
||||
| class_name | string | 排序的类名 |
|
||||
| prefix | string | 前缀 |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
|
||||
@@ -15,6 +15,7 @@ public function setLevel(int $level): mixed
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| level | int | |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
|
||||
@@ -17,6 +17,7 @@ public function check(mixed $remote, mixed $local, Symfony\Component\Console\Out
|
||||
| remote | mixed | |
|
||||
| local | mixed | |
|
||||
| out | Symfony\Component\Console\Output\OutputInterface | |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
|
||||
@@ -1 +1,24 @@
|
||||
# ZM\Command\Module\ModuleListCommand
|
||||
# ZM\Command\Module\ModuleListCommand
|
||||
|
||||
## execute
|
||||
|
||||
```php
|
||||
public function execute(Symfony\Component\Console\Input\InputInterface $input, Symfony\Component\Console\Output\OutputInterface $output): int
|
||||
```
|
||||
|
||||
### 描述
|
||||
|
||||
作者很懒,什么也没有说
|
||||
|
||||
### 参数
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| input | Symfony\Component\Console\Input\InputInterface | |
|
||||
| output | Symfony\Component\Console\Output\OutputInterface | |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| int | |
|
||||
|
||||
@@ -1 +1,24 @@
|
||||
# ZM\Command\Module\ModulePackCommand
|
||||
# ZM\Command\Module\ModulePackCommand
|
||||
|
||||
## execute
|
||||
|
||||
```php
|
||||
public function execute(Symfony\Component\Console\Input\InputInterface $input, Symfony\Component\Console\Output\OutputInterface $output): int
|
||||
```
|
||||
|
||||
### 描述
|
||||
|
||||
作者很懒,什么也没有说
|
||||
|
||||
### 参数
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| input | Symfony\Component\Console\Input\InputInterface | |
|
||||
| output | Symfony\Component\Console\Output\OutputInterface | |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| int | |
|
||||
|
||||
@@ -15,6 +15,7 @@ public function __construct(string $name): mixed
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| name | string | |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
@@ -37,6 +38,7 @@ public function initEnv(string $with_default_cmd): ZM\ConsoleApplication
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| with_default_cmd | string | |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
|
||||
77
docs/api/ZM/Container/BoundMethod.md
Normal file
77
docs/api/ZM/Container/BoundMethod.md
Normal file
@@ -0,0 +1,77 @@
|
||||
# ZM\Container\BoundMethod
|
||||
|
||||
## call
|
||||
|
||||
```php
|
||||
public function call(Container $container, callable|string $callback, array $parameters, string $default_method): mixed
|
||||
```
|
||||
|
||||
### 描述
|
||||
|
||||
调用指定闭包、类方法并注入依赖
|
||||
|
||||
### 参数
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| container | Container | |
|
||||
| callback | callable|string | |
|
||||
| parameters | array | |
|
||||
| default_method | string | |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| mixed | |
|
||||
|
||||
|
||||
## getMethodDependencies
|
||||
|
||||
```php
|
||||
public function getMethodDependencies(callable|string $callback, ZM\Container\ContainerInterface $container, array $parameters): array
|
||||
```
|
||||
|
||||
### 描述
|
||||
|
||||
Get all dependencies for a given method.
|
||||
|
||||
### 参数
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| callback | callable|string | |
|
||||
| container | ZM\Container\ContainerInterface | |
|
||||
| parameters | array | |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| array | |
|
||||
|
||||
|
||||
## addDependencyForCallParameter
|
||||
|
||||
```php
|
||||
public function addDependencyForCallParameter(ZM\Container\ContainerInterface $container, ReflectionParameter $parameter, array $parameters, array $dependencies): void
|
||||
```
|
||||
|
||||
### 描述
|
||||
|
||||
Get the dependency for the given call parameter.
|
||||
|
||||
### 参数
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| container | ZM\Container\ContainerInterface | |
|
||||
| parameter | ReflectionParameter | |
|
||||
| parameters | array | |
|
||||
| dependencies | array | |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| void | |
|
||||
882
docs/api/ZM/Container/Container.md
Normal file
882
docs/api/ZM/Container/Container.md
Normal file
@@ -0,0 +1,882 @@
|
||||
# ZM\Container\Container
|
||||
|
||||
## getParent
|
||||
|
||||
```php
|
||||
public function getParent(): ZM\Container\ContainerInterface
|
||||
```
|
||||
|
||||
### 描述
|
||||
|
||||
获取父容器
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| ZM\Container\ContainerInterface | |
|
||||
|
||||
|
||||
## has
|
||||
|
||||
```php
|
||||
public function has(string $id): bool
|
||||
```
|
||||
|
||||
### 描述
|
||||
|
||||
Returns true if the container can return an entry for the given identifier.
|
||||
Returns false otherwise.
|
||||
`has($id)` returning true does not mean that `get($id)` will not throw an exception.
|
||||
It does however mean that `get($id)` will not throw a `NotFoundExceptionInterface`.
|
||||
|
||||
### 参数
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| id | string | identifier of the entry to look for |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| bool | |
|
||||
|
||||
|
||||
## make
|
||||
|
||||
```php
|
||||
public function make(class-string<T> $abstract, array $parameters): Closure|mixed|T
|
||||
```
|
||||
|
||||
### 描述
|
||||
|
||||
获取一个绑定的实例
|
||||
|
||||
### 参数
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| abstract | class-string<T> | 类或接口名 |
|
||||
| parameters | array | 参数 |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| Closure|mixed|T | 实例 |
|
||||
|
||||
|
||||
## getInstance
|
||||
|
||||
```php
|
||||
public function getInstance(): static
|
||||
```
|
||||
|
||||
### 描述
|
||||
|
||||
获取类实例
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| static | |
|
||||
|
||||
|
||||
## bound
|
||||
|
||||
```php
|
||||
public function bound(string $abstract): bool
|
||||
```
|
||||
|
||||
### 描述
|
||||
|
||||
判断对应的类或接口是否已经注册
|
||||
|
||||
### 参数
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| abstract | string | 类或接口名 |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| bool | |
|
||||
|
||||
|
||||
## getAlias
|
||||
|
||||
```php
|
||||
public function getAlias(string $abstract): string
|
||||
```
|
||||
|
||||
### 描述
|
||||
|
||||
获取类别名(如存在)
|
||||
|
||||
### 参数
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| abstract | string | 类或接口名 |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| string | 别名,不存在时返回传入的类或接口名 |
|
||||
|
||||
|
||||
## alias
|
||||
|
||||
```php
|
||||
public function alias(string $abstract, string $alias): void
|
||||
```
|
||||
|
||||
### 描述
|
||||
|
||||
注册一个类别名
|
||||
|
||||
### 参数
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| abstract | string | 类或接口名 |
|
||||
| alias | string | 别名 |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| void | |
|
||||
|
||||
|
||||
## bind
|
||||
|
||||
```php
|
||||
public function bind(string $abstract, null|Closure|string $concrete, bool $shared): void
|
||||
```
|
||||
|
||||
### 描述
|
||||
|
||||
注册绑定
|
||||
|
||||
### 参数
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| abstract | string | 类或接口名 |
|
||||
| concrete | null|Closure|string | 返回类实例的闭包,或是类名 |
|
||||
| shared | bool | 是否共享 |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| void | |
|
||||
|
||||
|
||||
## bindIf
|
||||
|
||||
```php
|
||||
public function bindIf(string $abstract, null|Closure|string $concrete, bool $shared): void
|
||||
```
|
||||
|
||||
### 描述
|
||||
|
||||
注册绑定
|
||||
在已经绑定时不会重复注册
|
||||
|
||||
### 参数
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| abstract | string | 类或接口名 |
|
||||
| concrete | null|Closure|string | 返回类实例的闭包,或是类名 |
|
||||
| shared | bool | 是否共享 |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| void | |
|
||||
|
||||
|
||||
## singleton
|
||||
|
||||
```php
|
||||
public function singleton(string $abstract, null|Closure|string $concrete): void
|
||||
```
|
||||
|
||||
### 描述
|
||||
|
||||
注册一个单例绑定
|
||||
|
||||
### 参数
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| abstract | string | 类或接口名 |
|
||||
| concrete | null|Closure|string | 返回类实例的闭包,或是类名 |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| void | |
|
||||
|
||||
|
||||
## singletonIf
|
||||
|
||||
```php
|
||||
public function singletonIf(string $abstract, null|Closure|string $concrete): void
|
||||
```
|
||||
|
||||
### 描述
|
||||
|
||||
注册一个单例绑定
|
||||
在已经绑定时不会重复注册
|
||||
|
||||
### 参数
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| abstract | string | 类或接口名 |
|
||||
| concrete | null|Closure|string | 返回类实例的闭包,或是类名 |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| void | |
|
||||
|
||||
|
||||
## instance
|
||||
|
||||
```php
|
||||
public function instance(string $abstract, mixed $instance): mixed
|
||||
```
|
||||
|
||||
### 描述
|
||||
|
||||
注册一个已有的实例,效果等同于单例绑定
|
||||
|
||||
### 参数
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| abstract | string | 类或接口名 |
|
||||
| instance | mixed | 实例 |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| mixed | |
|
||||
|
||||
|
||||
## factory
|
||||
|
||||
```php
|
||||
public function factory(string $abstract): Closure
|
||||
```
|
||||
|
||||
### 描述
|
||||
|
||||
获取一个解析对应类实例的闭包
|
||||
|
||||
### 参数
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| abstract | string | 类或接口名 |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| Closure | |
|
||||
|
||||
|
||||
## flush
|
||||
|
||||
```php
|
||||
public function flush(): void
|
||||
```
|
||||
|
||||
### 描述
|
||||
|
||||
清除所有绑定和实例
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| void | |
|
||||
|
||||
|
||||
## traitMake
|
||||
|
||||
```php
|
||||
public function traitMake(class-string<T> $abstract, array $parameters): Closure|mixed|T
|
||||
```
|
||||
|
||||
### 描述
|
||||
|
||||
获取一个绑定的实例
|
||||
|
||||
### 参数
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| abstract | class-string<T> | 类或接口名 |
|
||||
| parameters | array | 参数 |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| Closure|mixed|T | 实例 |
|
||||
|
||||
|
||||
## build
|
||||
|
||||
```php
|
||||
public function build(Closure|string $concrete): mixed
|
||||
```
|
||||
|
||||
### 描述
|
||||
|
||||
实例化具体的类实例
|
||||
|
||||
### 参数
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| concrete | Closure|string | 类名或对应的闭包 |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| mixed | |
|
||||
|
||||
|
||||
## call
|
||||
|
||||
```php
|
||||
public function call(callable|string $callback, array $parameters, null|string $default_method): mixed
|
||||
```
|
||||
|
||||
### 描述
|
||||
|
||||
调用对应的方法,并自动注入依赖
|
||||
|
||||
### 参数
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| callback | callable|string | 对应的方法 |
|
||||
| parameters | array | 参数 |
|
||||
| default_method | null|string | 默认方法 |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| mixed | |
|
||||
|
||||
|
||||
## get
|
||||
|
||||
```php
|
||||
public function get(string $id): mixed
|
||||
```
|
||||
|
||||
### 描述
|
||||
|
||||
Finds an entry of the container by its identifier and returns it.
|
||||
|
||||
### 参数
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| id | string | identifier of the entry to look for * |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| mixed | entry |
|
||||
|
||||
|
||||
## extend
|
||||
|
||||
```php
|
||||
public function extend(string $abstract, Closure $closure): void
|
||||
```
|
||||
|
||||
### 描述
|
||||
|
||||
扩展一个类或接口
|
||||
|
||||
### 参数
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| abstract | string | 类或接口名 |
|
||||
| closure | Closure | 扩展闭包 |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| void | |
|
||||
|
||||
|
||||
## getLogPrefix
|
||||
|
||||
```php
|
||||
public function getLogPrefix(): string
|
||||
```
|
||||
|
||||
### 描述
|
||||
|
||||
获取日志前缀
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| string | |
|
||||
|
||||
|
||||
## setLogPrefix
|
||||
|
||||
```php
|
||||
public function setLogPrefix(string $prefix): void
|
||||
```
|
||||
|
||||
### 描述
|
||||
|
||||
设置日志前缀
|
||||
|
||||
### 参数
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| prefix | string | |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| void | |
|
||||
|
||||
|
||||
## getExtenders
|
||||
|
||||
```php
|
||||
public function getExtenders(string $abstract): Closure[]
|
||||
```
|
||||
|
||||
### 描述
|
||||
|
||||
获取对应类型的所有扩展器
|
||||
|
||||
### 参数
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| abstract | string | 类或接口名 |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| Closure[] | |
|
||||
|
||||
|
||||
## isAlias
|
||||
|
||||
```php
|
||||
public function isAlias(string $name): bool
|
||||
```
|
||||
|
||||
### 描述
|
||||
|
||||
判断传入的是否为别名
|
||||
|
||||
### 参数
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| name | string | |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| bool | |
|
||||
|
||||
|
||||
## dropStaleInstances
|
||||
|
||||
```php
|
||||
public function dropStaleInstances(string $abstract): void
|
||||
```
|
||||
|
||||
### 描述
|
||||
|
||||
抛弃所有过时的实例和别名
|
||||
|
||||
### 参数
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| abstract | string | 类或接口名 |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| void | |
|
||||
|
||||
|
||||
## getClosure
|
||||
|
||||
```php
|
||||
public function getClosure(string $abstract, string $concrete): Closure
|
||||
```
|
||||
|
||||
### 描述
|
||||
|
||||
获取一个解析对应类的闭包
|
||||
|
||||
### 参数
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| abstract | string | 类或接口名 |
|
||||
| concrete | string | 实际类名 |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| Closure | |
|
||||
|
||||
|
||||
## getLastParameterOverride
|
||||
|
||||
```php
|
||||
public function getLastParameterOverride(): array
|
||||
```
|
||||
|
||||
### 描述
|
||||
|
||||
获取最后一次的覆盖参数
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| array | |
|
||||
|
||||
|
||||
## notInstantiable
|
||||
|
||||
```php
|
||||
public function notInstantiable(string $concrete, string $reason): void
|
||||
```
|
||||
|
||||
### 描述
|
||||
|
||||
抛出实例化异常
|
||||
|
||||
### 参数
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| concrete | string | |
|
||||
| reason | string | |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| void | |
|
||||
|
||||
|
||||
## resolveDependencies
|
||||
|
||||
```php
|
||||
public function resolveDependencies(ReflectionParameter[] $dependencies): array
|
||||
```
|
||||
|
||||
### 描述
|
||||
|
||||
解析依赖
|
||||
|
||||
### 参数
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| dependencies | ReflectionParameter[] | |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| array | |
|
||||
|
||||
|
||||
## hasParameterOverride
|
||||
|
||||
```php
|
||||
public function hasParameterOverride(ReflectionParameter $parameter): bool
|
||||
```
|
||||
|
||||
### 描述
|
||||
|
||||
判断传入的参数是否存在覆盖参数
|
||||
|
||||
### 参数
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| parameter | ReflectionParameter | |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| bool | |
|
||||
|
||||
|
||||
## getParameterOverride
|
||||
|
||||
```php
|
||||
public function getParameterOverride(ReflectionParameter $parameter): mixed
|
||||
```
|
||||
|
||||
### 描述
|
||||
|
||||
获取覆盖参数
|
||||
|
||||
### 参数
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| parameter | ReflectionParameter | |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| mixed | |
|
||||
|
||||
|
||||
## hasParameterTypeOverride
|
||||
|
||||
```php
|
||||
public function hasParameterTypeOverride(ReflectionParameter $parameter): bool
|
||||
```
|
||||
|
||||
### 描述
|
||||
|
||||
判断传入的参数是否存在临时注入的参数
|
||||
|
||||
### 参数
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| parameter | ReflectionParameter | |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| bool | |
|
||||
|
||||
|
||||
## getParameterTypeOverride
|
||||
|
||||
```php
|
||||
public function getParameterTypeOverride(ReflectionParameter $parameter): mixed
|
||||
```
|
||||
|
||||
### 描述
|
||||
|
||||
获取临时注入的参数
|
||||
|
||||
### 参数
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| parameter | ReflectionParameter | |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| mixed | |
|
||||
|
||||
|
||||
## resolvePrimitive
|
||||
|
||||
```php
|
||||
public function resolvePrimitive(ReflectionParameter $parameter): mixed
|
||||
```
|
||||
|
||||
### 描述
|
||||
|
||||
解析基本类型
|
||||
|
||||
### 参数
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| parameter | ReflectionParameter | |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| mixed | 对应类型的默认值 |
|
||||
|
||||
|
||||
## resolveClass
|
||||
|
||||
```php
|
||||
public function resolveClass(ReflectionParameter $parameter): mixed
|
||||
```
|
||||
|
||||
### 描述
|
||||
|
||||
解析类
|
||||
|
||||
### 参数
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| parameter | ReflectionParameter | |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| mixed | |
|
||||
|
||||
|
||||
## getConcrete
|
||||
|
||||
```php
|
||||
public function getConcrete(string $abstract): Closure|string
|
||||
```
|
||||
|
||||
### 描述
|
||||
|
||||
获取类名的实际类型
|
||||
|
||||
### 参数
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| abstract | string | 类或接口名 |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| Closure|string | |
|
||||
|
||||
|
||||
## isBuildable
|
||||
|
||||
```php
|
||||
public function isBuildable(mixed $concrete, string $abstract): bool
|
||||
```
|
||||
|
||||
### 描述
|
||||
|
||||
判断传入的实际类型是否可以构造
|
||||
|
||||
### 参数
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| concrete | mixed | 实际类型 |
|
||||
| abstract | string | 类或接口名 |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| bool | |
|
||||
|
||||
|
||||
## isShared
|
||||
|
||||
```php
|
||||
public function isShared(string $abstract): bool
|
||||
```
|
||||
|
||||
### 描述
|
||||
|
||||
判断传入的类型是否为共享实例
|
||||
|
||||
### 参数
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| abstract | string | 类或接口名 |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| bool | |
|
||||
|
||||
|
||||
## shouldLog
|
||||
|
||||
```php
|
||||
public function shouldLog(): bool
|
||||
```
|
||||
|
||||
### 描述
|
||||
|
||||
判断是否输出日志
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| bool | |
|
||||
|
||||
|
||||
## log
|
||||
|
||||
```php
|
||||
public function log(string $message): void
|
||||
```
|
||||
|
||||
### 描述
|
||||
|
||||
记录日志(自动附加容器日志前缀)
|
||||
|
||||
### 参数
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| message | string | |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| void | |
|
||||
841
docs/api/ZM/Container/WorkerContainer.md
Normal file
841
docs/api/ZM/Container/WorkerContainer.md
Normal file
@@ -0,0 +1,841 @@
|
||||
# ZM\Container\WorkerContainer
|
||||
|
||||
## getInstance
|
||||
|
||||
```php
|
||||
public function getInstance(): static
|
||||
```
|
||||
|
||||
### 描述
|
||||
|
||||
获取类实例
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| static | |
|
||||
|
||||
|
||||
## bound
|
||||
|
||||
```php
|
||||
public function bound(string $abstract): bool
|
||||
```
|
||||
|
||||
### 描述
|
||||
|
||||
判断对应的类或接口是否已经注册
|
||||
|
||||
### 参数
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| abstract | string | 类或接口名 |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| bool | |
|
||||
|
||||
|
||||
## getAlias
|
||||
|
||||
```php
|
||||
public function getAlias(string $abstract): string
|
||||
```
|
||||
|
||||
### 描述
|
||||
|
||||
获取类别名(如存在)
|
||||
|
||||
### 参数
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| abstract | string | 类或接口名 |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| string | 别名,不存在时返回传入的类或接口名 |
|
||||
|
||||
|
||||
## alias
|
||||
|
||||
```php
|
||||
public function alias(string $abstract, string $alias): void
|
||||
```
|
||||
|
||||
### 描述
|
||||
|
||||
注册一个类别名
|
||||
|
||||
### 参数
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| abstract | string | 类或接口名 |
|
||||
| alias | string | 别名 |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| void | |
|
||||
|
||||
|
||||
## bind
|
||||
|
||||
```php
|
||||
public function bind(string $abstract, null|Closure|string $concrete, bool $shared): void
|
||||
```
|
||||
|
||||
### 描述
|
||||
|
||||
注册绑定
|
||||
|
||||
### 参数
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| abstract | string | 类或接口名 |
|
||||
| concrete | null|Closure|string | 返回类实例的闭包,或是类名 |
|
||||
| shared | bool | 是否共享 |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| void | |
|
||||
|
||||
|
||||
## bindIf
|
||||
|
||||
```php
|
||||
public function bindIf(string $abstract, null|Closure|string $concrete, bool $shared): void
|
||||
```
|
||||
|
||||
### 描述
|
||||
|
||||
注册绑定
|
||||
在已经绑定时不会重复注册
|
||||
|
||||
### 参数
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| abstract | string | 类或接口名 |
|
||||
| concrete | null|Closure|string | 返回类实例的闭包,或是类名 |
|
||||
| shared | bool | 是否共享 |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| void | |
|
||||
|
||||
|
||||
## singleton
|
||||
|
||||
```php
|
||||
public function singleton(string $abstract, null|Closure|string $concrete): void
|
||||
```
|
||||
|
||||
### 描述
|
||||
|
||||
注册一个单例绑定
|
||||
|
||||
### 参数
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| abstract | string | 类或接口名 |
|
||||
| concrete | null|Closure|string | 返回类实例的闭包,或是类名 |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| void | |
|
||||
|
||||
|
||||
## singletonIf
|
||||
|
||||
```php
|
||||
public function singletonIf(string $abstract, null|Closure|string $concrete): void
|
||||
```
|
||||
|
||||
### 描述
|
||||
|
||||
注册一个单例绑定
|
||||
在已经绑定时不会重复注册
|
||||
|
||||
### 参数
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| abstract | string | 类或接口名 |
|
||||
| concrete | null|Closure|string | 返回类实例的闭包,或是类名 |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| void | |
|
||||
|
||||
|
||||
## instance
|
||||
|
||||
```php
|
||||
public function instance(string $abstract, mixed $instance): mixed
|
||||
```
|
||||
|
||||
### 描述
|
||||
|
||||
注册一个已有的实例,效果等同于单例绑定
|
||||
|
||||
### 参数
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| abstract | string | 类或接口名 |
|
||||
| instance | mixed | 实例 |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| mixed | |
|
||||
|
||||
|
||||
## factory
|
||||
|
||||
```php
|
||||
public function factory(string $abstract): Closure
|
||||
```
|
||||
|
||||
### 描述
|
||||
|
||||
获取一个解析对应类实例的闭包
|
||||
|
||||
### 参数
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| abstract | string | 类或接口名 |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| Closure | |
|
||||
|
||||
|
||||
## flush
|
||||
|
||||
```php
|
||||
public function flush(): void
|
||||
```
|
||||
|
||||
### 描述
|
||||
|
||||
清除所有绑定和实例
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| void | |
|
||||
|
||||
|
||||
## make
|
||||
|
||||
```php
|
||||
public function make(class-string<T> $abstract, array $parameters): Closure|mixed|T
|
||||
```
|
||||
|
||||
### 描述
|
||||
|
||||
获取一个绑定的实例
|
||||
|
||||
### 参数
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| abstract | class-string<T> | 类或接口名 |
|
||||
| parameters | array | 参数 |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| Closure|mixed|T | 实例 |
|
||||
|
||||
|
||||
## build
|
||||
|
||||
```php
|
||||
public function build(Closure|string $concrete): mixed
|
||||
```
|
||||
|
||||
### 描述
|
||||
|
||||
实例化具体的类实例
|
||||
|
||||
### 参数
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| concrete | Closure|string | 类名或对应的闭包 |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| mixed | |
|
||||
|
||||
|
||||
## call
|
||||
|
||||
```php
|
||||
public function call(callable|string $callback, array $parameters, null|string $default_method): mixed
|
||||
```
|
||||
|
||||
### 描述
|
||||
|
||||
调用对应的方法,并自动注入依赖
|
||||
|
||||
### 参数
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| callback | callable|string | 对应的方法 |
|
||||
| parameters | array | 参数 |
|
||||
| default_method | null|string | 默认方法 |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| mixed | |
|
||||
|
||||
|
||||
## get
|
||||
|
||||
```php
|
||||
public function get(string $id): mixed
|
||||
```
|
||||
|
||||
### 描述
|
||||
|
||||
Finds an entry of the container by its identifier and returns it.
|
||||
|
||||
### 参数
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| id | string | identifier of the entry to look for * |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| mixed | entry |
|
||||
|
||||
|
||||
## has
|
||||
|
||||
```php
|
||||
public function has(string $id): bool
|
||||
```
|
||||
|
||||
### 描述
|
||||
|
||||
Returns true if the container can return an entry for the given identifier.
|
||||
Returns false otherwise.
|
||||
`has($id)` returning true does not mean that `get($id)` will not throw an exception.
|
||||
It does however mean that `get($id)` will not throw a `NotFoundExceptionInterface`.
|
||||
|
||||
### 参数
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| id | string | identifier of the entry to look for |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| bool | |
|
||||
|
||||
|
||||
## extend
|
||||
|
||||
```php
|
||||
public function extend(string $abstract, Closure $closure): void
|
||||
```
|
||||
|
||||
### 描述
|
||||
|
||||
扩展一个类或接口
|
||||
|
||||
### 参数
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| abstract | string | 类或接口名 |
|
||||
| closure | Closure | 扩展闭包 |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| void | |
|
||||
|
||||
|
||||
## getLogPrefix
|
||||
|
||||
```php
|
||||
public function getLogPrefix(): string
|
||||
```
|
||||
|
||||
### 描述
|
||||
|
||||
获取日志前缀
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| string | |
|
||||
|
||||
|
||||
## setLogPrefix
|
||||
|
||||
```php
|
||||
public function setLogPrefix(string $prefix): void
|
||||
```
|
||||
|
||||
### 描述
|
||||
|
||||
设置日志前缀
|
||||
|
||||
### 参数
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| prefix | string | |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| void | |
|
||||
|
||||
|
||||
## getExtenders
|
||||
|
||||
```php
|
||||
public function getExtenders(string $abstract): Closure[]
|
||||
```
|
||||
|
||||
### 描述
|
||||
|
||||
获取对应类型的所有扩展器
|
||||
|
||||
### 参数
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| abstract | string | 类或接口名 |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| Closure[] | |
|
||||
|
||||
|
||||
## isAlias
|
||||
|
||||
```php
|
||||
public function isAlias(string $name): bool
|
||||
```
|
||||
|
||||
### 描述
|
||||
|
||||
判断传入的是否为别名
|
||||
|
||||
### 参数
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| name | string | |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| bool | |
|
||||
|
||||
|
||||
## dropStaleInstances
|
||||
|
||||
```php
|
||||
public function dropStaleInstances(string $abstract): void
|
||||
```
|
||||
|
||||
### 描述
|
||||
|
||||
抛弃所有过时的实例和别名
|
||||
|
||||
### 参数
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| abstract | string | 类或接口名 |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| void | |
|
||||
|
||||
|
||||
## getClosure
|
||||
|
||||
```php
|
||||
public function getClosure(string $abstract, string $concrete): Closure
|
||||
```
|
||||
|
||||
### 描述
|
||||
|
||||
获取一个解析对应类的闭包
|
||||
|
||||
### 参数
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| abstract | string | 类或接口名 |
|
||||
| concrete | string | 实际类名 |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| Closure | |
|
||||
|
||||
|
||||
## getLastParameterOverride
|
||||
|
||||
```php
|
||||
public function getLastParameterOverride(): array
|
||||
```
|
||||
|
||||
### 描述
|
||||
|
||||
获取最后一次的覆盖参数
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| array | |
|
||||
|
||||
|
||||
## notInstantiable
|
||||
|
||||
```php
|
||||
public function notInstantiable(string $concrete, string $reason): void
|
||||
```
|
||||
|
||||
### 描述
|
||||
|
||||
抛出实例化异常
|
||||
|
||||
### 参数
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| concrete | string | |
|
||||
| reason | string | |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| void | |
|
||||
|
||||
|
||||
## resolveDependencies
|
||||
|
||||
```php
|
||||
public function resolveDependencies(ReflectionParameter[] $dependencies): array
|
||||
```
|
||||
|
||||
### 描述
|
||||
|
||||
解析依赖
|
||||
|
||||
### 参数
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| dependencies | ReflectionParameter[] | |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| array | |
|
||||
|
||||
|
||||
## hasParameterOverride
|
||||
|
||||
```php
|
||||
public function hasParameterOverride(ReflectionParameter $parameter): bool
|
||||
```
|
||||
|
||||
### 描述
|
||||
|
||||
判断传入的参数是否存在覆盖参数
|
||||
|
||||
### 参数
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| parameter | ReflectionParameter | |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| bool | |
|
||||
|
||||
|
||||
## getParameterOverride
|
||||
|
||||
```php
|
||||
public function getParameterOverride(ReflectionParameter $parameter): mixed
|
||||
```
|
||||
|
||||
### 描述
|
||||
|
||||
获取覆盖参数
|
||||
|
||||
### 参数
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| parameter | ReflectionParameter | |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| mixed | |
|
||||
|
||||
|
||||
## hasParameterTypeOverride
|
||||
|
||||
```php
|
||||
public function hasParameterTypeOverride(ReflectionParameter $parameter): bool
|
||||
```
|
||||
|
||||
### 描述
|
||||
|
||||
判断传入的参数是否存在临时注入的参数
|
||||
|
||||
### 参数
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| parameter | ReflectionParameter | |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| bool | |
|
||||
|
||||
|
||||
## getParameterTypeOverride
|
||||
|
||||
```php
|
||||
public function getParameterTypeOverride(ReflectionParameter $parameter): mixed
|
||||
```
|
||||
|
||||
### 描述
|
||||
|
||||
获取临时注入的参数
|
||||
|
||||
### 参数
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| parameter | ReflectionParameter | |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| mixed | |
|
||||
|
||||
|
||||
## resolvePrimitive
|
||||
|
||||
```php
|
||||
public function resolvePrimitive(ReflectionParameter $parameter): mixed
|
||||
```
|
||||
|
||||
### 描述
|
||||
|
||||
解析基本类型
|
||||
|
||||
### 参数
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| parameter | ReflectionParameter | |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| mixed | 对应类型的默认值 |
|
||||
|
||||
|
||||
## resolveClass
|
||||
|
||||
```php
|
||||
public function resolveClass(ReflectionParameter $parameter): mixed
|
||||
```
|
||||
|
||||
### 描述
|
||||
|
||||
解析类
|
||||
|
||||
### 参数
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| parameter | ReflectionParameter | |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| mixed | |
|
||||
|
||||
|
||||
## getConcrete
|
||||
|
||||
```php
|
||||
public function getConcrete(string $abstract): Closure|string
|
||||
```
|
||||
|
||||
### 描述
|
||||
|
||||
获取类名的实际类型
|
||||
|
||||
### 参数
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| abstract | string | 类或接口名 |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| Closure|string | |
|
||||
|
||||
|
||||
## isBuildable
|
||||
|
||||
```php
|
||||
public function isBuildable(mixed $concrete, string $abstract): bool
|
||||
```
|
||||
|
||||
### 描述
|
||||
|
||||
判断传入的实际类型是否可以构造
|
||||
|
||||
### 参数
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| concrete | mixed | 实际类型 |
|
||||
| abstract | string | 类或接口名 |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| bool | |
|
||||
|
||||
|
||||
## isShared
|
||||
|
||||
```php
|
||||
public function isShared(string $abstract): bool
|
||||
```
|
||||
|
||||
### 描述
|
||||
|
||||
判断传入的类型是否为共享实例
|
||||
|
||||
### 参数
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| abstract | string | 类或接口名 |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| bool | |
|
||||
|
||||
|
||||
## shouldLog
|
||||
|
||||
```php
|
||||
public function shouldLog(): bool
|
||||
```
|
||||
|
||||
### 描述
|
||||
|
||||
判断是否输出日志
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| bool | |
|
||||
|
||||
|
||||
## log
|
||||
|
||||
```php
|
||||
public function log(string $message): void
|
||||
```
|
||||
|
||||
### 描述
|
||||
|
||||
记录日志(自动附加容器日志前缀)
|
||||
|
||||
### 参数
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| message | string | |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| void | |
|
||||
@@ -37,7 +37,7 @@ public function getData(): mixed
|
||||
## reply
|
||||
|
||||
```php
|
||||
public function reply(mixed $msg, bool $yield): array|bool
|
||||
public function reply(array|string $msg, bool|callable|Closure $yield): array|bool
|
||||
```
|
||||
|
||||
### 描述
|
||||
@@ -48,19 +48,20 @@ only can used by cq->message event function
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| msg | mixed | |
|
||||
| yield | bool | |
|
||||
| msg | array|string | 要回复的消息 |
|
||||
| yield | bool|callable|Closure | 是否协程挂起(true),是否绑定异步事件(Closure) |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| array|bool | |
|
||||
| array|bool | 返回API调用结果 |
|
||||
|
||||
|
||||
## finalReply
|
||||
|
||||
```php
|
||||
public function finalReply(mixed $msg, bool $yield): mixed
|
||||
public function finalReply(array|string $msg, bool $yield): mixed
|
||||
```
|
||||
|
||||
### 描述
|
||||
@@ -71,8 +72,9 @@ public function finalReply(mixed $msg, bool $yield): mixed
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| msg | mixed | |
|
||||
| yield | bool | |
|
||||
| msg | array|string | 要回复的消息 |
|
||||
| yield | bool | 是否协程挂起(true),是否绑定异步事件(Closure) |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
@@ -97,34 +99,36 @@ public function waitMessage(string $prompt, int $timeout, string $timeout_prompt
|
||||
| prompt | string | |
|
||||
| timeout | int | |
|
||||
| timeout_prompt | string | |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| string | |
|
||||
| string | 返回用户输入的内容 |
|
||||
|
||||
|
||||
## getArgs
|
||||
|
||||
```php
|
||||
public function getArgs(mixed $mode, mixed $prompt_msg): mixed|string
|
||||
public function getArgs(int|string $mode, string|Stringable $prompt_msg): float|int|string
|
||||
```
|
||||
|
||||
### 描述
|
||||
|
||||
作者很懒,什么也没有说
|
||||
根据选定的模式获取消息参数
|
||||
|
||||
### 参数
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| mode | mixed | |
|
||||
| prompt_msg | mixed | |
|
||||
| mode | int|string | 获取的模式 |
|
||||
| prompt_msg | string|Stringable | 提示语回复 |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| mixed|string | |
|
||||
| float|int|string | |
|
||||
|
||||
|
||||
## getNextArg
|
||||
@@ -135,18 +139,19 @@ public function getNextArg(string $prompt_msg): int|mixed|string
|
||||
|
||||
### 描述
|
||||
|
||||
作者很懒,什么也没有说
|
||||
获取下一个参数
|
||||
|
||||
### 参数
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| prompt_msg | string | |
|
||||
| prompt_msg | string | 提示语回复 |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| int|mixed|string | |
|
||||
| int|mixed|string | 返回获取的参数 |
|
||||
|
||||
|
||||
## getFullArg
|
||||
@@ -157,18 +162,19 @@ public function getFullArg(string $prompt_msg): int|mixed|string
|
||||
|
||||
### 描述
|
||||
|
||||
作者很懒,什么也没有说
|
||||
获取接下来所有的消息当成一个完整的参数(包含空格)
|
||||
|
||||
### 参数
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| prompt_msg | string | |
|
||||
| prompt_msg | string | 提示语回复 |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| int|mixed|string | |
|
||||
| int|mixed|string | 返回获取的参数 |
|
||||
|
||||
|
||||
## getNumArg
|
||||
@@ -179,24 +185,25 @@ public function getNumArg(string $prompt_msg): int|mixed|string
|
||||
|
||||
### 描述
|
||||
|
||||
作者很懒,什么也没有说
|
||||
获取下一个数字类型的参数
|
||||
|
||||
### 参数
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| prompt_msg | string | |
|
||||
| prompt_msg | string | 提示语回复 |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| int|mixed|string | |
|
||||
| int|mixed|string | 返回获取的参数 |
|
||||
|
||||
|
||||
## cloneFromParent
|
||||
|
||||
```php
|
||||
public function cloneFromParent(): mixed
|
||||
public function cloneFromParent(): ContextInterface
|
||||
```
|
||||
|
||||
### 描述
|
||||
@@ -207,4 +214,4 @@ public function cloneFromParent(): mixed
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| mixed | |
|
||||
| ContextInterface | 返回上下文 |
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
## initTableList
|
||||
|
||||
```php
|
||||
public function initTableList(mixed $db_name): mixed
|
||||
public function initTableList(string $db_name): mixed
|
||||
```
|
||||
|
||||
### 描述
|
||||
@@ -14,7 +14,8 @@ public function initTableList(mixed $db_name): mixed
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| db_name | mixed | |
|
||||
| db_name | string | 数据库名称 |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
@@ -25,7 +26,7 @@ public function initTableList(mixed $db_name): mixed
|
||||
## table
|
||||
|
||||
```php
|
||||
public function table(mixed $table_name): ZM\DB\Table
|
||||
public function table(string $table_name): Table
|
||||
```
|
||||
|
||||
### 描述
|
||||
@@ -36,18 +37,19 @@ public function table(mixed $table_name): ZM\DB\Table
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| table_name | mixed | |
|
||||
| table_name | string | 表名 |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| ZM\DB\Table | |
|
||||
| Table | 返回表对象 |
|
||||
|
||||
|
||||
## statement
|
||||
|
||||
```php
|
||||
public function statement(mixed $line): mixed
|
||||
public function statement(string $line): mixed
|
||||
```
|
||||
|
||||
### 描述
|
||||
@@ -58,7 +60,8 @@ public function statement(mixed $line): mixed
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| line | mixed | |
|
||||
| line | string | SQL语句 |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
@@ -69,7 +72,7 @@ public function statement(mixed $line): mixed
|
||||
## unprepared
|
||||
|
||||
```php
|
||||
public function unprepared(mixed $line): bool
|
||||
public function unprepared(string $line): bool
|
||||
```
|
||||
|
||||
### 描述
|
||||
@@ -80,9 +83,35 @@ public function unprepared(mixed $line): bool
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| line | mixed | |
|
||||
| line | string | SQL语句 |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| bool | |
|
||||
| bool | 返回查询是否成功的结果 |
|
||||
|
||||
|
||||
## rawQuery
|
||||
|
||||
```php
|
||||
public function rawQuery(string $line, array $params, int $fetch_mode): array|false
|
||||
```
|
||||
|
||||
### 描述
|
||||
|
||||
作者很懒,什么也没有说
|
||||
|
||||
### 参数
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| line | string | SQL语句 |
|
||||
| params | array | 查询参数 |
|
||||
| fetch_mode | int | fetch规则 |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| array|false | 返回结果集或false |
|
||||
|
||||
@@ -15,6 +15,7 @@ DeleteBody constructor.
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| table | ZM\DB\Table | |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
## __construct
|
||||
|
||||
```php
|
||||
public function __construct(mixed $row, ZM\DB\Table $table): mixed
|
||||
public function __construct(Table $table, array|string $row): mixed
|
||||
```
|
||||
|
||||
### 描述
|
||||
@@ -14,8 +14,9 @@ InsertBody constructor.
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| row | mixed | |
|
||||
| table | ZM\DB\Table | |
|
||||
| table | Table | 表对象 |
|
||||
| row | array|string | 行数据 |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
|
||||
@@ -37,7 +37,7 @@ public function count(): int
|
||||
## fetchAll
|
||||
|
||||
```php
|
||||
public function fetchAll(int $fetch_mode): mixed
|
||||
public function fetchAll(mixed $fetch_mode): mixed
|
||||
```
|
||||
|
||||
### 描述
|
||||
@@ -48,7 +48,8 @@ public function fetchAll(int $fetch_mode): mixed
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| fetch_mode | int | |
|
||||
| fetch_mode | mixed | |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
@@ -76,7 +77,7 @@ public function fetchFirst(): null|mixed
|
||||
## value
|
||||
|
||||
```php
|
||||
public function value(null $key): null|mixed
|
||||
public function value(null|mixed $key): null|mixed
|
||||
```
|
||||
|
||||
### 描述
|
||||
@@ -87,7 +88,8 @@ public function value(null $key): null|mixed
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| key | null | |
|
||||
| key | null|mixed | |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
@@ -110,6 +112,7 @@ public function execute(int $fetch_mode): mixed
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| fetch_mode | int | |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
|
||||
@@ -16,6 +16,7 @@ UpdateBody constructor.
|
||||
| -------- | ---- | ----------- |
|
||||
| table | ZM\DB\Table | |
|
||||
| set_value | array | |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
|
||||
@@ -15,6 +15,7 @@ public function interrupt(mixed $return_var): mixed
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| return_var | mixed | |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
|
||||
@@ -15,6 +15,7 @@ public function loadEventByParser(ZM\Annotation\AnnotationParser $parser): mixed
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| parser | ZM\Annotation\AnnotationParser | |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
|
||||
@@ -1 +1,24 @@
|
||||
# ZM\Event\SwooleEvent\OnMessage
|
||||
# ZM\Event\SwooleEvent\OnMessage
|
||||
|
||||
## registerRequestContainerBindings
|
||||
|
||||
```php
|
||||
public function registerRequestContainerBindings(Swoole\WebSocket\Frame $frame, ZM\ConnectionManager\ConnectionObject $conn): void
|
||||
```
|
||||
|
||||
### 描述
|
||||
|
||||
注册请求容器绑定
|
||||
|
||||
### 参数
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| frame | Swoole\WebSocket\Frame | |
|
||||
| conn | ZM\ConnectionManager\ConnectionObject | |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| void | |
|
||||
|
||||
@@ -16,6 +16,7 @@ public function onCall(Swoole\Server $server, Swoole\Server\Task $task): mixed
|
||||
| -------- | ---- | ----------- |
|
||||
| server | Swoole\Server | |
|
||||
| task | Swoole\Server\Task | |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
|
||||
@@ -15,3 +15,26 @@ public function loadAnnotations(): mixed
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| mixed | |
|
||||
|
||||
|
||||
## registerWorkerContainerBindings
|
||||
|
||||
```php
|
||||
public function registerWorkerContainerBindings(Swoole\WebSocket\Server $server): void
|
||||
```
|
||||
|
||||
### 描述
|
||||
|
||||
注册进程容器绑定
|
||||
|
||||
### 参数
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| server | Swoole\WebSocket\Server | |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| void | |
|
||||
|
||||
@@ -1,5 +1,29 @@
|
||||
# ZM\Framework
|
||||
|
||||
## __construct
|
||||
|
||||
```php
|
||||
public function __construct(array $args, bool $instant_mode): mixed
|
||||
```
|
||||
|
||||
### 描述
|
||||
|
||||
创建一个新的框架实例
|
||||
|
||||
### 参数
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| args | array | 运行参数 |
|
||||
| instant_mode | bool | 是否为单文件模式 |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| mixed | |
|
||||
|
||||
|
||||
## saveProcessState
|
||||
|
||||
```php
|
||||
@@ -17,6 +41,7 @@ public function saveProcessState(int|string $pid, int $type, array $data): mixed
|
||||
| pid | int|string | |
|
||||
| type | int | |
|
||||
| data | array | |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
@@ -40,6 +65,7 @@ public function getProcessState(mixed $id_or_name, int $type): false|int|mixed
|
||||
| -------- | ---- | ----------- |
|
||||
| id_or_name | mixed | |
|
||||
| type | int | |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
@@ -50,7 +76,7 @@ public function getProcessState(mixed $id_or_name, int $type): false|int|mixed
|
||||
## removeProcessState
|
||||
|
||||
```php
|
||||
public function removeProcessState(null $id_or_name, int $type): mixed
|
||||
public function removeProcessState(null|int|string $id_or_name, int $type): mixed
|
||||
```
|
||||
|
||||
### 描述
|
||||
@@ -61,8 +87,9 @@ public function removeProcessState(null $id_or_name, int $type): mixed
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| id_or_name | null | |
|
||||
| id_or_name | null|int|string | |
|
||||
| type | int | |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
@@ -107,7 +134,7 @@ public function registerServerEvents(): mixed
|
||||
## parseCliArgs
|
||||
|
||||
```php
|
||||
public function parseCliArgs(mixed $args, mixed $add_port): mixed
|
||||
public function parseCliArgs(array $args, bool|string $add_port): mixed
|
||||
```
|
||||
|
||||
### 描述
|
||||
@@ -118,8 +145,9 @@ public function parseCliArgs(mixed $args, mixed $add_port): mixed
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| args | mixed | |
|
||||
| add_port | mixed | |
|
||||
| args | array | 命令行参数 |
|
||||
| add_port | bool|string | 是否添加端口号 |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
|
||||
@@ -17,58 +17,10 @@ public function initHeader(): mixed
|
||||
| mixed | |
|
||||
|
||||
|
||||
## status
|
||||
|
||||
```php
|
||||
public function status(mixed $http_code, mixed $reason, mixed $params): mixed
|
||||
```
|
||||
|
||||
### 描述
|
||||
|
||||
作者很懒,什么也没有说
|
||||
|
||||
### 参数
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| http_code | mixed | |
|
||||
| reason | mixed | |
|
||||
| params | mixed | |
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| mixed | |
|
||||
|
||||
|
||||
## setStatusCode
|
||||
|
||||
```php
|
||||
public function setStatusCode(mixed $http_code, mixed $reason, mixed $params): mixed
|
||||
```
|
||||
|
||||
### 描述
|
||||
|
||||
作者很懒,什么也没有说
|
||||
|
||||
### 参数
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| http_code | mixed | |
|
||||
| reason | mixed | |
|
||||
| params | mixed | |
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| mixed | |
|
||||
|
||||
|
||||
## header
|
||||
|
||||
```php
|
||||
public function header(mixed $key, mixed $value, mixed $ucwords): mixed
|
||||
public function header(array|string $value, null|array|string $ucwords, string $key): mixed
|
||||
```
|
||||
|
||||
### 描述
|
||||
@@ -79,9 +31,10 @@ public function header(mixed $key, mixed $value, mixed $ucwords): mixed
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| key | mixed | |
|
||||
| value | mixed | |
|
||||
| ucwords | mixed | |
|
||||
| value | array|string | |
|
||||
| ucwords | null|array|string | |
|
||||
| key | string | |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
@@ -92,7 +45,7 @@ public function header(mixed $key, mixed $value, mixed $ucwords): mixed
|
||||
## setHeader
|
||||
|
||||
```php
|
||||
public function setHeader(mixed $key, mixed $value, mixed $ucwords): mixed
|
||||
public function setHeader(array|string $value, null|array|string $ucwords, string $key): mixed
|
||||
```
|
||||
|
||||
### 描述
|
||||
@@ -103,9 +56,10 @@ public function setHeader(mixed $key, mixed $value, mixed $ucwords): mixed
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| key | mixed | |
|
||||
| value | mixed | |
|
||||
| ucwords | mixed | |
|
||||
| value | array|string | |
|
||||
| ucwords | null|array|string | |
|
||||
| key | string | |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
@@ -116,7 +70,7 @@ public function setHeader(mixed $key, mixed $value, mixed $ucwords): mixed
|
||||
## trailer
|
||||
|
||||
```php
|
||||
public function trailer(mixed $key, mixed $value): mixed
|
||||
public function trailer(array|string $value, string $key): mixed
|
||||
```
|
||||
|
||||
### 描述
|
||||
@@ -127,8 +81,9 @@ public function trailer(mixed $key, mixed $value): mixed
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| key | mixed | |
|
||||
| value | mixed | |
|
||||
| value | array|string | |
|
||||
| key | string | |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
@@ -156,7 +111,7 @@ public function ping(): mixed
|
||||
## write
|
||||
|
||||
```php
|
||||
public function write(mixed $content): mixed
|
||||
public function write(string|Stringable $content): mixed
|
||||
```
|
||||
|
||||
### 描述
|
||||
@@ -167,7 +122,8 @@ public function write(mixed $content): mixed
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| content | mixed | |
|
||||
| content | string|Stringable | |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
@@ -178,7 +134,7 @@ public function write(mixed $content): mixed
|
||||
## end
|
||||
|
||||
```php
|
||||
public function end(mixed $content): mixed
|
||||
public function end(null|string|Stringable $content): mixed
|
||||
```
|
||||
|
||||
### 描述
|
||||
@@ -189,7 +145,8 @@ public function end(mixed $content): mixed
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| content | mixed | |
|
||||
| content | null|string|Stringable | |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
@@ -200,7 +157,7 @@ public function end(mixed $content): mixed
|
||||
## sendfile
|
||||
|
||||
```php
|
||||
public function sendfile(mixed $filename, mixed $offset, mixed $length): mixed
|
||||
public function sendfile(null|int|string $offset, null|int|string $length, string $filename): mixed
|
||||
```
|
||||
|
||||
### 描述
|
||||
@@ -211,9 +168,10 @@ public function sendfile(mixed $filename, mixed $offset, mixed $length): mixed
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| filename | mixed | |
|
||||
| offset | mixed | |
|
||||
| length | mixed | |
|
||||
| offset | null|int|string | |
|
||||
| length | null|int|string | |
|
||||
| filename | string | |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
@@ -224,7 +182,7 @@ public function sendfile(mixed $filename, mixed $offset, mixed $length): mixed
|
||||
## redirect
|
||||
|
||||
```php
|
||||
public function redirect(mixed $location, mixed $http_code): mixed
|
||||
public function redirect(string $location, int $http_code): mixed
|
||||
```
|
||||
|
||||
### 描述
|
||||
@@ -235,8 +193,9 @@ public function redirect(mixed $location, mixed $http_code): mixed
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| location | mixed | |
|
||||
| http_code | mixed | |
|
||||
| location | string | |
|
||||
| http_code | int | |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
@@ -276,6 +235,7 @@ public function create(mixed $fd): mixed
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| fd | mixed | |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
@@ -303,7 +263,7 @@ public function upgrade(): mixed
|
||||
## push
|
||||
|
||||
```php
|
||||
public function push(mixed $data, null $opcode, null $flags): mixed
|
||||
public function push(mixed $data, mixed $opcode, mixed $flags): mixed
|
||||
```
|
||||
|
||||
### 描述
|
||||
@@ -315,8 +275,9 @@ public function push(mixed $data, null $opcode, null $flags): mixed
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| data | mixed | |
|
||||
| opcode | null | |
|
||||
| flags | null | |
|
||||
| opcode | mixed | |
|
||||
| flags | mixed | |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
|
||||
@@ -1,17 +1,57 @@
|
||||
# ZM\Module\ModuleBase
|
||||
|
||||
## getModuleName
|
||||
## __construct
|
||||
|
||||
```php
|
||||
public function getModuleName(): mixed
|
||||
public function __construct(string $module_name): mixed
|
||||
```
|
||||
|
||||
### 描述
|
||||
|
||||
作者很懒,什么也没有说
|
||||
|
||||
### 参数
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| module_name | string | 模块名称 |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| mixed | |
|
||||
|
||||
|
||||
## getModuleName
|
||||
|
||||
```php
|
||||
public function getModuleName(): string
|
||||
```
|
||||
|
||||
### 描述
|
||||
|
||||
获取模块名称
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| string | |
|
||||
|
||||
|
||||
## getEvents
|
||||
|
||||
```php
|
||||
public function getEvents(): array
|
||||
```
|
||||
|
||||
### 描述
|
||||
|
||||
获取事件列表
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| array | |
|
||||
|
||||
@@ -15,6 +15,7 @@ public function __construct(array $module): mixed
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| module | array | |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
@@ -25,7 +26,7 @@ public function __construct(array $module): mixed
|
||||
## setOutputPath
|
||||
|
||||
```php
|
||||
public function setOutputPath(mixed $path): mixed
|
||||
public function setOutputPath(string $path): mixed
|
||||
```
|
||||
|
||||
### 描述
|
||||
@@ -36,7 +37,8 @@ public function setOutputPath(mixed $path): mixed
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| path | mixed | |
|
||||
| path | string | 输出路径 |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
@@ -59,6 +61,7 @@ public function setOverride(bool $override): mixed
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| override | bool | |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
|
||||
@@ -18,6 +18,7 @@ public function unpack(mixed $ignore_depends, bool $override_light_cache, bool $
|
||||
| override_light_cache | bool | |
|
||||
| override_data_files | bool | |
|
||||
| override_source | bool | |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
@@ -57,6 +58,7 @@ public function checkDepends(mixed $ignore_depends): mixed
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| ignore_depends | mixed | |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
@@ -113,6 +115,7 @@ public function copyZMDataStore(mixed $override_data): mixed
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| override_data | mixed | |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
|
||||
@@ -1,9 +1,26 @@
|
||||
# ZM\Module\QQBot
|
||||
|
||||
## handleByEvent
|
||||
|
||||
```php
|
||||
public function handleByEvent(): mixed
|
||||
```
|
||||
|
||||
### 描述
|
||||
|
||||
作者很懒,什么也没有说
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| mixed | |
|
||||
|
||||
|
||||
## handle
|
||||
|
||||
```php
|
||||
public function handle(mixed $data, int $level): mixed
|
||||
public function handle(array|Iterator $data, int $level): mixed
|
||||
```
|
||||
|
||||
### 描述
|
||||
@@ -14,8 +31,9 @@ public function handle(mixed $data, int $level): mixed
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| data | mixed | |
|
||||
| level | int | |
|
||||
| data | array|Iterator | 数据包 |
|
||||
| level | int | 递归等级 |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
@@ -26,7 +44,7 @@ public function handle(mixed $data, int $level): mixed
|
||||
## dispatchBeforeEvents
|
||||
|
||||
```php
|
||||
public function dispatchBeforeEvents(mixed $data, mixed $time): ZM\Event\EventDispatcher
|
||||
public function dispatchBeforeEvents(array|Iterator $data, string $time): ZM\Event\EventDispatcher
|
||||
```
|
||||
|
||||
### 描述
|
||||
@@ -37,8 +55,9 @@ public function dispatchBeforeEvents(mixed $data, mixed $time): ZM\Event\EventDi
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| data | mixed | |
|
||||
| time | mixed | |
|
||||
| data | array|Iterator | 数据包 |
|
||||
| time | string | 类型(pre或post) |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
@@ -49,7 +68,7 @@ public function dispatchBeforeEvents(mixed $data, mixed $time): ZM\Event\EventDi
|
||||
## dispatchEvents
|
||||
|
||||
```php
|
||||
public function dispatchEvents(mixed $data): mixed
|
||||
public function dispatchEvents(array|Iterator $data): mixed
|
||||
```
|
||||
|
||||
### 描述
|
||||
@@ -60,7 +79,8 @@ public function dispatchEvents(mixed $data): mixed
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| data | mixed | |
|
||||
| data | array|Iterator | 数据包 |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
@@ -68,6 +88,29 @@ public function dispatchEvents(mixed $data): mixed
|
||||
| mixed | |
|
||||
|
||||
|
||||
## dispatchAfterEvents
|
||||
|
||||
```php
|
||||
public function dispatchAfterEvents(mixed $data): ZM\Event\EventDispatcher
|
||||
```
|
||||
|
||||
### 描述
|
||||
|
||||
作者很懒,什么也没有说
|
||||
|
||||
### 参数
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| data | mixed | 分发事件数据包 |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| ZM\Event\EventDispatcher | |
|
||||
|
||||
|
||||
## dispatchAPIResponse
|
||||
|
||||
```php
|
||||
@@ -83,6 +126,7 @@ public function dispatchAPIResponse(mixed $req): mixed
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| req | mixed | |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
@@ -93,15 +137,15 @@ public function dispatchAPIResponse(mixed $req): mixed
|
||||
## getInstance
|
||||
|
||||
```php
|
||||
public function getInstance(): self
|
||||
public function getInstance(): static
|
||||
```
|
||||
|
||||
### 描述
|
||||
|
||||
作者很懒,什么也没有说
|
||||
获取类实例
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| self | |
|
||||
| static | |
|
||||
|
||||
@@ -1 +1,93 @@
|
||||
# ZM\MySQL\MySQLConnection
|
||||
# ZM\MySQL\MySQLConnection
|
||||
|
||||
## prepare
|
||||
|
||||
```php
|
||||
public function prepare(mixed $sql, mixed $options): mixed
|
||||
```
|
||||
|
||||
### 描述
|
||||
|
||||
作者很懒,什么也没有说
|
||||
|
||||
### 参数
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| sql | mixed | |
|
||||
| options | mixed | |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| mixed | |
|
||||
|
||||
|
||||
## query
|
||||
|
||||
```php
|
||||
public function query(mixed $args): mixed
|
||||
```
|
||||
|
||||
### 描述
|
||||
|
||||
作者很懒,什么也没有说
|
||||
|
||||
### 参数
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| args | mixed | |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| mixed | |
|
||||
|
||||
|
||||
## exec
|
||||
|
||||
```php
|
||||
public function exec(mixed $sql): mixed
|
||||
```
|
||||
|
||||
### 描述
|
||||
|
||||
作者很懒,什么也没有说
|
||||
|
||||
### 参数
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| sql | mixed | |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| mixed | |
|
||||
|
||||
|
||||
## lastInsertId
|
||||
|
||||
```php
|
||||
public function lastInsertId(null|mixed $name): mixed
|
||||
```
|
||||
|
||||
### 描述
|
||||
|
||||
作者很懒,什么也没有说
|
||||
|
||||
### 参数
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| name | null|mixed | |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| mixed | |
|
||||
|
||||
@@ -32,6 +32,7 @@ public function putConnection(PDO|PDOProxy $connection): mixed
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| connection | PDO|PDOProxy | |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
|
||||
@@ -1 +1,17 @@
|
||||
# ZM\MySQL\MySQLStatement
|
||||
# ZM\MySQL\MySQLStatement
|
||||
|
||||
## current
|
||||
|
||||
```php
|
||||
public function current(): mixed
|
||||
```
|
||||
|
||||
### 描述
|
||||
|
||||
作者很懒,什么也没有说
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| mixed | |
|
||||
|
||||
@@ -54,7 +54,7 @@ wrapper method
|
||||
## setAutoCommit
|
||||
|
||||
```php
|
||||
public function setAutoCommit(mixed $autoCommit): mixed
|
||||
public function setAutoCommit(bool $auto_commit): mixed
|
||||
```
|
||||
|
||||
### 描述
|
||||
@@ -65,7 +65,8 @@ wrapper method
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| autoCommit | mixed | |
|
||||
| auto_commit | bool | |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
@@ -90,6 +91,7 @@ wrapper method
|
||||
| query | string | |
|
||||
| params | array | |
|
||||
| types | array | |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
@@ -114,6 +116,7 @@ wrapper method
|
||||
| query | string | |
|
||||
| params | array | |
|
||||
| types | array | |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
@@ -138,6 +141,7 @@ public function fetchOne(string $query, array $params, array $types): false|mixe
|
||||
| query | string | |
|
||||
| params | array | |
|
||||
| types | array | |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
@@ -165,7 +169,7 @@ wrapper method
|
||||
## delete
|
||||
|
||||
```php
|
||||
public function delete(mixed $table, array $criteria, array $types): int
|
||||
public function delete(string $table, array $criteria, array $types): int
|
||||
```
|
||||
|
||||
### 描述
|
||||
@@ -176,9 +180,10 @@ public function delete(mixed $table, array $criteria, array $types): int
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| table | mixed | |
|
||||
| table | string | 表 |
|
||||
| criteria | array | |
|
||||
| types | array | |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
@@ -189,7 +194,7 @@ public function delete(mixed $table, array $criteria, array $types): int
|
||||
## setTransactionIsolation
|
||||
|
||||
```php
|
||||
public function setTransactionIsolation(mixed $level): int
|
||||
public function setTransactionIsolation(int $level): int
|
||||
```
|
||||
|
||||
### 描述
|
||||
@@ -200,7 +205,8 @@ wrapper method
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| level | mixed | |
|
||||
| level | int | Sets the transaction isolation level |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
@@ -228,7 +234,7 @@ wrapper method
|
||||
## update
|
||||
|
||||
```php
|
||||
public function update(mixed $table, array $data, array $criteria, array $types): int
|
||||
public function update(string $table, array $data, array $criteria, array $types): int
|
||||
```
|
||||
|
||||
### 描述
|
||||
@@ -239,10 +245,11 @@ wrapper method
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| table | mixed | |
|
||||
| table | string | 表名 |
|
||||
| data | array | |
|
||||
| criteria | array | |
|
||||
| types | array | |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
@@ -253,7 +260,7 @@ wrapper method
|
||||
## insert
|
||||
|
||||
```php
|
||||
public function insert(mixed $table, array $data, array $types): int
|
||||
public function insert(string $table, array $data, array $types): int
|
||||
```
|
||||
|
||||
### 描述
|
||||
@@ -264,9 +271,10 @@ wrapper method
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| table | mixed | |
|
||||
| table | string | 表名 |
|
||||
| data | array | |
|
||||
| types | array | |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
@@ -277,7 +285,7 @@ wrapper method
|
||||
## quoteIdentifier
|
||||
|
||||
```php
|
||||
public function quoteIdentifier(mixed $str): string
|
||||
public function quoteIdentifier(string $str): string
|
||||
```
|
||||
|
||||
### 描述
|
||||
@@ -288,7 +296,8 @@ wrapper method
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| str | mixed | |
|
||||
| str | string | The name to be quoted |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
@@ -299,7 +308,7 @@ wrapper method
|
||||
## quote
|
||||
|
||||
```php
|
||||
public function quote(mixed $value, int $type): mixed
|
||||
public function quote(mixed $value, null|int|string|Type $type): mixed
|
||||
```
|
||||
|
||||
### 描述
|
||||
@@ -311,7 +320,8 @@ wrapper method
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| value | mixed | |
|
||||
| type | int | |
|
||||
| type | null|int|string|Type | |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
@@ -319,320 +329,6 @@ wrapper method
|
||||
| mixed | |
|
||||
|
||||
|
||||
## fetchAllNumeric
|
||||
|
||||
```php
|
||||
public function fetchAllNumeric(string $query, array $params, array $types): array
|
||||
```
|
||||
|
||||
### 描述
|
||||
|
||||
wrapper method
|
||||
|
||||
### 参数
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| query | string | |
|
||||
| params | array | |
|
||||
| types | array | |
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| array | |
|
||||
|
||||
|
||||
## fetchAllAssociative
|
||||
|
||||
```php
|
||||
public function fetchAllAssociative(string $query, array $params, array $types): array
|
||||
```
|
||||
|
||||
### 描述
|
||||
|
||||
wrapper method
|
||||
|
||||
### 参数
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| query | string | |
|
||||
| params | array | |
|
||||
| types | array | |
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| array | |
|
||||
|
||||
|
||||
## fetchAllKeyValue
|
||||
|
||||
```php
|
||||
public function fetchAllKeyValue(string $query, array $params, array $types): array
|
||||
```
|
||||
|
||||
### 描述
|
||||
|
||||
wrapper method
|
||||
|
||||
### 参数
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| query | string | |
|
||||
| params | array | |
|
||||
| types | array | |
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| array | |
|
||||
|
||||
|
||||
## fetchAllAssociativeIndexed
|
||||
|
||||
```php
|
||||
public function fetchAllAssociativeIndexed(string $query, array $params, array $types): array
|
||||
```
|
||||
|
||||
### 描述
|
||||
|
||||
wrapper method
|
||||
|
||||
### 参数
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| query | string | |
|
||||
| params | array | |
|
||||
| types | array | |
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| array | |
|
||||
|
||||
|
||||
## fetchFirstColumn
|
||||
|
||||
```php
|
||||
public function fetchFirstColumn(string $query, array $params, array $types): array
|
||||
```
|
||||
|
||||
### 描述
|
||||
|
||||
wrapper method
|
||||
|
||||
### 参数
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| query | string | |
|
||||
| params | array | |
|
||||
| types | array | |
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| array | |
|
||||
|
||||
|
||||
## iterateNumeric
|
||||
|
||||
```php
|
||||
public function iterateNumeric(string $query, array $params, array $types): Traversable
|
||||
```
|
||||
|
||||
### 描述
|
||||
|
||||
wrapper method
|
||||
|
||||
### 参数
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| query | string | |
|
||||
| params | array | |
|
||||
| types | array | |
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| Traversable | |
|
||||
|
||||
|
||||
## iterateAssociative
|
||||
|
||||
```php
|
||||
public function iterateAssociative(string $query, array $params, array $types): Traversable
|
||||
```
|
||||
|
||||
### 描述
|
||||
|
||||
wrapper method
|
||||
|
||||
### 参数
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| query | string | |
|
||||
| params | array | |
|
||||
| types | array | |
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| Traversable | |
|
||||
|
||||
|
||||
## iterateKeyValue
|
||||
|
||||
```php
|
||||
public function iterateKeyValue(string $query, array $params, array $types): Traversable
|
||||
```
|
||||
|
||||
### 描述
|
||||
|
||||
wrapper method
|
||||
|
||||
### 参数
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| query | string | |
|
||||
| params | array | |
|
||||
| types | array | |
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| Traversable | |
|
||||
|
||||
|
||||
## iterateAssociativeIndexed
|
||||
|
||||
```php
|
||||
public function iterateAssociativeIndexed(string $query, array $params, array $types): Traversable
|
||||
```
|
||||
|
||||
### 描述
|
||||
|
||||
wrapper method
|
||||
|
||||
### 参数
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| query | string | |
|
||||
| params | array | |
|
||||
| types | array | |
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| Traversable | |
|
||||
|
||||
|
||||
## iterateColumn
|
||||
|
||||
```php
|
||||
public function iterateColumn(string $query, array $params, array $types): Traversable
|
||||
```
|
||||
|
||||
### 描述
|
||||
|
||||
wrapper method
|
||||
|
||||
### 参数
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| query | string | |
|
||||
| params | array | |
|
||||
| types | array | |
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| Traversable | |
|
||||
|
||||
|
||||
## executeQuery
|
||||
|
||||
```php
|
||||
public function executeQuery(mixed $sql, array $types, array $params, Doctrine\DBAL\Cache\QueryCacheProfile $qcp): ZM\MySQL\MySQLStatementWrapper
|
||||
```
|
||||
|
||||
### 描述
|
||||
|
||||
wrapper method
|
||||
|
||||
### 参数
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| sql | mixed | |
|
||||
| types | array | |
|
||||
| params | array | |
|
||||
| qcp | Doctrine\DBAL\Cache\QueryCacheProfile | |
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| ZM\MySQL\MySQLStatementWrapper | |
|
||||
|
||||
|
||||
## executeCacheQuery
|
||||
|
||||
```php
|
||||
public function executeCacheQuery(mixed $sql, mixed $params, mixed $types, Doctrine\DBAL\Cache\QueryCacheProfile $qcp): ZM\MySQL\MySQLStatementWrapper
|
||||
```
|
||||
|
||||
### 描述
|
||||
|
||||
wrapper method
|
||||
|
||||
### 参数
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| sql | mixed | |
|
||||
| params | mixed | |
|
||||
| types | mixed | |
|
||||
| qcp | Doctrine\DBAL\Cache\QueryCacheProfile | |
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| ZM\MySQL\MySQLStatementWrapper | |
|
||||
|
||||
|
||||
## executeStatement
|
||||
|
||||
```php
|
||||
public function executeStatement(mixed $sql, array $params, array $types): int
|
||||
```
|
||||
|
||||
### 描述
|
||||
|
||||
wrapper method
|
||||
|
||||
### 参数
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| sql | mixed | |
|
||||
| params | array | |
|
||||
| types | array | |
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| int | |
|
||||
|
||||
|
||||
## getTransactionNestingLevel
|
||||
|
||||
```php
|
||||
@@ -653,7 +349,7 @@ wrapper method
|
||||
## lastInsertId
|
||||
|
||||
```php
|
||||
public function lastInsertId(null $name): string
|
||||
public function lastInsertId(null|string $name): false|int|string
|
||||
```
|
||||
|
||||
### 描述
|
||||
@@ -664,12 +360,13 @@ wrapper method
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| name | null | |
|
||||
| name | null|string | name of the sequence object from which the ID should be returned |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| string | |
|
||||
| false|int|string | a string representation of the last inserted ID |
|
||||
|
||||
|
||||
## transactional
|
||||
@@ -687,6 +384,7 @@ overwrite method to $this->connection->transactional()
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| func | Closure | |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
@@ -697,7 +395,7 @@ overwrite method to $this->connection->transactional()
|
||||
## setNestTransactionsWithSavepoints
|
||||
|
||||
```php
|
||||
public function setNestTransactionsWithSavepoints(mixed $nestTransactionsWithSavepoints): mixed
|
||||
public function setNestTransactionsWithSavepoints(bool $nest_transactions_with_savepoints): mixed
|
||||
```
|
||||
|
||||
### 描述
|
||||
@@ -708,7 +406,8 @@ wrapper method
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| nestTransactionsWithSavepoints | mixed | |
|
||||
| nest_transactions_with_savepoints | bool | |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
@@ -787,7 +486,7 @@ wrapper method
|
||||
## createSavepoint
|
||||
|
||||
```php
|
||||
public function createSavepoint(mixed $savepoint): mixed
|
||||
public function createSavepoint(string $savepoint): mixed
|
||||
```
|
||||
|
||||
### 描述
|
||||
@@ -798,7 +497,8 @@ wrapper method
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| savepoint | mixed | |
|
||||
| savepoint | string | the name of the savepoint to create |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
@@ -809,7 +509,7 @@ wrapper method
|
||||
## releaseSavepoint
|
||||
|
||||
```php
|
||||
public function releaseSavepoint(mixed $savepoint): mixed
|
||||
public function releaseSavepoint(string $savepoint): mixed
|
||||
```
|
||||
|
||||
### 描述
|
||||
@@ -820,7 +520,8 @@ wrapper method
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| savepoint | mixed | |
|
||||
| savepoint | string | the name of the savepoint to release |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
@@ -831,7 +532,7 @@ wrapper method
|
||||
## rollbackSavepoint
|
||||
|
||||
```php
|
||||
public function rollbackSavepoint(mixed $savepoint): mixed
|
||||
public function rollbackSavepoint(string $savepoint): mixed
|
||||
```
|
||||
|
||||
### 描述
|
||||
@@ -842,7 +543,8 @@ wrapper method
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| savepoint | mixed | |
|
||||
| savepoint | string | the name of the savepoint to rollback to |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
## init
|
||||
|
||||
```php
|
||||
public function init(mixed $config): bool|mixed
|
||||
public function init(array $config): bool|mixed
|
||||
```
|
||||
|
||||
### 描述
|
||||
@@ -14,12 +14,13 @@ public function init(mixed $config): bool|mixed
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| config | mixed | |
|
||||
| config | array | 配置 |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| bool|mixed | |
|
||||
| bool|mixed | 返回失败(false)或创建SwooleTable成功结果 |
|
||||
|
||||
|
||||
## get
|
||||
@@ -37,6 +38,7 @@ public function get(string $key): null|mixed
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| key | string | |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
@@ -59,6 +61,7 @@ public function getExpire(string $key): null|mixed
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| key | string | |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
@@ -81,6 +84,7 @@ public function getExpireTS(string $key): null|mixed
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| key | string | |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
@@ -105,6 +109,7 @@ public function set(array|int|string $value, string $key, int $expire): bool
|
||||
| value | array|int|string | |
|
||||
| key | string | |
|
||||
| expire | int | |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
@@ -128,6 +133,7 @@ public function update(mixed $value, string $key): bool
|
||||
| -------- | ---- | ----------- |
|
||||
| value | mixed | |
|
||||
| key | string | |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
@@ -150,6 +156,7 @@ public function isset(string $key): bool
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| key | string | |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
|
||||
@@ -16,6 +16,7 @@ public function get(string $table, string $key): null|mixed
|
||||
| -------- | ---- | ----------- |
|
||||
| table | string | |
|
||||
| key | string | |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
@@ -26,7 +27,7 @@ public function get(string $table, string $key): null|mixed
|
||||
## set
|
||||
|
||||
```php
|
||||
public function set(array|int|string $value, string $table, string $key): mixed
|
||||
public function set(array|int|string $value, string $table, string $key): bool
|
||||
```
|
||||
|
||||
### 描述
|
||||
@@ -40,17 +41,18 @@ public function set(array|int|string $value, string $table, string $key): mixed
|
||||
| value | array|int|string | |
|
||||
| table | string | |
|
||||
| key | string | |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| mixed | |
|
||||
| bool | |
|
||||
|
||||
|
||||
## createTable
|
||||
|
||||
```php
|
||||
public function createTable(mixed $name, mixed $size, mixed $str_size, int $conflict_proportion): mixed
|
||||
public function createTable(float|int $conflict_proportion, string $name, int $size, int $str_size): mixed
|
||||
```
|
||||
|
||||
### 描述
|
||||
@@ -61,10 +63,11 @@ public function createTable(mixed $name, mixed $size, mixed $str_size, int $conf
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| name | mixed | |
|
||||
| size | mixed | |
|
||||
| str_size | mixed | |
|
||||
| conflict_proportion | int | |
|
||||
| conflict_proportion | float|int | |
|
||||
| name | string | |
|
||||
| size | int | |
|
||||
| str_size | int | |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
|
||||
@@ -32,6 +32,7 @@ public function call(callable $callable): mixed
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| callable | callable | |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
|
||||
@@ -1,27 +1,5 @@
|
||||
# ZM\Store\ZMAtomic
|
||||
|
||||
## get
|
||||
|
||||
```php
|
||||
public function get(mixed $name): Swoole\Atomic
|
||||
```
|
||||
|
||||
### 描述
|
||||
|
||||
作者很懒,什么也没有说
|
||||
|
||||
### 参数
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| name | mixed | |
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| Swoole\Atomic | |
|
||||
|
||||
|
||||
## init
|
||||
|
||||
```php
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
## yieldByWS
|
||||
|
||||
```php
|
||||
public function yieldByWS(int $timeout, array $hang, array $compare): mixed
|
||||
public function yieldByWS(array $hang, array $compare, int $timeout): mixed
|
||||
```
|
||||
|
||||
### 描述
|
||||
@@ -14,9 +14,10 @@ public function yieldByWS(int $timeout, array $hang, array $compare): mixed
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| timeout | int | |
|
||||
| hang | array | |
|
||||
| compare | array | |
|
||||
| timeout | int | |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
|
||||
138
docs/api/ZM/Utils/CommandInfoUtil.md
Normal file
138
docs/api/ZM/Utils/CommandInfoUtil.md
Normal file
@@ -0,0 +1,138 @@
|
||||
# ZM\Utils\CommandInfoUtil
|
||||
|
||||
## exists
|
||||
|
||||
```php
|
||||
public function exists(): bool
|
||||
```
|
||||
|
||||
### 描述
|
||||
|
||||
判断命令信息是否已生成并缓存
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| bool | |
|
||||
|
||||
|
||||
## get
|
||||
|
||||
```php
|
||||
public function get(): array
|
||||
```
|
||||
|
||||
### 描述
|
||||
|
||||
获取命令信息
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| array | |
|
||||
|
||||
|
||||
## regenerate
|
||||
|
||||
```php
|
||||
public function regenerate(): void
|
||||
```
|
||||
|
||||
### 描述
|
||||
|
||||
重新生成命令信息
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| void | |
|
||||
|
||||
|
||||
## getHelp
|
||||
|
||||
```php
|
||||
public function getHelp(string $command_id, bool $simple): string
|
||||
```
|
||||
|
||||
### 描述
|
||||
|
||||
获取命令帮助
|
||||
|
||||
### 参数
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| command_id | string | 命令ID,为 `class@method` 格式 |
|
||||
| simple | bool | 是否仅输出简易信息(只有命令触发条件和描述) |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| string | |
|
||||
|
||||
|
||||
## save
|
||||
|
||||
```php
|
||||
public function save(array $helps): void
|
||||
```
|
||||
|
||||
### 描述
|
||||
|
||||
缓存命令信息
|
||||
|
||||
### 参数
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| helps | array | |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| void | |
|
||||
|
||||
|
||||
## generateCommandList
|
||||
|
||||
```php
|
||||
public function generateCommandList(): array
|
||||
```
|
||||
|
||||
### 描述
|
||||
|
||||
根据注解树生成命令信息(内部)
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| array | |
|
||||
|
||||
|
||||
## generateCommandArgumentList
|
||||
|
||||
```php
|
||||
public function generateCommandArgumentList(string $id): array
|
||||
```
|
||||
|
||||
### 描述
|
||||
|
||||
生成指定命令的参数列表
|
||||
|
||||
### 参数
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| id | string | 命令 ID |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| array | |
|
||||
@@ -100,6 +100,7 @@ public function getDataFolder(string $second): null|array|false|mixed|string
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| second | string | |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
@@ -110,7 +111,7 @@ public function getDataFolder(string $second): null|array|false|mixed|string
|
||||
## saveToJson
|
||||
|
||||
```php
|
||||
public function saveToJson(mixed $filename, mixed $file_array): false|int
|
||||
public function saveToJson(string $filename, array|int|Iterator|JsonSerializable|string|Traversable $file_array): false|int
|
||||
```
|
||||
|
||||
### 描述
|
||||
@@ -121,19 +122,20 @@ public function saveToJson(mixed $filename, mixed $file_array): false|int
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| filename | mixed | |
|
||||
| file_array | mixed | |
|
||||
| filename | string | 文件名 |
|
||||
| file_array | array|int|Iterator|JsonSerializable|string|Traversable | 文件内容数组 |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| false|int | |
|
||||
| false|int | 返回文件大小或false |
|
||||
|
||||
|
||||
## loadFromJson
|
||||
|
||||
```php
|
||||
public function loadFromJson(mixed $filename): null|mixed
|
||||
public function loadFromJson(string $filename): null|mixed
|
||||
```
|
||||
|
||||
### 描述
|
||||
@@ -144,18 +146,19 @@ public function loadFromJson(mixed $filename): null|mixed
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| filename | mixed | |
|
||||
| filename | string | 文件名 |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| null|mixed | |
|
||||
| null|mixed | 返回文件内容数据或null |
|
||||
|
||||
|
||||
## scanDirFiles
|
||||
|
||||
```php
|
||||
public function scanDirFiles(mixed $dir, bool|string $relative, bool $recursive): array|false
|
||||
public function scanDirFiles(string $dir, bool $recursive, bool|mixed|string $relative, bool $include_dir): array|false
|
||||
```
|
||||
|
||||
### 描述
|
||||
@@ -166,9 +169,11 @@ public function scanDirFiles(mixed $dir, bool|string $relative, bool $recursive)
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| dir | mixed | |
|
||||
| relative | bool|string | |
|
||||
| recursive | bool | |
|
||||
| dir | string | 目录 |
|
||||
| recursive | bool | 是否递归扫描子目录 |
|
||||
| relative | bool|mixed|string | 是否返回相对目录,如果为true则返回相对目录,如果为false则返回绝对目录 |
|
||||
| include_dir | bool | 非递归模式下,是否包含目录 |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
@@ -179,7 +184,7 @@ public function scanDirFiles(mixed $dir, bool|string $relative, bool $recursive)
|
||||
## isRelativePath
|
||||
|
||||
```php
|
||||
public function isRelativePath(mixed $path): bool
|
||||
public function isRelativePath(string $path): bool
|
||||
```
|
||||
|
||||
### 描述
|
||||
@@ -190,9 +195,33 @@ public function isRelativePath(mixed $path): bool
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| path | mixed | |
|
||||
| path | string | 路径 |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| bool | |
|
||||
| bool | 返回结果 |
|
||||
|
||||
|
||||
## createIfNotExists
|
||||
|
||||
```php
|
||||
public function createIfNotExists(string $path): void
|
||||
```
|
||||
|
||||
### 描述
|
||||
|
||||
创建目录(如果不存在)
|
||||
|
||||
### 参数
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| path | string | 目录路径 |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| void | |
|
||||
|
||||
@@ -19,6 +19,7 @@ public function parseUri(mixed $request, mixed $response, mixed $uri, mixed $nod
|
||||
| uri | mixed | |
|
||||
| node | mixed | |
|
||||
| params | mixed | |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
@@ -29,7 +30,7 @@ public function parseUri(mixed $request, mixed $response, mixed $uri, mixed $nod
|
||||
## handleStaticPage
|
||||
|
||||
```php
|
||||
public function handleStaticPage(mixed $uri, Response|\Swoole\Http\Response $response, array $settings): bool
|
||||
public function handleStaticPage(Response|\Swoole\Http\Response $response, string $uri, array $settings): bool
|
||||
```
|
||||
|
||||
### 描述
|
||||
@@ -40,9 +41,10 @@ public function handleStaticPage(mixed $uri, Response|\Swoole\Http\Response $res
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| uri | mixed | |
|
||||
| response | Response|\Swoole\Http\Response | |
|
||||
| uri | string | |
|
||||
| settings | array | |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
|
||||
@@ -35,6 +35,7 @@ public function startExecute(ZM\Annotation\Cron\Cron $v, ZM\Event\EventDispatche
|
||||
| v | ZM\Annotation\Cron\Cron | |
|
||||
| dispatcher | ZM\Event\EventDispatcher | |
|
||||
| cron | Cron\CronExpression | |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
|
||||
@@ -20,7 +20,7 @@ public function getConfiguredModules(): array
|
||||
## packModule
|
||||
|
||||
```php
|
||||
public function packModule(mixed $module): bool
|
||||
public function packModule(array $module, string $target): bool
|
||||
```
|
||||
|
||||
### 描述
|
||||
@@ -31,7 +31,9 @@ public function packModule(mixed $module): bool
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| module | mixed | |
|
||||
| module | array | 模块信息 |
|
||||
| target | string | 目标路径 |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
@@ -42,7 +44,7 @@ public function packModule(mixed $module): bool
|
||||
## unpackModule
|
||||
|
||||
```php
|
||||
public function unpackModule(mixed $module, array $options): array|false
|
||||
public function unpackModule(array|Iterator $module, array $options): array|false
|
||||
```
|
||||
|
||||
### 描述
|
||||
@@ -53,10 +55,11 @@ public function unpackModule(mixed $module, array $options): array|false
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| module | mixed | |
|
||||
| module | array|Iterator | 模块信息 |
|
||||
| options | array | |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| array|false | |
|
||||
| array|false | 返回解包的信息或false |
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
## workerAction
|
||||
|
||||
```php
|
||||
public function workerAction(mixed $src_worker_id, mixed $data): mixed
|
||||
public function workerAction(int $src_worker_id, array $data): mixed
|
||||
```
|
||||
|
||||
### 描述
|
||||
@@ -14,8 +14,9 @@ Worker 进程间通信触发的动作类型函数
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| src_worker_id | mixed | |
|
||||
| data | mixed | |
|
||||
| src_worker_id | int | 源 Worker 进程 ID |
|
||||
| data | array | 数据 |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
@@ -26,7 +27,7 @@ Worker 进程间通信触发的动作类型函数
|
||||
## sendActionToWorker
|
||||
|
||||
```php
|
||||
public function sendActionToWorker(mixed $worker_id, mixed $action, mixed $data): mixed
|
||||
public function sendActionToWorker(int $worker_id, string $action, mixed $data): mixed
|
||||
```
|
||||
|
||||
### 描述
|
||||
@@ -37,9 +38,10 @@ public function sendActionToWorker(mixed $worker_id, mixed $action, mixed $data)
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| worker_id | mixed | |
|
||||
| action | mixed | |
|
||||
| data | mixed | |
|
||||
| worker_id | int | 进程ID |
|
||||
| action | string | 动作 |
|
||||
| data | mixed | 参数 |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
## downloadCQImage
|
||||
|
||||
```php
|
||||
public function downloadCQImage(mixed $msg, null $path): array|false
|
||||
public function downloadCQImage(array|string $msg, null|string $path): array|false
|
||||
```
|
||||
|
||||
### 描述
|
||||
@@ -14,19 +14,20 @@ public function downloadCQImage(mixed $msg, null $path): array|false
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| msg | mixed | |
|
||||
| path | null | |
|
||||
| msg | array|string | 消息或消息数组 |
|
||||
| path | null|string | 保存路径 |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| array|false | |
|
||||
| array|false | 返回图片信息或失败返回false |
|
||||
|
||||
|
||||
## containsImage
|
||||
|
||||
```php
|
||||
public function containsImage(mixed $msg): bool
|
||||
public function containsImage(array|string $msg): bool
|
||||
```
|
||||
|
||||
### 描述
|
||||
@@ -37,7 +38,8 @@ public function containsImage(mixed $msg): bool
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| msg | mixed | |
|
||||
| msg | array|string | 消息或消息数组 |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
@@ -48,7 +50,7 @@ public function containsImage(mixed $msg): bool
|
||||
## getImageCQFromLocal
|
||||
|
||||
```php
|
||||
public function getImageCQFromLocal(mixed $file, int $type): string
|
||||
public function getImageCQFromLocal(string $file, int $type): string
|
||||
```
|
||||
|
||||
### 描述
|
||||
@@ -62,8 +64,9 @@ type == 2 : 返回图片的 http://xxx CQ 码(默认为 /images/ 路径就是
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| file | mixed | |
|
||||
| type | int | |
|
||||
| file | string | 文件数据 |
|
||||
| type | int | 文件类型(0,1,2可选,默认为0) |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
@@ -74,7 +77,7 @@ type == 2 : 返回图片的 http://xxx CQ 码(默认为 /images/ 路径就是
|
||||
## splitCommand
|
||||
|
||||
```php
|
||||
public function splitCommand(mixed $msg): array|string[]
|
||||
public function splitCommand(string $msg): array|string[]
|
||||
```
|
||||
|
||||
### 描述
|
||||
@@ -85,7 +88,8 @@ public function splitCommand(mixed $msg): array|string[]
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| msg | mixed | |
|
||||
| msg | string | 消息内容 |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
@@ -96,19 +100,20 @@ public function splitCommand(mixed $msg): array|string[]
|
||||
## matchCommand
|
||||
|
||||
```php
|
||||
public function matchCommand(mixed $msg, mixed $obj): ZM\Entity\MatchResult
|
||||
public function matchCommand(array|string $msg, array|Iterator $obj): ZM\Entity\MatchResult
|
||||
```
|
||||
|
||||
### 描述
|
||||
|
||||
作者很懒,什么也没有说
|
||||
根据CQCommand的规则匹配消息,获取是否匹配到对应的注解事件
|
||||
|
||||
### 参数
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| msg | mixed | |
|
||||
| obj | mixed | |
|
||||
| msg | array|string | 消息内容 |
|
||||
| obj | array|Iterator | 数据对象 |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
@@ -119,7 +124,7 @@ public function matchCommand(mixed $msg, mixed $obj): ZM\Entity\MatchResult
|
||||
## addShortCommand
|
||||
|
||||
```php
|
||||
public function addShortCommand(mixed $command, string $reply): mixed
|
||||
public function addShortCommand(string $command, string $reply): mixed
|
||||
```
|
||||
|
||||
### 描述
|
||||
@@ -130,8 +135,9 @@ public function addShortCommand(mixed $command, string $reply): mixed
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| command | mixed | |
|
||||
| reply | string | |
|
||||
| command | string | 命令内容 |
|
||||
| reply | string | 回复内容 |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
@@ -142,7 +148,7 @@ public function addShortCommand(mixed $command, string $reply): mixed
|
||||
## strToArray
|
||||
|
||||
```php
|
||||
public function strToArray(mixed $msg, false $trim_text, bool $ignore_space): array
|
||||
public function strToArray(string $msg, bool $ignore_space, bool $trim_text): array
|
||||
```
|
||||
|
||||
### 描述
|
||||
@@ -153,14 +159,15 @@ public function strToArray(mixed $msg, false $trim_text, bool $ignore_space): ar
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| msg | mixed | |
|
||||
| trim_text | false | |
|
||||
| ignore_space | bool | |
|
||||
| msg | string | 消息内容 |
|
||||
| ignore_space | bool | 是否忽略空行 |
|
||||
| trim_text | bool | 是否去除空格 |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| array | |
|
||||
| array | 返回数组 |
|
||||
|
||||
|
||||
## arrayToStr
|
||||
@@ -179,6 +186,7 @@ public function arrayToStr(array $array): string
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| array | array | |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
@@ -186,18 +194,26 @@ public function arrayToStr(array $array): string
|
||||
| string | |
|
||||
|
||||
|
||||
## generateCommandHelp
|
||||
## checkArguments
|
||||
|
||||
```php
|
||||
public function generateCommandHelp(): array
|
||||
public function checkArguments(string $class, string $method, array $match): array
|
||||
```
|
||||
|
||||
### 描述
|
||||
|
||||
根据注解树生成命令列表、帮助
|
||||
作者很懒,什么也没有说
|
||||
|
||||
### 参数
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| class | string | |
|
||||
| method | string | |
|
||||
| match | array | |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| array | 帮助信息,每个元素对应一个命令的帮助信息,格式为:命令名(其他触发条件):命令描述 |
|
||||
| array | |
|
||||
|
||||
95
docs/api/ZM/Utils/ReflectionUtil.md
Normal file
95
docs/api/ZM/Utils/ReflectionUtil.md
Normal file
@@ -0,0 +1,95 @@
|
||||
# ZM\Utils\ReflectionUtil
|
||||
|
||||
## getParameterClassName
|
||||
|
||||
```php
|
||||
public function getParameterClassName(ReflectionParameter $parameter): null|string
|
||||
```
|
||||
|
||||
### 描述
|
||||
|
||||
获取参数的类名(如有)
|
||||
|
||||
### 参数
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| parameter | ReflectionParameter | 参数 |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| null|string | 类名,如果参数不是类,返回 null |
|
||||
|
||||
|
||||
## variableToString
|
||||
|
||||
```php
|
||||
public function variableToString(mixed $var): string
|
||||
```
|
||||
|
||||
### 描述
|
||||
|
||||
将传入变量转换为字符串
|
||||
|
||||
### 参数
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| var | mixed | |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| string | |
|
||||
|
||||
|
||||
## isNonStaticMethod
|
||||
|
||||
```php
|
||||
public function isNonStaticMethod(callable|string $callback): bool
|
||||
```
|
||||
|
||||
### 描述
|
||||
|
||||
判断传入的回调是否为任意类的非静态方法
|
||||
|
||||
### 参数
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| callback | callable|string | 回调 |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| bool | |
|
||||
|
||||
|
||||
## getCallReflector
|
||||
|
||||
```php
|
||||
public function getCallReflector(callable|string $callback): ReflectionFunctionAbstract
|
||||
```
|
||||
|
||||
### 描述
|
||||
|
||||
获取传入的回调的反射实例
|
||||
如果传入的是类方法,则会返回 {@link ReflectionMethod} 实例
|
||||
否则将返回 {@link ReflectionFunction} 实例
|
||||
可传入实现了 __invoke 的类
|
||||
|
||||
### 参数
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| callback | callable|string | 回调 |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| ReflectionFunctionAbstract | |
|
||||
@@ -15,6 +15,7 @@ public function signalMaster(Swoole\Server $server): mixed
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| server | Swoole\Server | |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
@@ -42,7 +43,7 @@ public function signalManager(): mixed
|
||||
## signalWorker
|
||||
|
||||
```php
|
||||
public function signalWorker(mixed $worker_id, Swoole\Server $server): mixed
|
||||
public function signalWorker(int $worker_id, Swoole\Server $server): mixed
|
||||
```
|
||||
|
||||
### 描述
|
||||
@@ -53,8 +54,9 @@ public function signalWorker(mixed $worker_id, Swoole\Server $server): mixed
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| worker_id | mixed | |
|
||||
| worker_id | int | 当前进程的ID |
|
||||
| server | Swoole\Server | |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
|
||||
@@ -15,6 +15,7 @@ public function executeCommand(string $cmd): bool
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| cmd | string | |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
@@ -76,7 +77,7 @@ public function testlog(): mixed
|
||||
## call
|
||||
|
||||
```php
|
||||
public function call(mixed $it): mixed
|
||||
public function call(array $it): mixed
|
||||
```
|
||||
|
||||
### 描述
|
||||
@@ -87,7 +88,8 @@ public function call(mixed $it): mixed
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| it | mixed | |
|
||||
| it | array | |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
@@ -98,7 +100,7 @@ public function call(mixed $it): mixed
|
||||
## level
|
||||
|
||||
```php
|
||||
public function level(mixed $it): mixed
|
||||
public function level(array $it): mixed
|
||||
```
|
||||
|
||||
### 描述
|
||||
@@ -109,7 +111,8 @@ public function level(mixed $it): mixed
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| it | mixed | |
|
||||
| it | array | |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
@@ -120,7 +123,7 @@ public function level(mixed $it): mixed
|
||||
## bc
|
||||
|
||||
```php
|
||||
public function bc(mixed $it): mixed
|
||||
public function bc(array $it): mixed
|
||||
```
|
||||
|
||||
### 描述
|
||||
@@ -131,7 +134,8 @@ public function bc(mixed $it): mixed
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| it | mixed | |
|
||||
| it | array | |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
@@ -142,7 +146,7 @@ public function bc(mixed $it): mixed
|
||||
## echoI
|
||||
|
||||
```php
|
||||
public function echoI(mixed $it): mixed
|
||||
public function echoI(array $it): mixed
|
||||
```
|
||||
|
||||
### 描述
|
||||
@@ -153,7 +157,8 @@ public function echoI(mixed $it): mixed
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| it | mixed | |
|
||||
| it | array | |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
|
||||
@@ -3,13 +3,19 @@
|
||||
## stop
|
||||
|
||||
```php
|
||||
public function stop(): mixed
|
||||
public function stop(mixed $error_exit): mixed
|
||||
```
|
||||
|
||||
### 描述
|
||||
|
||||
作者很懒,什么也没有说
|
||||
|
||||
### 参数
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| error_exit | mixed | |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
@@ -54,7 +60,7 @@ public function getReloadableFiles(): string[]|string[][]
|
||||
## getClassesPsr4
|
||||
|
||||
```php
|
||||
public function getClassesPsr4(mixed $dir, mixed $base_namespace, null|mixed $rule, bool $return_path_value): string[]
|
||||
public function getClassesPsr4(string $dir, string $base_namespace, null|mixed $rule, bool|string $return_path_value): string[]
|
||||
```
|
||||
|
||||
### 描述
|
||||
@@ -65,10 +71,11 @@ public function getClassesPsr4(mixed $dir, mixed $base_namespace, null|mixed $ru
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| dir | mixed | |
|
||||
| base_namespace | mixed | |
|
||||
| rule | null|mixed | |
|
||||
| return_path_value | bool | |
|
||||
| dir | string | 目录 |
|
||||
| base_namespace | string | 基础命名空间 |
|
||||
| rule | null|mixed | 规则 |
|
||||
| return_path_value | bool|string | 是否返回文件路径,返回文件路径的话传入字符串 |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
|
||||
@@ -1,9 +1,55 @@
|
||||
# ZM\ZMServer
|
||||
|
||||
## getAppName
|
||||
## __construct
|
||||
|
||||
```php
|
||||
public function getAppName(): mixed
|
||||
public function __construct(string $app_name): mixed
|
||||
```
|
||||
|
||||
### 描述
|
||||
|
||||
作者很懒,什么也没有说
|
||||
|
||||
### 参数
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| app_name | string | App名称 |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| mixed | |
|
||||
|
||||
|
||||
## addModule
|
||||
|
||||
```php
|
||||
public function addModule(mixed $module_class): mixed
|
||||
```
|
||||
|
||||
### 描述
|
||||
|
||||
作者很懒,什么也没有说
|
||||
|
||||
### 参数
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| module_class | mixed | |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| mixed | |
|
||||
|
||||
|
||||
## run
|
||||
|
||||
```php
|
||||
public function run(): mixed
|
||||
```
|
||||
|
||||
### 描述
|
||||
|
||||
@@ -54,10 +54,12 @@ DataProvider::getDataFolder("TestModule"); // 例如返回 /root/zhamao-framewor
|
||||
|
||||
递归或非递归扫描目录,返回相对目录的文件列表或绝对目录的文件列表。(非常好用)
|
||||
|
||||
定义:`scanDirFiles($dir, $recursive = true, $relative = false)`
|
||||
定义:`scanDirFiles($dir, $recursive = true, $relative = false, $include_dir = false)`
|
||||
|
||||
`$dir` 为要扫描的目录,`$recursive` 为是否递归,`$relative` 为是否返回相对目录的文件列表。
|
||||
|
||||
`$include_dir` 只有在 `$recursive === false` 的情况才生效,当 `$include_dir` 为 `true` 时,返回的非递归文件列表会包含目录,否则只包含文件。
|
||||
|
||||
从给定的目录下开始遍历整个目录,如果将 `$recursive` 设置为 `true`,则会递归扫描子目录,否则将返回包含目录的文件列表。
|
||||
|
||||
如果将 `$relative` 设置为 `true`,则会返回文件列表的相对路径,否则返回绝对路径。
|
||||
|
||||
@@ -262,6 +262,22 @@
|
||||
|
||||
无。
|
||||
|
||||
## OnSave()
|
||||
|
||||
框架退出和每 15 分钟在 Worker #0 执行的代码。建议这里用来编写内存数据持久化的代码,如将 WorkerCache、内存全局变量存到文件。
|
||||
|
||||
| 类型 | 值 |
|
||||
| ---------- | ------------------------------ |
|
||||
| 名称 | `@OnSetup` |
|
||||
| 触发前提 | 每 15 分钟或 Ctrl+C、`server:stop` 等方式退出框架时 |
|
||||
| 命名空间 | `ZM\Annotation\Swoole\OnSave` |
|
||||
| 适用位置 | 方法 |
|
||||
| 返回值处理 | 无 |
|
||||
|
||||
### 注解参数
|
||||
|
||||
无。
|
||||
|
||||
## TerminalCommand()
|
||||
|
||||
添加一个远程终端的自定义命令。(2.4.0 版本起可用)
|
||||
@@ -430,4 +446,4 @@ public function onCrawl() {
|
||||
## 示例6(创建一个远程终端命令并调试框架)
|
||||
|
||||
> 开个坑,以后填。(__填坑标记__)
|
||||
>
|
||||
>
|
||||
|
||||
@@ -212,10 +212,10 @@ class Hello {
|
||||
|
||||
| 参数名称 | 参数范围 | 用途 | 默认 |
|
||||
| ----------- | ------------------------------------ | ------------------------------------------------------------ | ---- |
|
||||
| notice_type | `string`,支持填入 onebot 标准的内容 | 限定通知事件的类型,见 [OneBot - 通知事件](https://github.com/howmanybots/onebot/blob/master/v11/specs/event/notice.md) | 空 |
|
||||
| user_id | `int64` 或 `string` | 限定通知事件用户 ID(QQ 号),同上见 [OneBot - 通知事件](https://github.com/howmanybots/onebot/blob/master/v11/specs/event/notice.md) | 空 |
|
||||
| group_id | `int64` 或 `string` | 限定通知事件群 ID(QQ 群号),同上见 [OneBot - 通知事件](https://github.com/howmanybots/onebot/blob/master/v11/specs/event/notice.md) | 空 |
|
||||
| operator_id | `int64` 或 `string` | 限定操作者 QQ 号,同上见 [OneBot - 通知事件](https://github.com/howmanybots/onebot/blob/master/v11/specs/event/notice.md) | 空 |
|
||||
| notice_type | `string`,支持填入 onebot 标准的内容 | 限定通知事件的类型,见 [OneBot - 通知事件](https://github.com/botuniverse/onebot-11/blob/master/event/notice.md) | 空 |
|
||||
| user_id | `int64` 或 `string` | 限定通知事件用户 ID(QQ 号),同上见 [OneBot - 通知事件](https://github.com/botuniverse/onebot-11/blob/master/event/notice.md) | 空 |
|
||||
| group_id | `int64` 或 `string` | 限定通知事件群 ID(QQ 群号),同上见 [OneBot - 通知事件](https://github.com/botuniverse/onebot-11/blob/master/event/notice.md) | 空 |
|
||||
| operator_id | `int64` 或 `string` | 限定操作者 QQ 号,同上见 [OneBot - 通知事件](https://github.com/botuniverse/onebot-11/blob/master/event/notice.md) | 空 |
|
||||
| level | `int` | 事件优先级(越大越靠前) | 20 |
|
||||
|
||||
### 用法
|
||||
@@ -240,10 +240,10 @@ TODO:先放着,有时间再更。
|
||||
|
||||
| 参数名称 | 参数范围 | 用途 | 默认 |
|
||||
| ------------ | ------------------------------------ | ------------------------------------------------------------ | ---- |
|
||||
| request_type | `string`,支持填入 onebot 标准的内容 | 限定请求事件的类型,见 [OneBot - 请求事件](https://github.com/howmanybots/onebot/blob/master/v11/specs/event/request.md) | 空 |
|
||||
| user_id | `int64` 或 `string` | 限定请求事件当事人用户 ID(QQ 号),见 [OneBot - 请求事件](https://github.com/howmanybots/onebot/blob/master/v11/specs/event/request.md) | 空 |
|
||||
| sub_type | `string` | 限定请求事件来源群 ID(QQ 群号),见 [OneBot - 请求事件](https://github.com/howmanybots/onebot/blob/master/v11/specs/event/request.md) | 空 |
|
||||
| comment | `string` | 限定验证消息内容,见 [OneBot - 请求事件](https://github.com/howmanybots/onebot/blob/master/v11/specs/event/request.md) | 空 |
|
||||
| request_type | `string`,支持填入 onebot 标准的内容 | 限定请求事件的类型,见 [OneBot - 请求事件](https://github.com/botuniverse/onebot-11/blob/master/event/request.md) | 空 |
|
||||
| user_id | `int64` 或 `string` | 限定请求事件当事人用户 ID(QQ 号),见 [OneBot - 请求事件](https://github.com/botuniverse/onebot-11/blob/master/event/request.md) | 空 |
|
||||
| sub_type | `string` | 限定请求事件来源群 ID(QQ 群号),见 [OneBot - 请求事件](https://github.com/botuniverse/onebot-11/blob/master/event/request.md) | 空 |
|
||||
| comment | `string` | 限定验证消息内容,见 [OneBot - 请求事件](https://github.com/botuniverse/onebot-11/blob/master/event/request.md) | 空 |
|
||||
| level | `int` | 事件优先级(越大越靠前) | 20 |
|
||||
|
||||
### 用法
|
||||
@@ -268,7 +268,7 @@ TODO:先放着,有时间再更。
|
||||
|
||||
| 参数名称 | 参数范围 | 用途 | 默认 |
|
||||
| --------------- | ------------------ | ------------------------------------------------------------ | ---- |
|
||||
| meta_event_type | `string`,**必需** | 限定元事件的类型,见 [OneBot - 元事件](https://github.com/howmanybots/onebot/blob/master/v11/specs/event/meta.md) | |
|
||||
| meta_event_type | `string`,**必需** | 限定元事件的类型,见 [OneBot - 元事件]([OneBot - 请求事件](https://github.com/botuniverse/onebot-11/blob/master/event/meta.md)) | |
|
||||
| level | `int` | 事件优先级(越大越靠前) | 20 |
|
||||
|
||||
### 用法
|
||||
|
||||
@@ -177,7 +177,13 @@ public function testUrl() {
|
||||
|
||||
如果想要设置允许请求控制器的 HTTP 请求方式,可以使用方法在控制器中的 `@RequestMapping` 注解配置 `method` 参数,可以是 `GET`,`POST`,`PUT`, `PATCH`,`DELETE`,`OPTIONS`,`HEAD` 中的一个或多个。
|
||||
|
||||
- 限定 HTTP 方法:`@RequestMapping(method="GET")`,`@RequestMapping(method={"GET","POST"})`
|
||||
- 限定 HTTP 方法:`@RequestMapping(request_method="GET")`,`@RequestMapping(request_method={"GET","POST"})`
|
||||
|
||||
::: warning 注意
|
||||
|
||||
此处是 `request_method`,而不是 `method`,因为炸毛框架的注解 `method` 是保留属性,写错会出现问题。
|
||||
|
||||
:::
|
||||
|
||||
## 静态文件服务器
|
||||
|
||||
@@ -225,10 +231,10 @@ $config['static_file_server'] = [
|
||||
```php
|
||||
/**
|
||||
* @RequestMapping("/images/{filename}")
|
||||
* @param $param
|
||||
* @param array $param
|
||||
* @return StaticFileHandler
|
||||
*/
|
||||
public function staticImage($param) {
|
||||
public function staticImage(array $param) {
|
||||
Console::info("[下载图片] " . $param["filename"]);
|
||||
return new StaticFileHandler($param["filename"], "/path/to/your/image_dir/");
|
||||
}
|
||||
|
||||
@@ -78,4 +78,5 @@
|
||||
| E00074 | 参数非法 | 检查调用的参数是否正常(此处可能有多处问题,请看具体调用栈炸掉的地方) |
|
||||
| E00075 | Cron表达式非法 | 检查 @Cron 中的表达式是否书写格式正确 |
|
||||
| E00076 | Cron检查间隔非法 | 检查 @Cron 中的检查间隔(毫秒)是否在1000-60000之间 |
|
||||
| E00077 | 输入了非法的消息匹配参数类型 | 检查传入 `@CommandArgument` 或 `checkArguments()` 方法有没有传入非法的 `type` 参数 |
|
||||
| E99999 | 未知错误 | |
|
||||
|
||||
@@ -6,21 +6,15 @@
|
||||
|
||||
## 一键下载静态 PHP 环境和框架脚手架
|
||||
|
||||
从 2.4.4 版本起,炸毛框架支持一键拉取一个静态的 PHP 运行时和脚手架,只需运行下面的脚本即可。(开发环境推荐此方法)
|
||||
从 2.4.4 版本起,炸毛框架支持一键拉取一个静态的 PHP 运行时和脚手架(如果本机内安装的 PHP 已符合要求,则不安装),只需运行下面的脚本即可。
|
||||
|
||||
```bash
|
||||
# 将会把 PHP、框架都安装在此目录下
|
||||
mkdir zhamao-app/ # 这里可以取自己的项目名字
|
||||
cd zhamao-app/
|
||||
bash -c "$(curl -fsSL https://api.zhamao.xin/go.sh)"
|
||||
bash <(curl -fsSL https://zhamao.xin/go.sh)
|
||||
|
||||
# 安装完成后的启动框架命令(2.5.0 版本后可省略掉 runtime/php 前缀)
|
||||
vendor/bin/start server
|
||||
|
||||
# 扩展用法:使用静态 PHP 版本的 Composer update
|
||||
runtime/composer update
|
||||
# 扩展用法:使用静态 PHP 运行别的 CLI 脚本
|
||||
runtime/php path/to/your/script.php
|
||||
cd zhamao-app
|
||||
./zhamao server
|
||||
```
|
||||
|
||||
> 有关静态 PHP 的多种用法(如 Composer),见 [进阶 - PHP 环境高级](/advanced/php-env)
|
||||
@@ -80,3 +74,15 @@ $ vendor/bin/start server
|
||||
|
||||
## 进阶环境部署和开发
|
||||
炸毛框架还支持更多种启动方式,如源码模式、守护进程模式,具体后续有关环境和部署的进阶教程,请查看 [进阶开发](/advanced/) 部分!
|
||||
|
||||
## Windows 注意事项
|
||||
|
||||
由于 Swoole 扩展目前无法原生支持 Windows 环境的 PHP,所以以上方式都是默认在 Linux、macOS 系统下的命令。
|
||||
|
||||
如果需要在 Windows 上开发和运行,可以使用 WSL(1 和 2 均可)、Linux 虚拟机、Docker 或 cygwin。
|
||||
|
||||
如果使用 WSL、虚拟机或 Docker,方式可以直接参考上方相关命令。如果使用 cygwin,可先从 [Swoole 官方仓库](https://github.com/swoole/swoole-src) 下载 swoole 的 cygwin 构建版本,然后下载 Composer 后安装依赖,直接运行框架即可。
|
||||
|
||||
## macOS 注意事项
|
||||
|
||||
macOS 理论上运行环境和 Linux 无异,但 macOS 由于不能静态编译,所以不能使用静态编译的 PHP 直接运行,需自行从 `Homebrew` 下载最新版 PHP(命令 `brew install php`),然后使用命令 `pecl install swoole` 来安装 Swoole 后运行框架。
|
||||
|
||||
@@ -4,6 +4,125 @@
|
||||
|
||||
同时此处将只使用 build 版本号进行区分。
|
||||
|
||||
## build 478 (2022-8-7)
|
||||
|
||||
- 修复 `zm_sleep()` 无法传入小数的 Bug (#141)
|
||||
|
||||
## build 477 (2022-8-5)
|
||||
|
||||
- 修复了 `@CQNotice`、`@CQRequest` 注解无法正常激活的 Bug (#140)
|
||||
|
||||
## build 476 (2022-8-3)
|
||||
|
||||
- `DataProvider::scanDirFiles()` 新增参数 `$include_dir`,用于控制非递归模式下是否包含目录
|
||||
|
||||
## build 475 (2022-7-3)
|
||||
|
||||
- 修复 `match_args` 全局方法对于 `0` 字符串处理的 Bug(#136)
|
||||
|
||||
## build 474 (2022-5-21)
|
||||
|
||||
- 修复 WebSocket 连接时报错的 Bug
|
||||
|
||||
## build 473 (2022-5-7)
|
||||
|
||||
- 修复 `server:stop` 命令下部分情况报错的问题
|
||||
|
||||
## build 472 (2022-5-6)
|
||||
|
||||
- 修复 Container 环境继承全局变量的问题
|
||||
|
||||
## build 471 (2022-5-5)
|
||||
|
||||
- 修复 `CQ::encode()` 无法传入 `int` 的强类型解析问题(#113)
|
||||
- (内部)重构 CQ 类
|
||||
- 新增启动命令参数 `--audit-mode`,用于单次审计模式
|
||||
- 修复 `EventMapIterator` 对 PHP 8.1 的兼容性问题
|
||||
- 修复 #95 中提到的无输入流时报错的问题
|
||||
- 新增部分不可执行脚本的防呆退出功能
|
||||
- 修复 `ZMServer` 中的 typo
|
||||
|
||||
## build 470 (2022-5-4)
|
||||
|
||||
- 重构帮助生成器,将帮助生成器重构为 `CommandInfoUtil` 类
|
||||
|
||||
## build 469 (2022-5-3)
|
||||
|
||||
- 新增 `@CommandArgument` 注解,可直接通过注解添加聊天机器人命令参数
|
||||
- 修改默认 Hello 模块下随机数功能为采用 `@CommandArgument` 注解模式
|
||||
- (内部)新增 `EventManager::$event_map`,用于补充对事件对象遍历的方式
|
||||
- 新增 `EventMapIterator` 类,用于遍历注解事件对象
|
||||
- 新增 `MessageUtil::checkArguments()` 方法,用于检查 `@CommandArgument` 注解
|
||||
|
||||
## build 468 (2022-4-30)
|
||||
|
||||
- 优化单元测试流程
|
||||
- 优化上下文对象,在非协程环境下不再会抛出异常或返回 null
|
||||
|
||||
## build 467 (2022-4-29)
|
||||
|
||||
- 优化 `@RequestMapping` 注解事件的方法返回值处理,支持数组和字符串(数组自动转为 JSON 格式)
|
||||
|
||||
## build 466 (2022-4-29)
|
||||
|
||||
- 优化容器支持无名顺序参数的调用
|
||||
- 优化静态路由,支持 64 以上长度的路由
|
||||
|
||||
## build 464 (2022-4-28)
|
||||
|
||||
- 重构全局方法 `match_pattern()`,优化性能以及解决部分字符串不能匹配的 Bug
|
||||
|
||||
## build 463 (2022-4-16)
|
||||
|
||||
- 新增链式调用全局方法 `chain()`
|
||||
- 新增函数执行时间工具全局函数 `stopwatch()`
|
||||
|
||||
## build 462 (2022-4-15)
|
||||
|
||||
- 新增依赖注入、容器支持,目前对 Swoole 事件、机器人事件均支持使用依赖注入
|
||||
- 新增全局容器方法 `container()`、`resolve()`、`app()`,用于获取容器参数等
|
||||
- 新增相关容器测试
|
||||
|
||||
## build 461 (2022-4-11)
|
||||
|
||||
- 新增 AllBotsProxy、AllGroupsProxy 代理类,支持批量发送机器人动作
|
||||
- 新增全局函数 `implode_when_necessary()`,用于将可能为数组的参数转换为字符串
|
||||
|
||||
## build 460 (2022-4-3)
|
||||
|
||||
- 优化代码到 phpstan-level-4
|
||||
|
||||
## build 459 (2022-4-3)
|
||||
|
||||
- 优化代码到 phpstan-level-2
|
||||
|
||||
## build 458 (2022-4-3)
|
||||
|
||||
- 优化代码到 phpstan-level-1
|
||||
- 优化 `module:xxx` 类命令的有关实现代码
|
||||
|
||||
## build 457 (2022-4-2)
|
||||
|
||||
- 新增和优化测试用例(具体见文件)
|
||||
- 部分文件以 PHPStan Level 2 进行规范化
|
||||
|
||||
## build 456 (2022-3-30)
|
||||
|
||||
- 重构 phpunit-swoole,使其可以正常使用
|
||||
- 新增 `--private-mode` 参数,用于隐藏启动前的 MOTD 及敏感信息
|
||||
- 修复 Composer extra 配置项 `zm.exclude-annotation-path` 不能正常工作的 Bug
|
||||
- 优化注解事件加载器,防止 Master 进程中添加的事件在 Worker 中被覆盖的问题
|
||||
- 修复 `DataProvider::isRelativePath()` 方法判断有误的 Bug
|
||||
- 新增退出框架时支持以非 0 exit code 退出的功能
|
||||
- 优化 `ZMUtil::getClassesPsr4()` 方法,排除不含类的文件
|
||||
- 优化 PHP CS Fixer 的配置
|
||||
- 新增测试用例(具体见文件)
|
||||
|
||||
## build 455 (2022-3-27)
|
||||
|
||||
- 修复前几个小版本无法收发消息的 Bug
|
||||
- 新增 API Document 自动生成脚本
|
||||
|
||||
## build 454 (2022-3-27)
|
||||
|
||||
- 修复部分命令下无法杀掉进程的 Bug
|
||||
|
||||
@@ -1,5 +1,84 @@
|
||||
# 更新日志(v2 版本)
|
||||
|
||||
## v2.8.4(build 478)
|
||||
|
||||
> 更新时间:2022.8.7
|
||||
|
||||
- 修复 `zm_sleep()` 无法传入小数的 Bug (#141)
|
||||
|
||||
## v2.8.3(build 477)
|
||||
|
||||
> 更新时间:2022.8.5
|
||||
|
||||
- 修复了 `@CQNotice`、`@CQRequest` 注解无法正常激活的 Bug (#140)
|
||||
|
||||
## v2.8.2(build 476)
|
||||
|
||||
> 更新时间:2022.8.3
|
||||
|
||||
- `DataProvider::scanDirFiles()` 新增参数 `$include_dir`,用于控制非递归模式下是否包含目录
|
||||
|
||||
## v2.8.1(build 475)
|
||||
|
||||
> 更新时间:2022.7.3
|
||||
|
||||
- 修复 WebSocket 连接时报错的 Bug
|
||||
- 修复 `match_args` 全局方法对于 `0` 字符串处理的 Bug(#136)
|
||||
|
||||
## v2.8.0(build 473)
|
||||
|
||||
> 更新时间:2022.5.7
|
||||
|
||||
- 新增 AllBotsProxy、AllGroupsProxy 代理类,支持批量发送机器人动作
|
||||
- 新增全局函数 `implode_when_necessary()`,用于将可能为数组的参数转换为字符串
|
||||
- 新增依赖注入、容器支持,目前对 Swoole 事件、机器人事件均支持使用依赖注入
|
||||
- 新增全局容器方法 `container()`、`resolve()`、`app()`,用于获取容器参数等
|
||||
- 新增相关容器测试
|
||||
- 新增链式调用全局方法 `chain()`
|
||||
- 新增函数执行时间工具全局函数 `stopwatch()`
|
||||
- 新增 `@CommandArgument` 注解,可直接通过注解添加聊天机器人命令参数
|
||||
- (内部)新增 `EventManager::$event_map`,用于补充对事件对象遍历的方式
|
||||
- 新增 `EventMapIterator` 类,用于遍历注解事件对象
|
||||
- 新增 `MessageUtil::checkArguments()` 方法,用于检查 `@CommandArgument` 注解
|
||||
- 新增启动命令参数 `--audit-mode`,用于单次审计模式
|
||||
- 新增部分不可执行脚本的防呆退出功能
|
||||
- 重构全局方法 `match_pattern()`,优化性能以及解决部分字符串不能匹配的 Bug
|
||||
- 优化容器支持无名顺序参数的调用
|
||||
- 优化静态路由,支持 64 以上长度的路由
|
||||
- 优化 `@RequestMapping` 注解事件的方法返回值处理,支持数组和字符串(数组自动转为 JSON 格式)
|
||||
- 优化单元测试流程
|
||||
- 优化上下文对象,在非协程环境下不再会抛出异常或返回 null
|
||||
- 修改默认 Hello 模块下随机数功能为采用 `@CommandArgument` 注解模式
|
||||
- 重构帮助生成器,将帮助生成器重构为 `CommandInfoUtil` 类
|
||||
- 修复 `CQ::encode()` 无法传入 `int` 的强类型解析问题(#113)
|
||||
- (内部)重构 CQ 类
|
||||
- 修复 `EventMapIterator` 对 PHP 8.1 的兼容性问题
|
||||
- 修复 #95 中提到的无输入流时报错的问题
|
||||
- 修复 `ZMServer` 中的 typo
|
||||
- 修复 Container 环境继承全局变量的问题
|
||||
- 修复 `server:stop` 命令下部分情况报错的问题
|
||||
|
||||
## v2.7.6(build 460)
|
||||
|
||||
> 更新时间:2022.4.3
|
||||
|
||||
- 重构 phpunit-swoole,使其可以正常使用
|
||||
- 新增 `--private-mode` 参数,用于隐藏启动前的 MOTD 及敏感信息
|
||||
- 修复 Composer extra 配置项 `zm.exclude-annotation-path` 不能正常工作的 Bug
|
||||
- 优化注解事件加载器,防止 Master 进程中添加的事件在 Worker 中被覆盖的问题
|
||||
- 修复 `DataProvider::isRelativePath()` 方法判断有误的 Bug
|
||||
- 新增退出框架时支持以非 0 exit code 退出的功能
|
||||
- 优化 `ZMUtil::getClassesPsr4()` 方法,排除不含类的文件
|
||||
- 优化 `module:xxx` 类命令的有关实现代码
|
||||
- 优化代码到 phpstan-level-4
|
||||
|
||||
## v2.7.5(build 455)
|
||||
|
||||
> 更新时间:2022.3.27
|
||||
|
||||
- 修复前几个小版本无法收发消息的 Bug
|
||||
- 新增 API Document 自动生成脚本
|
||||
|
||||
## v2.7.4(build 454)
|
||||
|
||||
> 更新时间:2022.3.27
|
||||
|
||||
267
ext/go.sh
Executable file
267
ext/go.sh
Executable file
@@ -0,0 +1,267 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# 支持的环境变量:
|
||||
# ZM_DOWN_PHP_VERSION php版本,默认为8.0
|
||||
# ZM_NO_LOCAL_PHP 如果填入任意内容,则不检查本地PHP,直接安装内建PHP(仅限Linux)
|
||||
# ZM_TEMP_DIR 脚本下载内建PHP和Composer的临时目录,默认为/tmp/.zm-runtime
|
||||
# ZM_CUSTOM_DIR 自定义新建目录名称,默认为zhamao-app
|
||||
# ZM_COMPOSER_PACKAGIST 是否使用Composer的国外源,默认使用国内阿里云,如果设置并填写了内容,则自动使用Composer的国外源
|
||||
|
||||
ZM_PWD=$(pwd)
|
||||
_cyan="\033[0;36m"
|
||||
_reset="\033[0m"
|
||||
|
||||
# 彩头
|
||||
function nhead() {
|
||||
if [ "$1" = "red" ]; then
|
||||
echo -ne "\033[0;31m[!]"
|
||||
elif [ "$1" = "yellow" ]; then
|
||||
echo -ne "\033[0;33m[?]"
|
||||
else
|
||||
echo -ne "\033[0;32m[*]"
|
||||
fi
|
||||
echo -e "\033[0m"
|
||||
}
|
||||
|
||||
# 下载文件 $1 到目录 $2,自动选择使用 curl 或者 wget
|
||||
function download_file() {
|
||||
downloader="wget"
|
||||
type wget >/dev/null 2>&1 || { downloader="curl"; }
|
||||
if [ "$downloader" = "wget" ]; then
|
||||
_down_prefix="O"
|
||||
else
|
||||
_down_prefix="o"
|
||||
fi
|
||||
_down_symbol=0
|
||||
if [ ! -f "$2" ]; then
|
||||
echo -ne "$(nhead) 正在下载 $1 ... "
|
||||
$downloader "$1" -$_down_prefix "$2" >/dev/null 2>&1 && echo "完成!" && _down_symbol=1
|
||||
else
|
||||
echo "已存在!" && _down_symbol=1
|
||||
fi
|
||||
if [ $_down_symbol == 0 ]; then
|
||||
echo "$(nhead red) 下载失败!请检查网络连接!"
|
||||
rm -rf "$2"
|
||||
return 1
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
# 安装下载内建PHP
|
||||
function install_native_php() {
|
||||
ZM_PHP_VERSION="8.0"
|
||||
if [ "$ZM_DOWN_PHP_VERSION" != "" ]; then
|
||||
ZM_PHP_VERSION="$ZM_DOWN_PHP_VERSION"
|
||||
fi
|
||||
echo "$(nhead) 使用的内建 PHP 版本: $ZM_PHP_VERSION"
|
||||
|
||||
rm -rf "$ZM_TEMP_DIR"
|
||||
mkdir "$ZM_TEMP_DIR" >/dev/null 2>&1
|
||||
if [ ! -f "$ZM_TEMP_DIR/php" ]; then
|
||||
download_file "https://dl.zhamao.xin/php-bin/down.php?php_ver=$ZM_PHP_VERSION&arch=$(uname -m)" "$ZM_TEMP_DIR/php.tgz" || return 1
|
||||
tar -xf "$ZM_TEMP_DIR/php.tgz" -C "$ZM_TEMP_DIR/" && rm -rf "$ZM_TEMP_DIR/php.tgz"
|
||||
fi
|
||||
echo "$(nhead) 安装内建 PHP 完成!"
|
||||
php_executable="$ZM_TEMP_DIR/php"
|
||||
return 0
|
||||
}
|
||||
|
||||
# 安装下载Composer
|
||||
function install_native_composer() {
|
||||
if [ ! -f "$ZM_TEMP_DIR/composer.phar" ]; then
|
||||
# 下载 composer.phar
|
||||
download_file "https://mirrors.aliyun.com/composer/composer.phar" "$ZM_TEMP_DIR/composer.phar" || return 1
|
||||
if [ "$php_executable" = "$ZM_TEMP_DIR/php" ]; then
|
||||
# shellcheck disable=SC2016
|
||||
txt='#!/usr/bin/env sh
|
||||
if [ -f "$(dirname $0)/php" ]; then
|
||||
"$(dirname $0)/php" "$(dirname $0)/composer.phar" $*
|
||||
else
|
||||
php "$(dirname $0)/composer.phar" $*
|
||||
fi'
|
||||
echo "$txt" >"$ZM_TEMP_DIR/composer"
|
||||
chmod +x "$ZM_TEMP_DIR/composer"
|
||||
else
|
||||
mv "$ZM_TEMP_DIR/composer.phar" "$ZM_TEMP_DIR/composer" && chmod +x "$ZM_TEMP_DIR/composer"
|
||||
fi
|
||||
fi
|
||||
echo "$(nhead) 安装内建 Composer 完成!"
|
||||
composer_executable="$ZM_TEMP_DIR/composer"
|
||||
return 0
|
||||
}
|
||||
|
||||
# 检查Composer可用性
|
||||
function composer_check() {
|
||||
# 顺带检查一下
|
||||
echo "$(nhead) 正在检查 Git、unzip、7z 能否正常使用 ... "
|
||||
type git >/dev/null 2>&1 || {
|
||||
echo "$(nhead red) 检测到系统不存在 git 命令,可能无法正常使用 Composer 下载 GitHub 等仓库项目!"
|
||||
}
|
||||
zip_check_symbol=0
|
||||
if type unzip >/dev/null 2>&1; then
|
||||
zip_check_symbol=1
|
||||
fi
|
||||
if type 7z >/dev/null 2>&1; then
|
||||
zip_check_symbol=1
|
||||
fi
|
||||
if [ $zip_check_symbol -eq 0 ]; then
|
||||
if [ "$($php_executable -m | grep zip)" = "" ]; then
|
||||
echo "$(nhead red) 检测到系统不存在 unzip 或 7z 命令,PHP 不存在 zip 扩展,可能无法正常使用 Composer 下载压缩包项目!"
|
||||
fi
|
||||
fi
|
||||
|
||||
# 测试 Composer 和 PHP 是否能正常使用
|
||||
if [ "$("$composer_executable" -n about | grep Manager)" = "" ]; then
|
||||
echo "$(nhead red) Download PHP binary and composer failed!"
|
||||
return 1
|
||||
fi
|
||||
echo "$(nhead) 环境检查完成!"
|
||||
return 0
|
||||
}
|
||||
|
||||
# 环境检查
|
||||
function darwin_env_check() {
|
||||
echo -ne "$(nhead) 检查是否存在 PHP ... "
|
||||
if type php >/dev/null 2>&1; then
|
||||
php_executable=$(which php)
|
||||
echo "位置:$php_executable"
|
||||
if [ "$($php_executable -m | grep swoole)" = "" ]; then
|
||||
echo "$(nhead red) PHP 不存在 swoole 扩展,可能无法正常使用 Swoole 框架!" && return 1
|
||||
fi
|
||||
else
|
||||
echo "不存在"
|
||||
if type brew >/dev/null 2>&1; then
|
||||
echo -n "$(nhead yellow) 是否使用 Homebrew 安装 PHP?[y/N] "
|
||||
read -r y
|
||||
if [ "$y" = "" ]; then y="N"; fi
|
||||
if [ "$y" = "y" ]; then
|
||||
brew install php || echo "$(nhead red) 安装 PHP 失败!" && return 1
|
||||
else
|
||||
echo "$(nhead red) 跳过安装 PHP!" && return 1
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
echo -ne "$(nhead) 检查是否存在 Composer ... "
|
||||
if type composer >/dev/null 2>&1; then
|
||||
composer_executable=$(which composer)
|
||||
echo "位置:$composer_executable"
|
||||
else
|
||||
echo "不存在,正在下载 Composer ..."
|
||||
install_native_composer || return 1
|
||||
fi
|
||||
|
||||
composer_check || return 1
|
||||
}
|
||||
|
||||
# 询问是否安装 native php
|
||||
function prompt_install_native_php() {
|
||||
echo -ne "$(nhead yellow) 检测到系统的 PHP 不存在 swoole 扩展,是否下载安装独立的内建 PHP 和 Composer?[Y/n] "
|
||||
read -r y
|
||||
case $y in
|
||||
Y|y|"") return 0 ;;
|
||||
*) echo "$(nhead red) 跳过安装内建 PHP!" && return 1 ;;
|
||||
esac
|
||||
}
|
||||
|
||||
# 环境检查
|
||||
function linux_env_check() {
|
||||
if [ "$ZM_NO_LOCAL_PHP" != "" ]; then # 如果指定了不使用本地 php,则不检查,直接下载
|
||||
install_native_php && install_native_composer && composer_check && return 0 || return 1
|
||||
else
|
||||
echo -ne "$(nhead) 检查是否存在 PHP ... "
|
||||
if type php >/dev/null 2>&1; then
|
||||
php_executable=$(which php)
|
||||
echo "位置:$php_executable"
|
||||
if [ "$($php_executable -m | grep swoole)" = "" ]; then
|
||||
echo "$(nhead red) PHP 不存在 swoole 扩展,可能无法正常使用 Swoole 框架!" && \
|
||||
prompt_install_native_php && \
|
||||
install_native_php && \
|
||||
install_native_composer && composer_check && return 0 || return 1
|
||||
fi
|
||||
else
|
||||
echo "不存在,将下载内建 PHP"
|
||||
install_native_php || return 1
|
||||
fi
|
||||
fi
|
||||
|
||||
echo -ne "$(nhead) 检查是否存在 Composer ... "
|
||||
if type composer >/dev/null 2>&1; then
|
||||
composer_executable=$(which composer)
|
||||
echo "位置:$composer_executable"
|
||||
else
|
||||
echo "不存在,将下载内建 Composer"
|
||||
install_native_composer || return 1
|
||||
fi
|
||||
|
||||
composer_check || return 1
|
||||
}
|
||||
|
||||
function if_use_aliyun() {
|
||||
if [ "$ZM_COMPOSER_PACKAGIST" = "" ]; then
|
||||
$composer_executable -n config repos.packagist composer https://mirrors.aliyun.com/composer
|
||||
fi
|
||||
}
|
||||
|
||||
function if_restore_native_runtime() {
|
||||
ZM_RUNTIME_DIR="$ZM_PWD/$ZM_CUSTOM_DIR/runtime/"
|
||||
if [ "$php_executable" = "$ZM_TEMP_DIR/php" ]; then
|
||||
echo "$(nhead) 移动内建 PHP 到框架目录 $ZM_RUNTIME_DIR ..." && \
|
||||
mkdir -p "$ZM_RUNTIME_DIR" && \
|
||||
mv "$ZM_TEMP_DIR/php" "$ZM_RUNTIME_DIR" || {
|
||||
echo "$(nhead red) 移动内建 PHP 到框架目录失败!" && return 1
|
||||
}
|
||||
php_executable="$ZM_RUNTIME_DIR/php"
|
||||
fi
|
||||
if [ "$composer_executable" = "$ZM_TEMP_DIR/composer" ]; then
|
||||
echo "$(nhead) 移动内建 Composer 到框架目录 $ZM_RUNTIME_DIR ..." && \
|
||||
mkdir -p "$ZM_CUSTOM_DIR/runtime" && \
|
||||
mv "$ZM_TEMP_DIR/composer" "$ZM_RUNTIME_DIR" && \
|
||||
mv "$ZM_TEMP_DIR/composer.phar" "$ZM_RUNTIME_DIR" || {
|
||||
echo "$(nhead red) 移动内建 Composer 到框架目录失败!" && return 1
|
||||
}
|
||||
composer_executable="$ZM_RUNTIME_DIR/composer"
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
function install_framework() {
|
||||
echo "$(nhead) 开始安装框架到目录 $ZM_CUSTOM_DIR ..."
|
||||
mkdir -p "$ZM_PWD/$ZM_CUSTOM_DIR" && \
|
||||
cd "$ZM_PWD/$ZM_CUSTOM_DIR" && \
|
||||
$composer_executable init --name="zhamao/framework-starter" -n -q && \
|
||||
if_use_aliyun && \
|
||||
echo "$(nhead) 从 Composer 拉取框架 ..." && \
|
||||
$composer_executable require -n -q zhamao/framework:^2.7 && \
|
||||
$composer_executable require -n -q --dev swoole/ide-helper:^4.5 && \
|
||||
if_restore_native_runtime && \
|
||||
echo "$(nhead) 初始化框架脚手架文件 ..." && \
|
||||
vendor/bin/start init >/dev/null 2>&1 && \
|
||||
$composer_executable dump-autoload -n -q && \
|
||||
echo "$(nhead) 安装框架完成,已安装到目录 $ZM_CUSTOM_DIR" && \
|
||||
echo -e "$(nhead) 启动框架命令:""$_cyan""cd $ZM_CUSTOM_DIR && ./zhamao server""$_reset" || {
|
||||
echo "$(nhead red) 安装框架失败!" && return 1
|
||||
}
|
||||
}
|
||||
|
||||
# 环境变量设置
|
||||
if [ "$TMPDIR" != "" ]; then
|
||||
ZM_TEMP_DIR="$TMPDIR"
|
||||
fi
|
||||
test "$ZM_TEMP_DIR" = "" && ZM_TEMP_DIR="/tmp/.zm-runtime"
|
||||
test "$ZM_CUSTOM_DIR" = "" && ZM_CUSTOM_DIR="zhamao-app"
|
||||
|
||||
if [ -d "$ZM_PWD/$ZM_CUSTOM_DIR" ]; then
|
||||
echo "$(nhead red) 检测到目录 $ZM_CUSTOM_DIR/ 已安装过框架,请更换文件夹名称或删除旧文件夹再试!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# 检查系统环境,目前只支持 Linux
|
||||
case $(uname -s) in
|
||||
Linux) linux_env_check || exit 1 ;;
|
||||
Darwin) darwin_env_check || exit 1 ;;
|
||||
*) echo "$(nhead red) Only support Linux and macOS!" && exit 1 ;;
|
||||
esac
|
||||
|
||||
# 安装框架
|
||||
install_framework
|
||||
@@ -1,7 +1,14 @@
|
||||
parameters:
|
||||
reportUnmatchedIgnoredErrors: false
|
||||
level: 0
|
||||
level: 4
|
||||
paths:
|
||||
- ./src/
|
||||
ignoreErrors:
|
||||
- '#Used constant OS_TYPE_(LINUX|WINDOWS) not found#'
|
||||
- '#Constant .* not found#'
|
||||
- '#PHPDoc tag @throws with type Psr\\Container\\ContainerExceptionInterface is not subtype of Throwable#'
|
||||
- '#Unsafe usage of new static#'
|
||||
dynamicConstantNames:
|
||||
- SWOOLE_VERSION
|
||||
- ZM_TEST_LOG_DEBUG
|
||||
- _PHAR_STUB_ID
|
||||
|
||||
33
phpunit.xml.dist
Normal file
33
phpunit.xml.dist
Normal file
@@ -0,0 +1,33 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<phpunit bootstrap="./tests/bootstrap.php"
|
||||
backupGlobals="false"
|
||||
backupStaticAttributes="false"
|
||||
colors="true"
|
||||
convertDeprecationsToExceptions="true"
|
||||
convertErrorsToExceptions="true"
|
||||
convertNoticesToExceptions="true"
|
||||
convertWarningsToExceptions="true"
|
||||
processIsolation="false"
|
||||
stopOnError="false"
|
||||
stopOnFailure="false"
|
||||
testdox="true"
|
||||
verbose="true"
|
||||
>
|
||||
<testsuites>
|
||||
<testsuite name="Zhamao Framework Test Suite">
|
||||
<directory suffix="Test.php">./tests</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
<coverage>
|
||||
<include>
|
||||
<directory suffix=".php">./src/ZM</directory>
|
||||
</include>
|
||||
<report>
|
||||
<html outputDirectory="./build/html-coverage"/>
|
||||
<clover outputFile="./build/coverage.xml"/>
|
||||
</report>
|
||||
</coverage>
|
||||
<php>
|
||||
<env name="APP_ENV" value="testing"/>
|
||||
</php>
|
||||
</phpunit>
|
||||
@@ -4,6 +4,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace Module\Example;
|
||||
|
||||
use ZM\Annotation\CQ\CommandArgument;
|
||||
use ZM\Annotation\CQ\CQBefore;
|
||||
use ZM\Annotation\CQ\CQCommand;
|
||||
use ZM\Annotation\CQ\CQMessage;
|
||||
@@ -12,20 +13,25 @@ use ZM\Annotation\Http\RequestMapping;
|
||||
use ZM\Annotation\Swoole\OnCloseEvent;
|
||||
use ZM\Annotation\Swoole\OnOpenEvent;
|
||||
use ZM\Annotation\Swoole\OnRequestEvent;
|
||||
use ZM\Annotation\Swoole\OnStart;
|
||||
use ZM\API\CQ;
|
||||
use ZM\API\OneBotV11;
|
||||
use ZM\API\TuringAPI;
|
||||
use ZM\Config\ZMConfig;
|
||||
use ZM\ConnectionManager\ConnectionObject;
|
||||
use ZM\Console\Console;
|
||||
use ZM\Context\Context;
|
||||
use ZM\Event\EventDispatcher;
|
||||
use ZM\Exception\InterruptException;
|
||||
use ZM\Module\QQBot;
|
||||
use ZM\Requests\ZMRequest;
|
||||
use ZM\Utils\CommandInfoUtil;
|
||||
use ZM\Utils\MessageUtil;
|
||||
use ZM\Utils\ZMUtil;
|
||||
|
||||
/**
|
||||
* Class Hello
|
||||
*
|
||||
* @since 2.0
|
||||
*/
|
||||
class Hello
|
||||
@@ -95,11 +101,11 @@ class Hello
|
||||
public function turingAPI()
|
||||
{
|
||||
$user_id = ctx()->getUserId();
|
||||
$api = ''; // 请在这里填入你的图灵机器人的apikey
|
||||
$api = ZMConfig::get('global', 'custom.turing_apikey') ?? ''; // 请在这里填入你的图灵机器人的apikey
|
||||
if ($api === '') {
|
||||
return false;
|
||||
} // 如果没有填入apikey则此功能关闭
|
||||
if (($this->_running_annotation ?? null) instanceof CQCommand) {
|
||||
if (property_exists($this, '_running_annotation') && ($this->_running_annotation instanceof CQCommand)) {
|
||||
$msg = ctx()->getFullArg('我在!有什么事吗?');
|
||||
} else {
|
||||
$msg = ctx()->getMessage();
|
||||
@@ -133,18 +139,18 @@ class Hello
|
||||
* 问法2:从1到20的随机数
|
||||
* @CQCommand("随机数")
|
||||
* @CQCommand(pattern="*从*到*的随机数")
|
||||
* @CommandArgument(name="num1",type="int",required=true)
|
||||
* @CommandArgument(name="num2",type="int",required=true)
|
||||
* @param mixed $num1
|
||||
* @param mixed $num2
|
||||
* @return string
|
||||
*/
|
||||
public function randNum()
|
||||
public function randNum($num1, $num2)
|
||||
{
|
||||
// 获取第一个数字类型的参数
|
||||
$num1 = ctx()->getNumArg('请输入第一个数字');
|
||||
// 获取第二个数字类型的参数
|
||||
$num2 = ctx()->getNumArg('请输入第二个数字');
|
||||
$a = min(intval($num1), intval($num2));
|
||||
$b = max(intval($num1), intval($num2));
|
||||
$a = min($num1, $num2);
|
||||
$b = max($num1, $num2);
|
||||
// 回复用户结果
|
||||
return '随机数是:' . mt_rand($a, $b);
|
||||
return '从' . $a . '到' . $b . '的随机数是:' . mt_rand($a, $b);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -170,10 +176,11 @@ class Hello
|
||||
/**
|
||||
* 使用自定义参数的路由参数
|
||||
* @RequestMapping("/whoami/{name}")
|
||||
* @param $param
|
||||
* @return string
|
||||
*
|
||||
* @param array $param 参数
|
||||
* @return string 返回的 HTML Body
|
||||
*/
|
||||
public function paramGet($param)
|
||||
public function paramGet(array $param = []): string
|
||||
{
|
||||
return 'Hello, ' . $param['name'];
|
||||
}
|
||||
@@ -181,7 +188,8 @@ class Hello
|
||||
/**
|
||||
* 在机器人连接后向终端输出信息
|
||||
* @OnOpenEvent("qq")
|
||||
* @param $conn
|
||||
*
|
||||
* @param ConnectionObject $conn WebSocket 连接对象
|
||||
*/
|
||||
public function onConnect(ConnectionObject $conn)
|
||||
{
|
||||
@@ -200,6 +208,7 @@ class Hello
|
||||
/**
|
||||
* 阻止 Chrome 自动请求 /favicon.ico 导致的多条请求并发和干扰
|
||||
* @OnRequestEvent(rule="ctx()->getRequest()->server['request_uri'] == '/favicon.ico'",level=200)
|
||||
*
|
||||
* @throws InterruptException
|
||||
*/
|
||||
public function onRequest()
|
||||
@@ -225,8 +234,33 @@ class Hello
|
||||
#[CQCommand('帮助')]
|
||||
public function help(): string
|
||||
{
|
||||
$helps = MessageUtil::generateCommandHelp();
|
||||
$util = resolve(CommandInfoUtil::class);
|
||||
$commands = $util->get();
|
||||
$helps = array_map(static function ($command) use ($util) {
|
||||
return $util->getHelp($command['id']);
|
||||
}, $commands);
|
||||
array_unshift($helps, '帮助:');
|
||||
return implode("\n", $helps);
|
||||
}
|
||||
|
||||
/**
|
||||
* @CQCommand("proxy")
|
||||
*/
|
||||
#[CQCommand('proxy')]
|
||||
public function proxy()
|
||||
{
|
||||
bot()->all()->allGroups()->sendGroupMsg(0, ctx()->getMessage());
|
||||
}
|
||||
|
||||
/*
|
||||
* 欢迎来到容器时代
|
||||
*
|
||||
* @param Context $context 通过依赖注入实现的
|
||||
*
|
||||
* @CQCommand("容器你好")
|
||||
*/
|
||||
public function welcomeToContainerAge(Context $context)
|
||||
{
|
||||
$context->reply('欢迎来到容器时代');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace ZM\API;
|
||||
|
||||
use Stringable;
|
||||
use ZM\Console\Console;
|
||||
use ZM\Entity\CQObject;
|
||||
|
||||
@@ -11,284 +12,308 @@ class CQ
|
||||
{
|
||||
/**
|
||||
* at一下QQ用户(仅在QQ群支持at全体)
|
||||
* @param $qq
|
||||
* @return string
|
||||
* @param int|string $qq 用户QQ号/ID号
|
||||
* @return string CQ码
|
||||
*/
|
||||
public static function at($qq)
|
||||
public static function at($qq): string
|
||||
{
|
||||
if (is_numeric($qq) || $qq === 'all') {
|
||||
return '[CQ:at,qq=' . $qq . ']';
|
||||
}
|
||||
Console::warning(zm_internal_errcode('E00035') . "传入的QQ号码({$qq})错误!");
|
||||
return ' ';
|
||||
return self::buildCQ('at', ['qq' => $qq]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送QQ原生表情
|
||||
* @param $id
|
||||
* @return string
|
||||
* @param int|string $id 表情ID
|
||||
* @return string CQ码
|
||||
*/
|
||||
public static function face($id)
|
||||
public static function face($id): string
|
||||
{
|
||||
if (is_numeric($id)) {
|
||||
return '[CQ:face,id=' . $id . ']';
|
||||
}
|
||||
Console::warning(zm_internal_errcode('E00035') . "传入的face id({$id})错误!");
|
||||
return ' ';
|
||||
return self::buildCQ('face', ['id' => $id]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送图片
|
||||
* @param $file
|
||||
* @return string
|
||||
* @param string $file 文件的路径、URL或者base64编码的图片数据
|
||||
* @param bool $cache 是否缓存(默认为true)
|
||||
* @param bool $flash 是否闪照(默认为false)
|
||||
* @param bool $proxy 是否使用代理(默认为true)
|
||||
* @param int $timeout 超时时间(默认不超时)
|
||||
* @return string CQ码
|
||||
*/
|
||||
public static function image($file, bool $cache = true, bool $flash = false, bool $proxy = true, int $timeout = -1)
|
||||
public static function image(string $file, bool $cache = true, bool $flash = false, bool $proxy = true, int $timeout = -1): string
|
||||
{
|
||||
return
|
||||
'[CQ:image,file=' . self::encode($file, true) .
|
||||
(!$cache ? ',cache=0' : '') .
|
||||
($flash ? ',type=flash' : '') .
|
||||
(!$proxy ? ',proxy=false' : '') .
|
||||
($timeout != -1 ? (',timeout=' . $timeout) : '') .
|
||||
']';
|
||||
$optional_values = [
|
||||
'cache' => !$cache ? 'cache=0' : '',
|
||||
'flash' => $flash ? 'type=flash' : '',
|
||||
'proxy' => !$proxy ? 'proxy=false' : '',
|
||||
'timeout' => $timeout != -1 ? 'timeout=' . $timeout : '',
|
||||
];
|
||||
return self::buildCQ('image', ['file' => $file], $optional_values);
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送语音
|
||||
* @param $file
|
||||
* @return string
|
||||
* @param string $file 文件的路径、URL或者base64编码的语音数据
|
||||
* @param bool $magic 是否加特技(默认为false)
|
||||
* @param bool $cache 是否缓存(默认为true)
|
||||
* @param bool $proxy 是否使用代理(默认为true)
|
||||
* @param int $timeout 超时时间(默认不超时)
|
||||
* @return string CQ码
|
||||
*/
|
||||
public static function record($file, bool $magic = false, bool $cache = true, bool $proxy = true, int $timeout = -1)
|
||||
public static function record(string $file, bool $magic = false, bool $cache = true, bool $proxy = true, int $timeout = -1): string
|
||||
{
|
||||
return
|
||||
'[CQ:record,file=' . self::encode($file, true) .
|
||||
(!$cache ? ',cache=0' : '') .
|
||||
($magic ? ',magic=1' : '') .
|
||||
(!$proxy ? ',proxy=false' : '') .
|
||||
($timeout != -1 ? (',timeout=' . $timeout) : '') .
|
||||
']';
|
||||
$optional_values = [
|
||||
'magic' => $magic ? 'magic=true' : '',
|
||||
'cache' => !$cache ? 'cache=0' : '',
|
||||
'proxy' => !$proxy ? 'proxy=false' : '',
|
||||
'timeout' => $timeout != -1 ? 'timeout=' . $timeout : '',
|
||||
];
|
||||
return self::buildCQ('record', ['file' => $file], $optional_values);
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送短视频
|
||||
* @param $file
|
||||
* @return string
|
||||
* @param string $file 文件的路径、URL或者base64编码的短视频数据
|
||||
* @param bool $cache 是否缓存(默认为true)
|
||||
* @param bool $proxy 是否使用代理(默认为true)
|
||||
* @param int $timeout 超时时间(默认不超时)
|
||||
* @return string CQ码
|
||||
*/
|
||||
public static function video($file, bool $cache = true, bool $proxy = true, int $timeout = -1)
|
||||
public static function video(string $file, bool $cache = true, bool $proxy = true, int $timeout = -1): string
|
||||
{
|
||||
return
|
||||
'[CQ:video,file=' . self::encode($file, true) .
|
||||
(!$cache ? ',cache=0' : '') .
|
||||
(!$proxy ? ',proxy=false' : '') .
|
||||
($timeout != -1 ? (',timeout=' . $timeout) : '') .
|
||||
']';
|
||||
$optional_values = [
|
||||
'cache' => !$cache ? 'cache=0' : '',
|
||||
'proxy' => !$proxy ? 'proxy=false' : '',
|
||||
'timeout' => $timeout != -1 ? 'timeout=' . $timeout : '',
|
||||
];
|
||||
return self::buildCQ('video', ['file' => $file], $optional_values);
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送投掷骰子(只能在单条回复中单独使用)
|
||||
* @return string
|
||||
* @return string CQ码
|
||||
*/
|
||||
public static function rps()
|
||||
public static function rps(): string
|
||||
{
|
||||
return '[CQ:rps]';
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送掷骰子表情(只能在单条回复中单独使用)
|
||||
* @return string
|
||||
* @return string CQ码
|
||||
*/
|
||||
public static function dice()
|
||||
public static function dice(): string
|
||||
{
|
||||
return '[CQ:dice]';
|
||||
}
|
||||
|
||||
/**
|
||||
* 戳一戳(原窗口抖动,仅支持好友消息使用)
|
||||
* @return string
|
||||
* @return string CQ码
|
||||
*/
|
||||
public static function shake()
|
||||
public static function shake(): string
|
||||
{
|
||||
return '[CQ:shake]';
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送新的戳一戳
|
||||
* @param $type
|
||||
* @param $id
|
||||
* @return string
|
||||
* @param int|string $type 焯一戳类型
|
||||
* @param int|string $id 戳一戳ID号
|
||||
* @param string $name 戳一戳名称(可选)
|
||||
* @return string CQ码
|
||||
*/
|
||||
public static function poke($type, $id, string $name = '')
|
||||
public static function poke($type, $id, string $name = ''): string
|
||||
{
|
||||
return "[CQ:poke,type={$type},id={$id}" . ($name != '' ? (',name=' . self::encode($name, true)) : '') . ']';
|
||||
$optional_values = [
|
||||
'name' => $name ? 'name=' . $name : '',
|
||||
];
|
||||
return self::buildCQ('poke', ['type' => $type, 'id' => $id], $optional_values);
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送匿名消息
|
||||
* @return string
|
||||
* @param int $ignore 是否忽略错误(默认为1,0表示不忽略错误)
|
||||
* @return string CQ码
|
||||
*/
|
||||
public static function anonymous(int $ignore = 1)
|
||||
public static function anonymous(int $ignore = 1): string
|
||||
{
|
||||
return '[CQ:anonymous' . ($ignore != 1 ? ',ignore=0' : '') . ']';
|
||||
return self::buildCQ('anonymous', [], ['ignore' => $ignore != 1 ? 'ignore=0' : '']);
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送链接分享(只能在单条回复中单独使用)
|
||||
* @param $url
|
||||
* @param $title
|
||||
* @param null $content
|
||||
* @param null $image
|
||||
* @return string
|
||||
* @param string $url 分享地址
|
||||
* @param string $title 标题
|
||||
* @param null|string $content 卡片内容(可选)
|
||||
* @param null|string $image 卡片图片(可选)
|
||||
* @return string CQ码
|
||||
*/
|
||||
public static function share($url, $title, $content = null, $image = null)
|
||||
public static function share(string $url, string $title, ?string $content = null, ?string $image = null): string
|
||||
{
|
||||
if ($content === null) {
|
||||
$c = '';
|
||||
} else {
|
||||
$c = ',content=' . self::encode($content, true);
|
||||
}
|
||||
if ($image === null) {
|
||||
$i = '';
|
||||
} else {
|
||||
$i = ',image=' . self::encode($image, true);
|
||||
}
|
||||
return '[CQ:share,url=' . self::encode($url, true) . ',title=' . self::encode($title, true) . $c . $i . ']';
|
||||
$optional_values = [
|
||||
'content' => $content ? 'content=' . self::encode($content, true) : '',
|
||||
'image' => $image ? 'image=' . self::encode($image, true) : '',
|
||||
];
|
||||
return self::buildCQ('share', ['url' => $url, 'title' => $title], $optional_values);
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送好友或群推荐名片
|
||||
* @param $type
|
||||
* @param $id
|
||||
* @return string
|
||||
* @param int|string $type 名片类型
|
||||
* @param int|string $id 好友或群ID
|
||||
* @return string CQ码
|
||||
*/
|
||||
public static function contact($type, $id)
|
||||
public static function contact($type, $id): string
|
||||
{
|
||||
return "[CQ:contact,type={$type},id={$id}]";
|
||||
return self::buildCQ('contact', ['type' => $type, 'id' => $id]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送位置
|
||||
* @param $lat
|
||||
* @param $lon
|
||||
* @return string
|
||||
* @param float|string $lat 纬度
|
||||
* @param float|string $lon 经度
|
||||
* @param string $title 标题(可选)
|
||||
* @param string $content 卡片内容(可选)
|
||||
* @return string CQ码
|
||||
*/
|
||||
public static function location($lat, $lon, string $title = '', string $content = '')
|
||||
public static function location($lat, $lon, string $title = '', string $content = ''): string
|
||||
{
|
||||
return '[CQ:location' .
|
||||
',lat=' . self::encode($lat, true) .
|
||||
',lon=' . self::encode($lon, true) .
|
||||
($title != '' ? (',title=' . self::encode($title, true)) : '') .
|
||||
($content != '' ? (',content=' . self::encode($content, true)) : '') .
|
||||
']';
|
||||
$optional_values = [
|
||||
'title' => $title ? 'title=' . self::encode($title, true) : '',
|
||||
'content' => $content ? 'content=' . self::encode($content, true) : '',
|
||||
];
|
||||
return self::buildCQ('location', ['lat' => $lat, 'lon' => $lon], $optional_values);
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送音乐分享(只能在单条回复中单独使用)
|
||||
*
|
||||
* qq、163、xiami为内置分享,需要先通过搜索功能获取id后使用
|
||||
* custom为自定义分享
|
||||
* 当为自定义分享时:
|
||||
* $id_or_url 为音乐卡片点进去打开的链接(一般是音乐介绍界面啦什么的)
|
||||
* $audio 为音乐(如mp3文件)的HTTP链接地址(不可为空)
|
||||
* $title 为音乐卡片的标题,建议12字以内(不可为空)
|
||||
* $content 为音乐卡片的简介(可忽略)
|
||||
* $image 为音乐卡片的图片链接地址(可忽略)
|
||||
* @param $type
|
||||
* @param $id_or_url
|
||||
* @param null $audio
|
||||
* @param null $title
|
||||
* @param null $content
|
||||
* @param null $image
|
||||
* @return string
|
||||
*
|
||||
* @param string $type 分享类型(仅限 `qq`、`163`、`xiami` 或 `custom`)
|
||||
* @param int|string $id_or_url 当分享类型不是 `custom` 时,表示的是分享音乐的ID(需要先通过搜索功能获取id后使用),反之表示的是音乐卡片点入的链接
|
||||
* @param null|string $audio 当分享类型是 `custom` 时,表示为音乐(如mp3文件)的HTTP链接地址(不可为空)
|
||||
* @param null|string $title 当分享类型是 `custom` 时,表示为音乐卡片的标题,建议12字以内(不可为空)
|
||||
* @param null|string $content 当分享类型是 `custom` 时,表示为音乐卡片的简介(可忽略)
|
||||
* @param null|string $image 当分享类型是 `custom` 时,表示为音乐卡片的图片链接地址(可忽略)
|
||||
* @return string CQ码
|
||||
*/
|
||||
public static function music($type, $id_or_url, $audio = null, $title = null, $content = null, $image = null)
|
||||
public static function music(string $type, $id_or_url, ?string $audio = null, ?string $title = null, ?string $content = null, ?string $image = null): string
|
||||
{
|
||||
switch ($type) {
|
||||
case 'qq':
|
||||
case '163':
|
||||
case 'xiami':
|
||||
return "[CQ:music,type={$type},id={$id_or_url}]";
|
||||
return self::buildCQ('music', ['type' => $type, 'id' => $id_or_url]);
|
||||
case 'custom':
|
||||
if ($title === null || $audio === null) {
|
||||
Console::warning(zm_internal_errcode('E00035') . '传入CQ码实例的标题和音频链接不能为空!');
|
||||
return ' ';
|
||||
}
|
||||
if ($content === null) {
|
||||
$c = '';
|
||||
} else {
|
||||
$c = ',content=' . self::encode($content, true);
|
||||
}
|
||||
if ($image === null) {
|
||||
$i = '';
|
||||
} else {
|
||||
$i = ',image=' . self::encode($image, true);
|
||||
}
|
||||
return '[CQ:music,type=custom,url=' .
|
||||
self::encode($id_or_url, true) .
|
||||
',audio=' . self::encode($audio, true) . ',title=' . self::encode($title, true) . $c . $i .
|
||||
']';
|
||||
$optional_values = [
|
||||
'content' => $content ? 'content=' . self::encode($content, true) : '',
|
||||
'image' => $image ? 'image=' . self::encode($image, true) : '',
|
||||
];
|
||||
return self::buildCQ('music', ['type' => 'custom', 'url' => $id_or_url, 'audio' => $audio, 'title' => $title], $optional_values);
|
||||
default:
|
||||
Console::warning(zm_internal_errcode('E00035') . "传入的music type({$type})错误!");
|
||||
return ' ';
|
||||
}
|
||||
}
|
||||
|
||||
public static function forward($id)
|
||||
/**
|
||||
* 合并转发消息
|
||||
* @param int|string $id 合并转发ID, 需要通过 `/get_forward_msg` API获取转发的具体内容
|
||||
* @return string CQ码
|
||||
*/
|
||||
public static function forward($id): string
|
||||
{
|
||||
return '[CQ:forward,id=' . self::encode($id) . ']';
|
||||
return self::buildCQ('forward', ['id' => $id]);
|
||||
}
|
||||
|
||||
public static function node($user_id, $nickname, $content)
|
||||
/**
|
||||
* 合并转发消息节点
|
||||
* 特殊说明: 需要使用单独的API /send_group_forward_msg 发送, 并且由于消息段较为复杂, 仅支持Array形式入参。
|
||||
* 如果引用消息和自定义消息同时出现, 实际查看顺序将取消息段顺序。
|
||||
* 另外按 CQHTTP 文档说明, data 应全为字符串, 但由于需要接收message 类型的消息, 所以 仅限此Type的content字段 支持Array套娃
|
||||
* @param int|string $user_id 转发消息id
|
||||
* @param string $nickname 发送者显示名字
|
||||
* @param string $content 具体消息
|
||||
* @return string CQ码
|
||||
* @deprecated 这个不推荐使用,因为 go-cqhttp 官方没有对其提供CQ码模式相关支持,仅支持Array模式发送
|
||||
*/
|
||||
public static function node($user_id, string $nickname, string $content): string
|
||||
{
|
||||
return "[CQ:node,user_id={$user_id},nickname=" . self::encode($nickname, true) . ',content=' . self::encode($content, true) . ']';
|
||||
return self::buildCQ('node', ['user_id' => $user_id, 'nickname' => $nickname, 'content' => $content]);
|
||||
}
|
||||
|
||||
public static function xml($data)
|
||||
/**
|
||||
* XML消息
|
||||
* @param string $data xml内容, xml中的value部分
|
||||
* @return string CQ码
|
||||
*/
|
||||
public static function xml(string $data): string
|
||||
{
|
||||
return '[CQ:xml,data=' . self::encode($data, true) . ']';
|
||||
return self::buildCQ('xml', ['data' => $data]);
|
||||
}
|
||||
|
||||
public static function json($data, $resid = 0)
|
||||
/**
|
||||
* JSON消息
|
||||
* @param string $data json内容
|
||||
* @param int $resid 0为走小程序通道,其他值为富文本通道(默认为0)
|
||||
* @return string CQ码
|
||||
*/
|
||||
public static function json(string $data, int $resid = 0): string
|
||||
{
|
||||
return '[CQ:json,data=' . self::encode($data, true) . ',resid=' . intval($resid) . ']';
|
||||
return self::buildCQ('json', ['data' => $data, 'resid' => $resid]);
|
||||
}
|
||||
|
||||
public static function _custom(string $type_name, $params)
|
||||
/**
|
||||
* 返回一个自定义扩展的CQ码(支持自定义类型和参数)
|
||||
* @param string $type_name CQ码类型名称
|
||||
* @param array $params 参数
|
||||
* @return string CQ码
|
||||
*/
|
||||
public static function _custom(string $type_name, array $params): string
|
||||
{
|
||||
$code = '[CQ:' . $type_name;
|
||||
foreach ($params as $k => $v) {
|
||||
$code .= ',' . $k . '=' . self::escape($v, true);
|
||||
}
|
||||
$code .= ']';
|
||||
return $code;
|
||||
return self::buildCQ($type_name, $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 反转义字符串中的CQ码敏感符号
|
||||
* @param mixed $msg
|
||||
* @param mixed $is_content
|
||||
* @param int|string|Stringable $msg 字符串
|
||||
* @param bool $is_content 如果是解码CQ码本体内容,则为false(默认),如果是参数内的字符串,则为true
|
||||
* @return string 转义后的CQ码
|
||||
*/
|
||||
public static function decode($msg, $is_content = false)
|
||||
public static function decode($msg, bool $is_content = false): string
|
||||
{
|
||||
$msg = str_replace(['&', '[', ']'], ['&', '[', ']'], $msg);
|
||||
$msg = str_replace(['&', '[', ']'], ['&', '[', ']'], (string) $msg);
|
||||
if ($is_content) {
|
||||
$msg = str_replace(',', ',', $msg);
|
||||
}
|
||||
return $msg;
|
||||
}
|
||||
|
||||
public static function replace($str)
|
||||
/**
|
||||
* 简单反转义替换CQ码的方括号
|
||||
* @param int|string|Stringable $str 字符串
|
||||
* @return string 字符串
|
||||
*/
|
||||
public static function replace($str): string
|
||||
{
|
||||
$str = str_replace('{{', '[', $str);
|
||||
$str = str_replace('{{', '[', (string) $str);
|
||||
return str_replace('}}', ']', $str);
|
||||
}
|
||||
|
||||
/**
|
||||
* 转义CQ码的特殊字符,同encode
|
||||
* @param mixed $msg
|
||||
* @param mixed $is_content
|
||||
* @param int|string|Stringable $msg 字符串
|
||||
* @param bool $is_content 如果是转义CQ码本体内容,则为false(默认),如果是参数内的字符串,则为true
|
||||
* @return string 转义后的CQ码
|
||||
*/
|
||||
public static function escape($msg, $is_content = false)
|
||||
public static function escape($msg, bool $is_content = false): string
|
||||
{
|
||||
$msg = str_replace(['&', '[', ']'], ['&', '[', ']'], $msg);
|
||||
$msg = str_replace(['&', '[', ']'], ['&', '[', ']'], (string) $msg);
|
||||
if ($is_content) {
|
||||
$msg = str_replace(',', ',', $msg);
|
||||
}
|
||||
@@ -297,12 +322,13 @@ class CQ
|
||||
|
||||
/**
|
||||
* 转义CQ码的特殊字符
|
||||
* @param mixed $msg
|
||||
* @param mixed $is_content
|
||||
* @param int|string|Stringable $msg 字符串
|
||||
* @param bool $is_content 如果是转义CQ码本体内容,则为false(默认),如果是参数内的字符串,则为true
|
||||
* @return string 转义后的CQ码
|
||||
*/
|
||||
public static function encode($msg, $is_content = false)
|
||||
public static function encode($msg, bool $is_content = false): string
|
||||
{
|
||||
$msg = str_replace(['&', '[', ']'], ['&', '[', ']'], $msg);
|
||||
$msg = str_replace(['&', '[', ']'], ['&', '[', ']'], (string) $msg);
|
||||
if ($is_content) {
|
||||
$msg = str_replace(',', ',', $msg);
|
||||
}
|
||||
@@ -311,10 +337,10 @@ class CQ
|
||||
|
||||
/**
|
||||
* 移除消息中所有的CQ码并返回移除CQ码后的消息
|
||||
* @param $msg
|
||||
* @return string
|
||||
* @param string $msg 消息
|
||||
* @return string 消息内容
|
||||
*/
|
||||
public static function removeCQ($msg)
|
||||
public static function removeCQ(string $msg): string
|
||||
{
|
||||
$final = '';
|
||||
$last_end = 0;
|
||||
@@ -328,10 +354,11 @@ class CQ
|
||||
|
||||
/**
|
||||
* 获取消息中第一个CQ码
|
||||
* @param mixed $msg
|
||||
* @param mixed $is_object
|
||||
* @param string $msg 消息内容
|
||||
* @param bool $is_object 是否以对象形式返回,如果为False的话,返回数组形式(默认为false)
|
||||
* @return null|array|CQObject 返回的CQ码(数组或对象)
|
||||
*/
|
||||
public static function getCQ($msg, $is_object = false)
|
||||
public static function getCQ(string $msg, bool $is_object = false)
|
||||
{
|
||||
if (($head = mb_strpos($msg, '[CQ:')) !== false) {
|
||||
$key_offset = mb_substr($msg, $head);
|
||||
@@ -356,14 +383,15 @@ class CQ
|
||||
|
||||
/**
|
||||
* 获取消息中所有的CQ码
|
||||
* @param mixed $msg
|
||||
* @param mixed $is_object
|
||||
* @param string $msg 消息内容
|
||||
* @param bool $is_object 是否以对象形式返回,如果为False的话,返回数组形式(默认为false)
|
||||
* @return array|CQObject[] 返回的CQ码们(数组或对象)
|
||||
*/
|
||||
public static function getAllCQ($msg, $is_object = false)
|
||||
public static function getAllCQ(string $msg, bool $is_object = false): array
|
||||
{
|
||||
$cqs = [];
|
||||
$offset = 0;
|
||||
while (($head = mb_strpos(($submsg = mb_substr($msg, $offset)), '[CQ:')) !== false) {
|
||||
while (($head = mb_strpos($submsg = mb_substr($msg, $offset), '[CQ:')) !== false) {
|
||||
$key_offset = mb_substr($submsg, $head);
|
||||
$tmpmsg = mb_strpos($key_offset, ']');
|
||||
if ($tmpmsg === false) {
|
||||
@@ -385,4 +413,22 @@ class CQ
|
||||
}
|
||||
return $cqs;
|
||||
}
|
||||
|
||||
private static function buildCQ(string $cq, array $array, array $optional_values = []): string
|
||||
{
|
||||
$str = '[CQ:' . $cq;
|
||||
foreach ($array as $k => $v) {
|
||||
if ($v === null) {
|
||||
Console::warning('param ' . $k . ' cannot be set with null, empty CQ will returned!');
|
||||
return ' ';
|
||||
}
|
||||
$str .= ',' . $k . '=' . self::encode($v);
|
||||
}
|
||||
foreach ($optional_values as $v) {
|
||||
if ($v !== '') {
|
||||
$str .= ',' . $v;
|
||||
}
|
||||
}
|
||||
return $str . ']';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ use ZM\Utils\CoMessage;
|
||||
|
||||
trait CQAPI
|
||||
{
|
||||
/** @var null|Closure */
|
||||
/** @var null|Closure 过滤用的 */
|
||||
private static $filter;
|
||||
|
||||
public function __call($name, $arguments)
|
||||
@@ -33,12 +33,6 @@ trait CQAPI
|
||||
return $func_name . $postfix;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $connection
|
||||
* @param $reply
|
||||
* @param |null $function
|
||||
* @return array|bool
|
||||
*/
|
||||
private function processAPI($connection, $reply, $function = null)
|
||||
{
|
||||
if (is_callable(self::$filter)) {
|
||||
@@ -57,7 +51,7 @@ trait CQAPI
|
||||
|
||||
private function processWebsocketAPI($connection, $reply, $function = false)
|
||||
{
|
||||
$api_id = ZMAtomic::get('wait_msg_id')->add(1);
|
||||
$api_id = ZMAtomic::get('wait_msg_id')->add();
|
||||
$reply['echo'] = $api_id;
|
||||
if (server()->push($connection->getFd(), json_encode($reply))) {
|
||||
if ($function === true) {
|
||||
@@ -89,14 +83,10 @@ trait CQAPI
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $connection
|
||||
* @param $reply
|
||||
* @param null $function
|
||||
* @noinspection PhpUnusedParameterInspection
|
||||
*/
|
||||
private function processHttpAPI($connection, $reply, $function = null): bool
|
||||
{
|
||||
unset($connection, $reply, $function);
|
||||
// TODO: HTTP方式处理API的代码还没写
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ class GoCqhttpAPIV11
|
||||
* 获取频道系统内BOT的资料
|
||||
* 响应字段:nickname, tiny_id, avatar_url
|
||||
* @see https://github.com/Mrs4s/go-cqhttp/blob/master/docs/guild.md#%E8%8E%B7%E5%8F%96%E9%A2%91%E9%81%93%E7%B3%BB%E7%BB%9F%E5%86%85bot%E7%9A%84%E8%B5%84%E6%96%99
|
||||
* @return array|bool
|
||||
* @return array|bool 返回API调用结果(数组)或异步API调用状态(bool)
|
||||
*/
|
||||
public function getGuildServiceProfile()
|
||||
{
|
||||
@@ -39,7 +39,7 @@ class GoCqhttpAPIV11
|
||||
/**
|
||||
* 获取频道列表
|
||||
* @see https://github.com/Mrs4s/go-cqhttp/blob/master/docs/guild.md#%E8%8E%B7%E5%8F%96%E9%A2%91%E9%81%93%E5%88%97%E8%A1%A8
|
||||
* @return array|bool
|
||||
* @return array|bool 返回API调用结果(数组)或异步API调用状态(bool)
|
||||
*/
|
||||
public function getGuildList()
|
||||
{
|
||||
@@ -51,8 +51,8 @@ class GoCqhttpAPIV11
|
||||
/**
|
||||
* 通过访客获取频道元数据
|
||||
* @see https://github.com/Mrs4s/go-cqhttp/blob/master/docs/guild.md#%E9%80%9A%E8%BF%87%E8%AE%BF%E5%AE%A2%E8%8E%B7%E5%8F%96%E9%A2%91%E9%81%93%E5%85%83%E6%95%B0%E6%8D%AE
|
||||
* @param $guild_id
|
||||
* @return array|bool
|
||||
* @param int|string $guild_id 频道ID
|
||||
* @return array|bool 返回API调用结果(数组)或异步API调用状态(bool)
|
||||
*/
|
||||
public function getGuildMetaByGuest($guild_id)
|
||||
{
|
||||
@@ -67,9 +67,9 @@ class GoCqhttpAPIV11
|
||||
/**
|
||||
* 获取子频道列表
|
||||
* @see https://github.com/Mrs4s/go-cqhttp/blob/master/docs/guild.md#%E8%8E%B7%E5%8F%96%E5%AD%90%E9%A2%91%E9%81%93%E5%88%97%E8%A1%A8
|
||||
* @param $guild_id
|
||||
* @param false $no_cache
|
||||
* @return array|bool
|
||||
* @param int|string $guild_id 频道ID
|
||||
* @param false $no_cache 禁用缓存(默认为false)
|
||||
* @return array|bool 返回API调用结果(数组)或异步API调用状态(bool)
|
||||
*/
|
||||
public function getGuildChannelList($guild_id, bool $no_cache = false)
|
||||
{
|
||||
@@ -85,8 +85,8 @@ class GoCqhttpAPIV11
|
||||
/**
|
||||
* 获取频道成员列表
|
||||
* @see https://github.com/Mrs4s/go-cqhttp/blob/master/docs/guild.md#%E8%8E%B7%E5%8F%96%E9%A2%91%E9%81%93%E6%88%90%E5%91%98%E5%88%97%E8%A1%A8
|
||||
* @param $guild_id
|
||||
* @return array|bool
|
||||
* @param int|string $guild_id 频道ID
|
||||
* @return array|bool 返回API调用结果(数组)或异步API调用状态(bool)
|
||||
*/
|
||||
public function getGuildMembers($guild_id)
|
||||
{
|
||||
@@ -101,12 +101,12 @@ class GoCqhttpAPIV11
|
||||
/**
|
||||
* 发送信息到子频道
|
||||
* @see https://github.com/Mrs4s/go-cqhttp/blob/master/docs/guild.md#%E5%8F%91%E9%80%81%E4%BF%A1%E6%81%AF%E5%88%B0%E5%AD%90%E9%A2%91%E9%81%93
|
||||
* @param $guild_id
|
||||
* @param $channel_id
|
||||
* @param $message
|
||||
* @return array|bool
|
||||
* @param int|string $guild_id 频道ID
|
||||
* @param int|string $channel_id 子频道ID
|
||||
* @param string $message 信息内容
|
||||
* @return array|bool 返回API调用结果(数组)或异步API调用状态(bool)
|
||||
*/
|
||||
public function sendGuildChannelMsg($guild_id, $channel_id, $message)
|
||||
public function sendGuildChannelMsg($guild_id, $channel_id, string $message)
|
||||
{
|
||||
return $this->processAPI($this->connection, [
|
||||
'action' => $this->getActionName($this->prefix, __FUNCTION__),
|
||||
|
||||
@@ -6,6 +6,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace ZM\API;
|
||||
|
||||
use Closure;
|
||||
use ZM\ConnectionManager\ConnectionObject;
|
||||
use ZM\ConnectionManager\ManagerGM;
|
||||
use ZM\Exception\RobotNotFoundException;
|
||||
@@ -39,11 +40,12 @@ class OneBotV11
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $robot_id
|
||||
* 获取机器人Action/API实例
|
||||
* @param int|string $robot_id 机器人ID
|
||||
* @throws RobotNotFoundException
|
||||
* @return ZMRobot
|
||||
* @return ZMRobot 机器人实例
|
||||
*/
|
||||
public static function get($robot_id)
|
||||
public static function get($robot_id): ZMRobot
|
||||
{
|
||||
$r = ManagerGM::getAllByName('qq');
|
||||
foreach ($r as $v) {
|
||||
@@ -55,10 +57,11 @@ class OneBotV11
|
||||
}
|
||||
|
||||
/**
|
||||
* 随机获取一个连接到框架的机器人实例
|
||||
* @throws RobotNotFoundException
|
||||
* @return ZMRobot
|
||||
* @return ZMRobot 机器人实例
|
||||
*/
|
||||
public static function getRandom()
|
||||
public static function getRandom(): ZMRobot
|
||||
{
|
||||
$r = ManagerGM::getAllByName('qq');
|
||||
if ($r == []) {
|
||||
@@ -68,9 +71,10 @@ class OneBotV11
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ZMRobot[]
|
||||
* 获取所有机器人实例
|
||||
* @return ZMRobot[] 机器人实例们
|
||||
*/
|
||||
public static function getAllRobot()
|
||||
public static function getAllRobot(): array
|
||||
{
|
||||
$r = ManagerGM::getAllByName('qq');
|
||||
$obj = [];
|
||||
@@ -80,13 +84,23 @@ class OneBotV11
|
||||
return $obj;
|
||||
}
|
||||
|
||||
public function setCallback($callback = true)
|
||||
/**
|
||||
* 设置回调或启用协程等待API回包
|
||||
* @param bool|Closure $callback 是否开启协程或设置异步回调函数,如果为true,则协程等待结果,如果为false,则异步执行并不等待结果,如果为回调函数,则异步执行且调用回调
|
||||
* @return OneBotV11 返回本身
|
||||
*/
|
||||
public function setCallback($callback = true): OneBotV11
|
||||
{
|
||||
$this->callback = $callback;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setPrefix($prefix = self::API_NORMAL)
|
||||
/**
|
||||
* 设置API调用类型后缀
|
||||
* @param int $prefix 设置后缀类型,API_NORMAL为不加后缀,API_ASYNC为异步调用,API_RATE_LIMITED为加后缀并且限制调用频率
|
||||
* @return OneBotV11 返回本身
|
||||
*/
|
||||
public function setPrefix(int $prefix = self::API_NORMAL): OneBotV11
|
||||
{
|
||||
$this->prefix = $prefix;
|
||||
return $this;
|
||||
@@ -101,12 +115,13 @@ class OneBotV11
|
||||
|
||||
/**
|
||||
* 发送私聊消息
|
||||
* @see https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#send_private_msg-%E5%8F%91%E9%80%81%E7%A7%81%E8%81%8A%E6%B6%88%E6%81%AF
|
||||
* @param $user_id
|
||||
* @param $message
|
||||
* @return null|array|bool
|
||||
* @see https://github.com/botuniverse/onebot-11/blob/master/api/public.md#send_private_msg-%E5%8F%91%E9%80%81%E7%A7%81%E8%81%8A%E6%B6%88%E6%81%AF
|
||||
* @param int|string $user_id 用户ID
|
||||
* @param string $message 消息内容
|
||||
* @param bool $auto_escape 是否自动转义(默认为false)
|
||||
* @return array|bool 返回API调用结果(数组)或异步API调用状态(bool)
|
||||
*/
|
||||
public function sendPrivateMsg($user_id, $message, bool $auto_escape = false)
|
||||
public function sendPrivateMsg($user_id, string $message, bool $auto_escape = false)
|
||||
{
|
||||
return $this->processAPI($this->connection, [
|
||||
'action' => $this->getActionName($this->prefix, __FUNCTION__),
|
||||
@@ -120,12 +135,13 @@ class OneBotV11
|
||||
|
||||
/**
|
||||
* 发送群消息
|
||||
* @see https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#send_group_msg-%E5%8F%91%E9%80%81%E7%BE%A4%E6%B6%88%E6%81%AF
|
||||
* @param $group_id
|
||||
* @param $message
|
||||
* @return null|array|bool
|
||||
* @see https://github.com/botuniverse/onebot-11/blob/master/api/public.md#send_group_msg-%E5%8F%91%E9%80%81%E7%BE%A4%E6%B6%88%E6%81%AF
|
||||
* @param int|string $group_id 群组ID
|
||||
* @param string $message 消息内容
|
||||
* @param bool $auto_escape 是否自动转义(默认为false)
|
||||
* @return array|bool 返回API调用结果(数组)或异步API调用状态(bool)
|
||||
*/
|
||||
public function sendGroupMsg($group_id, $message, bool $auto_escape = false)
|
||||
public function sendGroupMsg($group_id, string $message, bool $auto_escape = false)
|
||||
{
|
||||
return $this->processAPI($this->connection, [
|
||||
'action' => $this->getActionName($this->prefix, __FUNCTION__),
|
||||
@@ -139,13 +155,14 @@ class OneBotV11
|
||||
|
||||
/**
|
||||
* 发送消息
|
||||
* @see https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#send_msg-%E5%8F%91%E9%80%81%E6%B6%88%E6%81%AF
|
||||
* @param $message_type
|
||||
* @param $target_id
|
||||
* @param $message
|
||||
* @return null|array|bool
|
||||
* @see https://github.com/botuniverse/onebot-11/blob/master/api/public.md#send_msg-%E5%8F%91%E9%80%81%E6%B6%88%E6%81%AF
|
||||
* @param string $message_type 消息类型
|
||||
* @param int|string $target_id 目标ID
|
||||
* @param string $message 消息内容
|
||||
* @param bool $auto_escape 是否自动转义(默认为false)
|
||||
* @return array|bool 返回API调用结果(数组)或异步API调用状态(bool)
|
||||
*/
|
||||
public function sendMsg($message_type, $target_id, $message, bool $auto_escape = false)
|
||||
public function sendMsg(string $message_type, $target_id, string $message, bool $auto_escape = false)
|
||||
{
|
||||
return $this->processAPI($this->connection, [
|
||||
'action' => $this->getActionName($this->prefix, __FUNCTION__),
|
||||
@@ -160,9 +177,9 @@ class OneBotV11
|
||||
|
||||
/**
|
||||
* 撤回消息
|
||||
* @see https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#delete_msg-%E6%92%A4%E5%9B%9E%E6%B6%88%E6%81%AF
|
||||
* @param $message_id
|
||||
* @return null|array|bool
|
||||
* @see https://github.com/botuniverse/onebot-11/blob/master/api/public.md#delete_msg-%E6%92%A4%E5%9B%9E%E6%B6%88%E6%81%AF
|
||||
* @param int|string $message_id 消息ID
|
||||
* @return array|bool 返回API调用结果(数组)或异步API调用状态(bool)
|
||||
*/
|
||||
public function deleteMsg($message_id)
|
||||
{
|
||||
@@ -176,9 +193,9 @@ class OneBotV11
|
||||
|
||||
/**
|
||||
* 获取消息
|
||||
* @see https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#get_msg-%E8%8E%B7%E5%8F%96%E6%B6%88%E6%81%AF
|
||||
* @param $message_id
|
||||
* @return null|array|bool
|
||||
* @see https://github.com/botuniverse/onebot-11/blob/master/api/public.md#get_msg-%E8%8E%B7%E5%8F%96%E6%B6%88%E6%81%AF
|
||||
* @param int|string $message_id 消息ID
|
||||
* @return array|bool 返回API调用结果(数组)或异步API调用状态(bool)
|
||||
*/
|
||||
public function getMsg($message_id)
|
||||
{
|
||||
@@ -192,9 +209,9 @@ class OneBotV11
|
||||
|
||||
/**
|
||||
* 获取合并转发消息
|
||||
* @see https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#get_forward_msg-%E8%8E%B7%E5%8F%96%E5%90%88%E5%B9%B6%E8%BD%AC%E5%8F%91%E6%B6%88%E6%81%AF
|
||||
* @param $id
|
||||
* @return null|array|bool
|
||||
* @see https://github.com/botuniverse/onebot-11/blob/master/api/public.md#get_forward_msg-%E8%8E%B7%E5%8F%96%E5%90%88%E5%B9%B6%E8%BD%AC%E5%8F%91%E6%B6%88%E6%81%AF
|
||||
* @param int|string $id ID
|
||||
* @return array|bool 返回API调用结果(数组)或异步API调用状态(bool)
|
||||
*/
|
||||
public function getForwardMsg($id)
|
||||
{
|
||||
@@ -208,9 +225,10 @@ class OneBotV11
|
||||
|
||||
/**
|
||||
* 发送好友赞
|
||||
* @see https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#send_like-%E5%8F%91%E9%80%81%E5%A5%BD%E5%8F%8B%E8%B5%9E
|
||||
* @param $user_id
|
||||
* @return null|array|bool
|
||||
* @see https://github.com/botuniverse/onebot-11/blob/master/api/public.md#send_like-%E5%8F%91%E9%80%81%E5%A5%BD%E5%8F%8B%E8%B5%9E
|
||||
* @param int|string $user_id 用户ID
|
||||
* @param int $times 时间
|
||||
* @return array|bool 返回API调用结果(数组)或异步API调用状态(bool)
|
||||
*/
|
||||
public function sendLike($user_id, int $times = 1)
|
||||
{
|
||||
@@ -225,10 +243,10 @@ class OneBotV11
|
||||
|
||||
/**
|
||||
* 群组踢人
|
||||
* @see https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#set_group_kick-%E7%BE%A4%E7%BB%84%E8%B8%A2%E4%BA%BA
|
||||
* @param $group_id
|
||||
* @param $user_id
|
||||
* @return null|array|bool
|
||||
* @see https://github.com/botuniverse/onebot-11/blob/master/api/public.md#set_group_kick-%E7%BE%A4%E7%BB%84%E8%B8%A2%E4%BA%BA
|
||||
* @param int|string $group_id 群ID
|
||||
* @param int|string $user_id 用户ID
|
||||
* @return array|bool 返回API调用结果(数组)或异步API调用状态(bool)
|
||||
*/
|
||||
public function setGroupKick($group_id, $user_id, bool $reject_add_request = false)
|
||||
{
|
||||
@@ -244,10 +262,11 @@ class OneBotV11
|
||||
|
||||
/**
|
||||
* 群组单人禁言
|
||||
* @see https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#set_group_ban-%E7%BE%A4%E7%BB%84%E5%8D%95%E4%BA%BA%E7%A6%81%E8%A8%80
|
||||
* @param $group_id
|
||||
* @param $user_id
|
||||
* @return null|array|bool
|
||||
* @see https://github.com/botuniverse/onebot-11/blob/master/api/public.md#set_group_ban-%E7%BE%A4%E7%BB%84%E5%8D%95%E4%BA%BA%E7%A6%81%E8%A8%80
|
||||
* @param int|string $group_id 群ID
|
||||
* @param int|string $user_id 用户ID
|
||||
* @param int $duration 禁言时长
|
||||
* @return array|bool 返回API调用结果(数组)或异步API调用状态(bool)
|
||||
*/
|
||||
public function setGroupBan($group_id, $user_id, int $duration = 1800)
|
||||
{
|
||||
@@ -263,10 +282,10 @@ class OneBotV11
|
||||
|
||||
/**
|
||||
* 群组匿名用户禁言
|
||||
* @see https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#set_group_anonymous_ban-%E7%BE%A4%E7%BB%84%E5%8C%BF%E5%90%8D%E7%94%A8%E6%88%B7%E7%A6%81%E8%A8%80
|
||||
* @param $group_id
|
||||
* @param $anonymous_or_flag
|
||||
* @return null|array|bool
|
||||
* @see https://github.com/botuniverse/onebot-11/blob/master/api/public.md#set_group_anonymous_ban-%E7%BE%A4%E7%BB%84%E5%8C%BF%E5%90%8D%E7%94%A8%E6%88%B7%E7%A6%81%E8%A8%80
|
||||
* @param int|string $group_id 群ID
|
||||
* @param array|int|string $anonymous_or_flag 匿名禁言Flag或匿名用户对象
|
||||
* @return array|bool 返回API调用结果(数组)或异步API调用状态(bool)
|
||||
*/
|
||||
public function setGroupAnonymousBan($group_id, $anonymous_or_flag, int $duration = 1800)
|
||||
{
|
||||
@@ -282,9 +301,9 @@ class OneBotV11
|
||||
|
||||
/**
|
||||
* 群组全员禁言
|
||||
* @see https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#set_group_whole_ban-%E7%BE%A4%E7%BB%84%E5%85%A8%E5%91%98%E7%A6%81%E8%A8%80
|
||||
* @param $group_id
|
||||
* @return null|array|bool
|
||||
* @see https://github.com/botuniverse/onebot-11/blob/master/api/public.md#set_group_whole_ban-%E7%BE%A4%E7%BB%84%E5%85%A8%E5%91%98%E7%A6%81%E8%A8%80
|
||||
* @param int|string $group_id 群ID
|
||||
* @return array|bool 返回API调用结果(数组)或异步API调用状态(bool)
|
||||
*/
|
||||
public function setGroupWholeBan($group_id, bool $enable = true)
|
||||
{
|
||||
@@ -299,10 +318,10 @@ class OneBotV11
|
||||
|
||||
/**
|
||||
* 群组设置管理员
|
||||
* @see https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#set_group_admin-%E7%BE%A4%E7%BB%84%E8%AE%BE%E7%BD%AE%E7%AE%A1%E7%90%86%E5%91%98
|
||||
* @param $group_id
|
||||
* @param $user_id
|
||||
* @return null|array|bool
|
||||
* @see https://github.com/botuniverse/onebot-11/blob/master/api/public.md#set_group_admin-%E7%BE%A4%E7%BB%84%E8%AE%BE%E7%BD%AE%E7%AE%A1%E7%90%86%E5%91%98
|
||||
* @param int|string $group_id 群ID
|
||||
* @param int|string $user_id 用户ID
|
||||
* @return array|bool 返回API调用结果(数组)或异步API调用状态(bool)
|
||||
*/
|
||||
public function setGroupAdmin($group_id, $user_id, bool $enable = true)
|
||||
{
|
||||
@@ -318,9 +337,10 @@ class OneBotV11
|
||||
|
||||
/**
|
||||
* 群组匿名
|
||||
* @see https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#set_group_anonymous-%E7%BE%A4%E7%BB%84%E5%8C%BF%E5%90%8D
|
||||
* @param $group_id
|
||||
* @return null|array|bool
|
||||
* @see https://github.com/botuniverse/onebot-11/blob/master/api/public.md#set_group_anonymous-%E7%BE%A4%E7%BB%84%E5%8C%BF%E5%90%8D
|
||||
* @param int|string $group_id 群ID
|
||||
* @param bool $enable 是否启用(默认为true)
|
||||
* @return array|bool 返回API调用结果(数组)或异步API调用状态(bool)
|
||||
*/
|
||||
public function setGroupAnonymous($group_id, bool $enable = true)
|
||||
{
|
||||
@@ -335,10 +355,11 @@ class OneBotV11
|
||||
|
||||
/**
|
||||
* 设置群名片(群备注)
|
||||
* @see https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#set_group_card-%E8%AE%BE%E7%BD%AE%E7%BE%A4%E5%90%8D%E7%89%87%E7%BE%A4%E5%A4%87%E6%B3%A8
|
||||
* @param $group_id
|
||||
* @param $user_id
|
||||
* @return null|array|bool
|
||||
* @see https://github.com/botuniverse/onebot-11/blob/master/api/public.md#set_group_card-%E8%AE%BE%E7%BD%AE%E7%BE%A4%E5%90%8D%E7%89%87%E7%BE%A4%E5%A4%87%E6%B3%A8
|
||||
* @param int|string $group_id 群ID
|
||||
* @param int|string $user_id 用户ID
|
||||
* @param string $card 名片内容(默认为空)
|
||||
* @return array|bool 返回API调用结果(数组)或异步API调用状态(bool)
|
||||
*/
|
||||
public function setGroupCard($group_id, $user_id, string $card = '')
|
||||
{
|
||||
@@ -354,12 +375,12 @@ class OneBotV11
|
||||
|
||||
/**
|
||||
* 设置群名
|
||||
* @see https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#set_group_name-%E8%AE%BE%E7%BD%AE%E7%BE%A4%E5%90%8D
|
||||
* @param $group_id
|
||||
* @param $group_name
|
||||
* @return null|array|bool
|
||||
* @see https://github.com/botuniverse/onebot-11/blob/master/api/public.md#set_group_name-%E8%AE%BE%E7%BD%AE%E7%BE%A4%E5%90%8D
|
||||
* @param int|string $group_id 群ID
|
||||
* @param string $group_name 群名
|
||||
* @return array|bool 返回API调用结果(数组)或异步API调用状态(bool)
|
||||
*/
|
||||
public function setGroupName($group_id, $group_name)
|
||||
public function setGroupName($group_id, string $group_name)
|
||||
{
|
||||
return $this->processAPI($this->connection, [
|
||||
'action' => $this->getActionName($this->prefix, __FUNCTION__),
|
||||
@@ -372,9 +393,10 @@ class OneBotV11
|
||||
|
||||
/**
|
||||
* 退出群组
|
||||
* @see https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#set_group_leave-%E9%80%80%E5%87%BA%E7%BE%A4%E7%BB%84
|
||||
* @param $group_id
|
||||
* @return null|array|bool
|
||||
* @see https://github.com/botuniverse/onebot-11/blob/master/api/public.md#set_group_leave-%E9%80%80%E5%87%BA%E7%BE%A4%E7%BB%84
|
||||
* @param int|string $group_id 群ID
|
||||
* @param bool $is_dismiss 是否解散(默认为false)
|
||||
* @return array|bool 返回API调用结果(数组)或异步API调用状态(bool)
|
||||
*/
|
||||
public function setGroupLeave($group_id, bool $is_dismiss = false)
|
||||
{
|
||||
@@ -389,10 +411,12 @@ class OneBotV11
|
||||
|
||||
/**
|
||||
* 设置群组专属头衔
|
||||
* @see https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#set_group_special_title-%E8%AE%BE%E7%BD%AE%E7%BE%A4%E7%BB%84%E4%B8%93%E5%B1%9E%E5%A4%B4%E8%A1%94
|
||||
* @param $group_id
|
||||
* @param $user_id
|
||||
* @return null|array|bool
|
||||
* @see https://github.com/botuniverse/onebot-11/blob/master/api/public.md#set_group_special_title-%E8%AE%BE%E7%BD%AE%E7%BE%A4%E7%BB%84%E4%B8%93%E5%B1%9E%E5%A4%B4%E8%A1%94
|
||||
* @param int|string $group_id 群ID
|
||||
* @param int|string $user_id 用户ID
|
||||
* @param string $special_title 专属头衔内容
|
||||
* @param int $duration 持续时间(默认为-1,永久)
|
||||
* @return array|bool 返回API调用结果(数组)或异步API调用状态(bool)
|
||||
*/
|
||||
public function setGroupSpecialTitle($group_id, $user_id, string $special_title = '', int $duration = -1)
|
||||
{
|
||||
@@ -409,9 +433,11 @@ class OneBotV11
|
||||
|
||||
/**
|
||||
* 处理加好友请求
|
||||
* @see https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#set_friend_add_request-%E5%A4%84%E7%90%86%E5%8A%A0%E5%A5%BD%E5%8F%8B%E8%AF%B7%E6%B1%82
|
||||
* @param $flag
|
||||
* @return null|array|bool
|
||||
* @see https://github.com/botuniverse/onebot-11/blob/master/api/public.md#set_friend_add_request-%E5%A4%84%E7%90%86%E5%8A%A0%E5%A5%BD%E5%8F%8B%E8%AF%B7%E6%B1%82
|
||||
* @param array|int|string $flag 处理加好友请求的flag
|
||||
* @param bool $approve 是否同意(默认为true)
|
||||
* @param string $remark 设置昵称(默认不设置)
|
||||
* @return array|bool 返回API调用结果(数组)或异步API调用状态(bool)
|
||||
*/
|
||||
public function setFriendAddRequest($flag, bool $approve = true, string $remark = '')
|
||||
{
|
||||
@@ -427,12 +453,14 @@ class OneBotV11
|
||||
|
||||
/**
|
||||
* 处理加群请求/邀请
|
||||
* @see https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#set_group_add_request-%E5%A4%84%E7%90%86%E5%8A%A0%E7%BE%A4%E8%AF%B7%E6%B1%82%E9%82%80%E8%AF%B7
|
||||
* @param $flag
|
||||
* @param $sub_type
|
||||
* @return null|array|bool
|
||||
* @see https://github.com/botuniverse/onebot-11/blob/master/api/public.md#set_group_add_request-%E5%A4%84%E7%90%86%E5%8A%A0%E7%BE%A4%E8%AF%B7%E6%B1%82%E9%82%80%E8%AF%B7
|
||||
* @param array|int|string $flag 处理加群请求的flag
|
||||
* @param string $sub_type 处理请求类型(包含add和invite)
|
||||
* @param bool $approve 是否同意(默认为true)
|
||||
* @param string $reason 拒绝理由(仅在拒绝时有效,默认为空)
|
||||
* @return array|bool 返回API调用结果(数组)或异步API调用状态(bool)
|
||||
*/
|
||||
public function setGroupAddRequest($flag, $sub_type, bool $approve = true, string $reason = '')
|
||||
public function setGroupAddRequest($flag, string $sub_type, bool $approve = true, string $reason = '')
|
||||
{
|
||||
return $this->processAPI($this->connection, [
|
||||
'action' => $this->getActionName($this->prefix, __FUNCTION__),
|
||||
@@ -447,8 +475,8 @@ class OneBotV11
|
||||
|
||||
/**
|
||||
* 获取登录号信息
|
||||
* @see https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#get_login_info-%E8%8E%B7%E5%8F%96%E7%99%BB%E5%BD%95%E5%8F%B7%E4%BF%A1%E6%81%AF
|
||||
* @return null|array|bool
|
||||
* @see https://github.com/botuniverse/onebot-11/blob/master/api/public.md#get_login_info-%E8%8E%B7%E5%8F%96%E7%99%BB%E5%BD%95%E5%8F%B7%E4%BF%A1%E6%81%AF
|
||||
* @return array|bool 返回API调用结果(数组)或异步API调用状态(bool)
|
||||
*/
|
||||
public function getLoginInfo()
|
||||
{
|
||||
@@ -457,9 +485,10 @@ class OneBotV11
|
||||
|
||||
/**
|
||||
* 获取陌生人信息
|
||||
* @see https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#get_stranger_info-%E8%8E%B7%E5%8F%96%E9%99%8C%E7%94%9F%E4%BA%BA%E4%BF%A1%E6%81%AF
|
||||
* @param $user_id
|
||||
* @return null|array|bool
|
||||
* @see https://github.com/botuniverse/onebot-11/blob/master/api/public.md#get_stranger_info-%E8%8E%B7%E5%8F%96%E9%99%8C%E7%94%9F%E4%BA%BA%E4%BF%A1%E6%81%AF
|
||||
* @param int|string $user_id 用户ID
|
||||
* @param bool $no_cache 是否不使用缓存(默认为false)
|
||||
* @return array|bool 返回API调用结果(数组)或异步API调用状态(bool)
|
||||
*/
|
||||
public function getStrangerInfo($user_id, bool $no_cache = false)
|
||||
{
|
||||
@@ -474,8 +503,8 @@ class OneBotV11
|
||||
|
||||
/**
|
||||
* 获取好友列表
|
||||
* @see https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#get_friend_list-%E8%8E%B7%E5%8F%96%E5%A5%BD%E5%8F%8B%E5%88%97%E8%A1%A8
|
||||
* @return null|array|bool
|
||||
* @see https://github.com/botuniverse/onebot-11/blob/master/api/public.md#get_friend_list-%E8%8E%B7%E5%8F%96%E5%A5%BD%E5%8F%8B%E5%88%97%E8%A1%A8
|
||||
* @return array|bool 返回API调用结果(数组)或异步API调用状态(bool)
|
||||
*/
|
||||
public function getFriendList()
|
||||
{
|
||||
@@ -486,9 +515,9 @@ class OneBotV11
|
||||
|
||||
/**
|
||||
* 获取群信息
|
||||
* @see https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#get_group_info-%E8%8E%B7%E5%8F%96%E7%BE%A4%E4%BF%A1%E6%81%AF
|
||||
* @param $group_id
|
||||
* @return null|array|bool
|
||||
* @see https://github.com/botuniverse/onebot-11/blob/master/api/public.md#get_group_info-%E8%8E%B7%E5%8F%96%E7%BE%A4%E4%BF%A1%E6%81%AF
|
||||
* @param int|string $group_id 群ID
|
||||
* @return array|bool 返回API调用结果(数组)或异步API调用状态(bool)
|
||||
*/
|
||||
public function getGroupInfo($group_id, bool $no_cache = false)
|
||||
{
|
||||
@@ -503,8 +532,8 @@ class OneBotV11
|
||||
|
||||
/**
|
||||
* 获取群列表
|
||||
* @see https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#get_group_list-%E8%8E%B7%E5%8F%96%E7%BE%A4%E5%88%97%E8%A1%A8
|
||||
* @return null|array|bool
|
||||
* @see https://github.com/botuniverse/onebot-11/blob/master/api/public.md#get_group_list-%E8%8E%B7%E5%8F%96%E7%BE%A4%E5%88%97%E8%A1%A8
|
||||
* @return array|bool 返回API调用结果(数组)或异步API调用状态(bool)
|
||||
*/
|
||||
public function getGroupList()
|
||||
{
|
||||
@@ -515,10 +544,10 @@ class OneBotV11
|
||||
|
||||
/**
|
||||
* 获取群成员信息
|
||||
* @see https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#get_group_member_info-%E8%8E%B7%E5%8F%96%E7%BE%A4%E6%88%90%E5%91%98%E4%BF%A1%E6%81%AF
|
||||
* @param $group_id
|
||||
* @param $user_id
|
||||
* @return null|array|bool
|
||||
* @see https://github.com/botuniverse/onebot-11/blob/master/api/public.md#get_group_member_info-%E8%8E%B7%E5%8F%96%E7%BE%A4%E6%88%90%E5%91%98%E4%BF%A1%E6%81%AF
|
||||
* @param int|string $group_id 群ID
|
||||
* @param int|string $user_id 用户ID
|
||||
* @return array|bool 返回API调用结果(数组)或异步API调用状态(bool)
|
||||
*/
|
||||
public function getGroupMemberInfo($group_id, $user_id, bool $no_cache = false)
|
||||
{
|
||||
@@ -534,9 +563,9 @@ class OneBotV11
|
||||
|
||||
/**
|
||||
* 获取群成员列表
|
||||
* @see https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#get_group_member_list-%E8%8E%B7%E5%8F%96%E7%BE%A4%E6%88%90%E5%91%98%E5%88%97%E8%A1%A8
|
||||
* @param $group_id
|
||||
* @return null|array|bool
|
||||
* @see https://github.com/botuniverse/onebot-11/blob/master/api/public.md#get_group_member_list-%E8%8E%B7%E5%8F%96%E7%BE%A4%E6%88%90%E5%91%98%E5%88%97%E8%A1%A8
|
||||
* @param int|string $group_id 群ID
|
||||
* @return array|bool 返回API调用结果(数组)或异步API调用状态(bool)
|
||||
*/
|
||||
public function getGroupMemberList($group_id)
|
||||
{
|
||||
@@ -550,12 +579,12 @@ class OneBotV11
|
||||
|
||||
/**
|
||||
* 获取群荣誉信息
|
||||
* @see https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#get_group_honor_info-%E8%8E%B7%E5%8F%96%E7%BE%A4%E8%8D%A3%E8%AA%89%E4%BF%A1%E6%81%AF
|
||||
* @param $group_id
|
||||
* @param $type
|
||||
* @return null|array|bool
|
||||
* @see https://github.com/botuniverse/onebot-11/blob/master/api/public.md#get_group_honor_info-%E8%8E%B7%E5%8F%96%E7%BE%A4%E8%8D%A3%E8%AA%89%E4%BF%A1%E6%81%AF
|
||||
* @param int|string $group_id 群ID
|
||||
* @param string $type 荣誉类型
|
||||
* @return array|bool 返回API调用结果(数组)或异步API调用状态(bool)
|
||||
*/
|
||||
public function getGroupHonorInfo($group_id, $type)
|
||||
public function getGroupHonorInfo($group_id, string $type)
|
||||
{
|
||||
return $this->processAPI($this->connection, [
|
||||
'action' => $this->getActionName($this->prefix, __FUNCTION__),
|
||||
@@ -568,8 +597,8 @@ class OneBotV11
|
||||
|
||||
/**
|
||||
* 获取 CSRF Token
|
||||
* @see https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#get_csrf_token-%E8%8E%B7%E5%8F%96-csrf-token
|
||||
* @return null|array|bool
|
||||
* @see https://github.com/botuniverse/onebot-11/blob/master/api/public.md#get_csrf_token-%E8%8E%B7%E5%8F%96-csrf-token
|
||||
* @return array|bool 返回API调用结果(数组)或异步API调用状态(bool)
|
||||
*/
|
||||
public function getCsrfToken()
|
||||
{
|
||||
@@ -580,8 +609,8 @@ class OneBotV11
|
||||
|
||||
/**
|
||||
* 获取 QQ 相关接口凭证
|
||||
* @see https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#get_credentials-%E8%8E%B7%E5%8F%96-qq-%E7%9B%B8%E5%85%B3%E6%8E%A5%E5%8F%A3%E5%87%AD%E8%AF%81
|
||||
* @return null|array|bool
|
||||
* @see https://github.com/botuniverse/onebot-11/blob/master/api/public.md#get_credentials-%E8%8E%B7%E5%8F%96-qq-%E7%9B%B8%E5%85%B3%E6%8E%A5%E5%8F%A3%E5%87%AD%E8%AF%81
|
||||
* @return array|bool 返回API调用结果(数组)或异步API调用状态(bool)
|
||||
*/
|
||||
public function getCredentials(string $domain = '')
|
||||
{
|
||||
@@ -595,12 +624,12 @@ class OneBotV11
|
||||
|
||||
/**
|
||||
* 获取语音
|
||||
* @see https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#get_record-%E8%8E%B7%E5%8F%96%E8%AF%AD%E9%9F%B3
|
||||
* @param $file
|
||||
* @param $out_format
|
||||
* @return null|array|bool
|
||||
* @see https://github.com/botuniverse/onebot-11/blob/master/api/public.md#get_record-%E8%8E%B7%E5%8F%96%E8%AF%AD%E9%9F%B3
|
||||
* @param string $file 文件
|
||||
* @param string $out_format 输出格式
|
||||
* @return array|bool 返回API调用结果(数组)或异步API调用状态(bool)
|
||||
*/
|
||||
public function getRecord($file, $out_format)
|
||||
public function getRecord(string $file, string $out_format)
|
||||
{
|
||||
return $this->processAPI($this->connection, [
|
||||
'action' => $this->getActionName($this->prefix, __FUNCTION__),
|
||||
@@ -613,11 +642,11 @@ class OneBotV11
|
||||
|
||||
/**
|
||||
* 获取图片
|
||||
* @see https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#get_image-%E8%8E%B7%E5%8F%96%E5%9B%BE%E7%89%87
|
||||
* @param $file
|
||||
* @return null|array|bool
|
||||
* @see https://github.com/botuniverse/onebot-11/blob/master/api/public.md#get_image-%E8%8E%B7%E5%8F%96%E5%9B%BE%E7%89%87
|
||||
* @param string $file 文件
|
||||
* @return array|bool 返回API调用结果(数组)或异步API调用状态(bool)
|
||||
*/
|
||||
public function getImage($file)
|
||||
public function getImage(string $file)
|
||||
{
|
||||
return $this->processAPI($this->connection, [
|
||||
'action' => $this->getActionName($this->prefix, __FUNCTION__),
|
||||
@@ -629,8 +658,8 @@ class OneBotV11
|
||||
|
||||
/**
|
||||
* 检查是否可以发送图片
|
||||
* @see https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#can_send_image-%E6%A3%80%E6%9F%A5%E6%98%AF%E5%90%A6%E5%8F%AF%E4%BB%A5%E5%8F%91%E9%80%81%E5%9B%BE%E7%89%87
|
||||
* @return null|array|bool
|
||||
* @see https://github.com/botuniverse/onebot-11/blob/master/api/public.md#can_send_image-%E6%A3%80%E6%9F%A5%E6%98%AF%E5%90%A6%E5%8F%AF%E4%BB%A5%E5%8F%91%E9%80%81%E5%9B%BE%E7%89%87
|
||||
* @return array|bool 返回API调用结果(数组)或异步API调用状态(bool)
|
||||
*/
|
||||
public function canSendImage()
|
||||
{
|
||||
@@ -641,8 +670,8 @@ class OneBotV11
|
||||
|
||||
/**
|
||||
* 检查是否可以发送语音
|
||||
* @see https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#can_send_record-%E6%A3%80%E6%9F%A5%E6%98%AF%E5%90%A6%E5%8F%AF%E4%BB%A5%E5%8F%91%E9%80%81%E8%AF%AD%E9%9F%B3
|
||||
* @return null|array|bool
|
||||
* @see https://github.com/botuniverse/onebot-11/blob/master/api/public.md#can_send_record-%E6%A3%80%E6%9F%A5%E6%98%AF%E5%90%A6%E5%8F%AF%E4%BB%A5%E5%8F%91%E9%80%81%E8%AF%AD%E9%9F%B3
|
||||
* @return array|bool 返回API调用结果(数组)或异步API调用状态(bool)
|
||||
*/
|
||||
public function canSendRecord()
|
||||
{
|
||||
@@ -653,8 +682,8 @@ class OneBotV11
|
||||
|
||||
/**
|
||||
* 获取运行状态
|
||||
* @see https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#get_status-%E8%8E%B7%E5%8F%96%E8%BF%90%E8%A1%8C%E7%8A%B6%E6%80%81
|
||||
* @return null|array|bool
|
||||
* @see https://github.com/botuniverse/onebot-11/blob/master/api/public.md#get_status-%E8%8E%B7%E5%8F%96%E8%BF%90%E8%A1%8C%E7%8A%B6%E6%80%81
|
||||
* @return array|bool 返回API调用结果(数组)或异步API调用状态(bool)
|
||||
*/
|
||||
public function getStatus()
|
||||
{
|
||||
@@ -665,8 +694,8 @@ class OneBotV11
|
||||
|
||||
/**
|
||||
* 获取版本信息
|
||||
* @see https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#get_version_info-%E8%8E%B7%E5%8F%96%E7%89%88%E6%9C%AC%E4%BF%A1%E6%81%AF
|
||||
* @return null|array|bool
|
||||
* @see https://github.com/botuniverse/onebot-11/blob/master/api/public.md#get_version_info-%E8%8E%B7%E5%8F%96%E7%89%88%E6%9C%AC%E4%BF%A1%E6%81%AF
|
||||
* @return array|bool 返回API调用结果(数组)或异步API调用状态(bool)
|
||||
*/
|
||||
public function getVersionInfo()
|
||||
{
|
||||
@@ -677,8 +706,9 @@ class OneBotV11
|
||||
|
||||
/**
|
||||
* 重启 OneBot 实现
|
||||
* @see https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#set_restart-%E9%87%8D%E5%90%AF-onebot-%E5%AE%9E%E7%8E%B0
|
||||
* @return null|array|bool
|
||||
* @see https://github.com/botuniverse/onebot-11/blob/master/api/public.md#set_restart-%E9%87%8D%E5%90%AF-onebot-%E5%AE%9E%E7%8E%B0
|
||||
* @param int $delay 延迟时间(毫秒,默认为0)
|
||||
* @return array|bool 返回API调用结果(数组)或异步API调用状态(bool)
|
||||
*/
|
||||
public function setRestart(int $delay = 0)
|
||||
{
|
||||
@@ -692,8 +722,8 @@ class OneBotV11
|
||||
|
||||
/**
|
||||
* 清理缓存
|
||||
* @see https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#clean_cache-%E6%B8%85%E7%90%86%E7%BC%93%E5%AD%98
|
||||
* @return null|array|bool
|
||||
* @see https://github.com/botuniverse/onebot-11/blob/master/api/public.md#clean_cache-%E6%B8%85%E7%90%86%E7%BC%93%E5%AD%98
|
||||
* @return array|bool 返回API调用结果(数组)或异步API调用状态(bool)
|
||||
*/
|
||||
public function cleanCache()
|
||||
{
|
||||
@@ -705,8 +735,9 @@ class OneBotV11
|
||||
/**
|
||||
* 获取内置支持的扩展API对象
|
||||
* 现支持 go-cqhttp 的扩展API
|
||||
* @params string $package_name 包名
|
||||
* @throws ZMKnownException
|
||||
* @return mixed
|
||||
* @return mixed 返回包的操作对象
|
||||
*/
|
||||
public function getExtendedAPI(string $package_name = 'go-cqhttp')
|
||||
{
|
||||
@@ -719,7 +750,12 @@ class OneBotV11
|
||||
throw new ZMKnownException(zm_internal_errcode('E00071'), '无法找到对应的调用扩展类');
|
||||
}
|
||||
|
||||
public function callExtendedAPI($action, $params = [])
|
||||
/**
|
||||
* @param string $action 动作(API)名称
|
||||
* @param array $params 参数
|
||||
* @return array|bool 返回API调用结果(数组)或异步API调用状态(bool)
|
||||
*/
|
||||
public function callExtendedAPI(string $action, array $params = [])
|
||||
{
|
||||
return $this->processAPI($this->connection, [
|
||||
'action' => $action,
|
||||
|
||||
74
src/ZM/API/Proxies/Bot/AbstractBotProxy.php
Normal file
74
src/ZM/API/Proxies/Bot/AbstractBotProxy.php
Normal file
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace ZM\API\Proxies\Bot;
|
||||
|
||||
use ZM\API\ZMRobot;
|
||||
|
||||
/**
|
||||
* @mixin ZMRobot
|
||||
*/
|
||||
abstract class AbstractBotProxy
|
||||
{
|
||||
/**
|
||||
* 传入的机器人实例
|
||||
*
|
||||
* @var ZMRobot
|
||||
*/
|
||||
protected $bot;
|
||||
|
||||
/**
|
||||
* 构造函数
|
||||
*
|
||||
* @param AbstractBotProxy|ZMRobot $bot 调用此代理的机器人实例
|
||||
*/
|
||||
public function __construct($bot)
|
||||
{
|
||||
$this->bot = $bot;
|
||||
}
|
||||
|
||||
/**
|
||||
* 在传入的机器人实例上调用方法
|
||||
*
|
||||
* @param string $name 方法名
|
||||
* @param array $arguments 参数
|
||||
* @return mixed
|
||||
*/
|
||||
public function __call(string $name, array $arguments)
|
||||
{
|
||||
return $this->bot->{$name}(...$arguments);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取传入的机器人实例的属性
|
||||
*
|
||||
* @param string $name 属性名
|
||||
* @return mixed
|
||||
*/
|
||||
public function __get(string $name)
|
||||
{
|
||||
return $this->bot->{$name};
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置传入的机器人实例的属性
|
||||
*
|
||||
* @param string $name 属性名
|
||||
* @param mixed $value 属性值
|
||||
*/
|
||||
public function __set(string $name, $value)
|
||||
{
|
||||
$this->bot->{$name} = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断传入的机器人实例的属性是否存在
|
||||
*
|
||||
* @param string $name 属性名
|
||||
*/
|
||||
public function __isset(string $name): bool
|
||||
{
|
||||
return isset($this->bot->{$name});
|
||||
}
|
||||
}
|
||||
43
src/ZM/API/Proxies/Bot/AllBotsProxy.php
Normal file
43
src/ZM/API/Proxies/Bot/AllBotsProxy.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace ZM\API\Proxies\Bot;
|
||||
|
||||
use ReflectionException;
|
||||
use ReflectionMethod;
|
||||
use ReflectionNamedType;
|
||||
use ZM\API\ZMRobot;
|
||||
use ZM\Console\Console;
|
||||
|
||||
class AllBotsProxy extends AbstractBotProxy
|
||||
{
|
||||
/**
|
||||
* 在所有机器人实例上调用方法
|
||||
*
|
||||
* @param string $name 方法名
|
||||
* @param array $arguments 参数
|
||||
* @throws ReflectionException
|
||||
* @return array<mixed> 返回一个包含所有执行结果的数组,键名为机器人ID
|
||||
*/
|
||||
public function __call(string $name, array $arguments)
|
||||
{
|
||||
// 如果调用的方法为代理方法,则传入当前代理作为参数
|
||||
// 一般此情况代表用户进行嵌套代理,即 `->all()->allGroups()` 等情况
|
||||
$reflection = new ReflectionMethod(ZMRobot::class, $name);
|
||||
if (($return = $reflection->getReturnType()) && $return instanceof ReflectionNamedType && str_contains($return->getName(), 'Proxy')) {
|
||||
Console::debug("Trying to construct proxy {$name} inside proxy, returning nested proxy.");
|
||||
// 插入当前代理作为第一个参数
|
||||
array_unshift($arguments, $this);
|
||||
return $this->bot->{$name}(...$arguments);
|
||||
}
|
||||
|
||||
$result = [];
|
||||
// 遍历所有机器人实例
|
||||
foreach ($this->bot::getAllRobot() as $bot) {
|
||||
Console::debug("Calling {$name} on bot {$bot->getSelfId()}.");
|
||||
$result[$bot->getSelfId()] = $bot->{$name}(...$arguments);
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
43
src/ZM/API/Proxies/Bot/AllGroupsProxy.php
Normal file
43
src/ZM/API/Proxies/Bot/AllGroupsProxy.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace ZM\API\Proxies\Bot;
|
||||
|
||||
use ReflectionException;
|
||||
use ZM\API\ZMRobot;
|
||||
use ZM\Console\Console;
|
||||
|
||||
class AllGroupsProxy extends AbstractBotProxy
|
||||
{
|
||||
/**
|
||||
* 在传入的机器人实例上调用方法
|
||||
*
|
||||
* @param string $name 方法名
|
||||
* @param array $arguments 参数
|
||||
* @throws ReflectionException
|
||||
* @return array<mixed> 返回一个包含所有执行结果的数组,键名为群号
|
||||
*/
|
||||
public function __call(string $name, array $arguments)
|
||||
{
|
||||
// 如果调用的方法并非群组方法,则直接返回输出
|
||||
// 因为目前所有群组方法都是以 `group_id` 作为第一个参数,故以此来判断
|
||||
$reflection = new \ReflectionMethod(ZMRobot::class, $name);
|
||||
if (!$reflection->getNumberOfParameters() || $reflection->getParameters()[0]->getName() !== 'group_id') {
|
||||
Console::warning("Trying to call non-group method {$name} on AllGroupsProxy, skipped.");
|
||||
return $this->bot->{$name}(...$arguments);
|
||||
}
|
||||
|
||||
$result = [];
|
||||
// 获取并遍历所有群组
|
||||
$groups = $this->bot->getGroupList()['data'];
|
||||
foreach ($groups as $group) {
|
||||
$arguments[0] = $group['group_id'];
|
||||
$bot_id = implode_when_necessary($this->bot->getSelfId());
|
||||
Console::debug("Calling {$name} on group {$group['group_id']} on bot {$bot_id}.");
|
||||
// 在群组上调用方法
|
||||
$result[$group['group_id']] = $this->bot->{$name}(...$arguments);
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
@@ -11,12 +11,12 @@ class TuringAPI
|
||||
{
|
||||
/**
|
||||
* 请求图灵API,返回图灵的消息
|
||||
* @param $msg
|
||||
* @param $user_id
|
||||
* @param $api
|
||||
* @return string
|
||||
* @param string $msg 消息
|
||||
* @param int|string $user_id 用户ID
|
||||
* @param string $api API Key
|
||||
* @return string 图灵的回复
|
||||
*/
|
||||
public static function getTuringMsg($msg, $user_id, $api)
|
||||
public static function getTuringMsg(string $msg, $user_id, string $api): string
|
||||
{
|
||||
$origin = $msg;
|
||||
if (($cq = CQ::getCQ($msg)) !== null) {// 如有CQ码则去除
|
||||
@@ -86,7 +86,11 @@ class TuringAPI
|
||||
return trim($final);
|
||||
}
|
||||
|
||||
public static function getResultStatus($r)
|
||||
/**
|
||||
* @param array $r 数据API回包
|
||||
* @return bool|string 错误消息或成功鸥鸟
|
||||
*/
|
||||
public static function getResultStatus(array $r)
|
||||
{
|
||||
switch ($r['intent']['code']) {
|
||||
case 5000:
|
||||
|
||||
@@ -4,6 +4,9 @@ declare(strict_types=1);
|
||||
|
||||
namespace ZM\API;
|
||||
|
||||
use ZM\API\Proxies\Bot as Proxies;
|
||||
use ZM\Console\Console;
|
||||
|
||||
/**
|
||||
* Class ZMRobot
|
||||
* @since 1.2
|
||||
@@ -11,4 +14,25 @@ namespace ZM\API;
|
||||
*/
|
||||
class ZMRobot extends OneBotV11
|
||||
{
|
||||
/**
|
||||
* 获取一个会在所有机器人实例上执行的代理
|
||||
*/
|
||||
public function all(Proxies\AbstractBotProxy $proxy = null): Proxies\AllBotsProxy
|
||||
{
|
||||
$bot = $proxy ?: $this;
|
||||
$bot_id = implode_when_necessary($bot->getSelfId());
|
||||
Console::debug("Constructing AllBotsProxy for ZMRobot({$bot_id})");
|
||||
return new Proxies\AllBotsProxy($bot);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取一个会在所有群上执行的代理
|
||||
*/
|
||||
public function allGroups(Proxies\AbstractBotProxy $proxy = null): Proxies\AllGroupsProxy
|
||||
{
|
||||
$bot = $proxy ?: $this;
|
||||
$bot_id = implode_when_necessary($bot->getSelfId());
|
||||
Console::debug("Constructing AllGroupsProxy for ZMRobot({$bot_id})");
|
||||
return new Proxies\AllGroupsProxy($bot);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,9 +4,12 @@ declare(strict_types=1);
|
||||
|
||||
namespace ZM\Annotation;
|
||||
|
||||
use ArrayIterator;
|
||||
use Closure;
|
||||
use IteratorAggregate;
|
||||
use Traversable;
|
||||
|
||||
abstract class AnnotationBase
|
||||
abstract class AnnotationBase implements IteratorAggregate
|
||||
{
|
||||
public $method = '';
|
||||
|
||||
@@ -35,4 +38,9 @@ abstract class AnnotationBase
|
||||
}
|
||||
return $str;
|
||||
}
|
||||
|
||||
public function getIterator(): Traversable
|
||||
{
|
||||
return new ArrayIterator($this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,10 +21,10 @@ use ZM\Annotation\Interfaces\Level;
|
||||
use ZM\Annotation\Module\Closed;
|
||||
use ZM\Config\ZMConfig;
|
||||
use ZM\Console\Console;
|
||||
use ZM\Event\EventManager;
|
||||
use ZM\Exception\AnnotationException;
|
||||
use ZM\Utils\Manager\RouteManager;
|
||||
use ZM\Utils\ZMUtil;
|
||||
use function server;
|
||||
|
||||
class AnnotationParser
|
||||
{
|
||||
@@ -38,7 +38,7 @@ class AnnotationParser
|
||||
|
||||
private $middlewares = [];
|
||||
|
||||
/** @var null|AnnotationReader */
|
||||
/** @var null|AnnotationReader|DualReader */
|
||||
private $reader;
|
||||
|
||||
private $req_mapping = [];
|
||||
@@ -82,6 +82,7 @@ class AnnotationParser
|
||||
$this->reader = new DualReader(new AnnotationReader(), new AttributeReader());
|
||||
foreach ($all_class as $v) {
|
||||
Console::debug('正在检索 ' . $v);
|
||||
|
||||
$reflection_class = new ReflectionClass($v);
|
||||
$methods = $reflection_class->getMethods(ReflectionMethod::IS_PUBLIC);
|
||||
$class_annotations = $this->reader->getClassAnnotations($reflection_class);
|
||||
@@ -104,6 +105,8 @@ class AnnotationParser
|
||||
}
|
||||
*/
|
||||
|
||||
// 保留ergodic注解
|
||||
$append_ergodics = [];
|
||||
// 生成主树
|
||||
$this->annotation_map[$v]['class_annotations'] = $class_annotations;
|
||||
$this->annotation_map[$v]['methods'] = $methods;
|
||||
@@ -115,11 +118,12 @@ class AnnotationParser
|
||||
$vs->class = $v;
|
||||
|
||||
// 预处理1:将适用于每一个函数的注解到类注解重新注解到每个函数下面
|
||||
if ($vs instanceof ErgodicAnnotation) {
|
||||
if (($vs instanceof ErgodicAnnotation) && ($vs instanceof AnnotationBase)) {
|
||||
foreach (($this->annotation_map[$v]['methods'] ?? []) as $method) {
|
||||
$copy = clone $vs;
|
||||
$copy->method = $method->getName();
|
||||
$this->annotation_map[$v]['methods_annotations'][$method->getName()][] = $copy;
|
||||
$append_ergodics[$method->getName()][] = $copy;
|
||||
// $this->annotation_map[$v]['methods_annotations'][$method->getName()][] = $copy;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -138,6 +142,13 @@ class AnnotationParser
|
||||
|
||||
$inserted = [];
|
||||
|
||||
// 预处理:将Class的ergodic注解拼接到每个方法的注解列表前面,且按照顺序(修复 #365)
|
||||
foreach ($this->annotation_map[$v]['methods_annotations'] as $method_name => $annos) {
|
||||
if (isset($append_ergodics[$method_name])) {
|
||||
$this->annotation_map[$v]['methods_annotations'][$method_name] = array_merge($append_ergodics[$method_name], $annos);
|
||||
}
|
||||
}
|
||||
|
||||
// 预处理3:处理每个函数上面的特殊注解,就是需要操作一些东西的
|
||||
foreach (($this->annotation_map[$v]['methods_annotations'] ?? []) as $method_name => $methods_annotations) {
|
||||
foreach ($methods_annotations as $method_anno) {
|
||||
@@ -155,11 +166,12 @@ class AnnotationParser
|
||||
}
|
||||
$inserted[$v][$method_name] = true;
|
||||
}
|
||||
}
|
||||
if ($method_anno instanceof RequestMapping) {
|
||||
} elseif ($method_anno instanceof RequestMapping) {
|
||||
RouteManager::importRouteByAnnotation($method_anno, $method_name, $v, $methods_annotations);
|
||||
} elseif ($method_anno instanceof Middleware) {
|
||||
$this->middleware_map[$method_anno->class][$method_anno->method][] = $method_anno;
|
||||
} else {
|
||||
EventManager::$event_map[$method_anno->class][$method_anno->method][] = $method_anno;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -207,10 +219,10 @@ class AnnotationParser
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $path
|
||||
* @param $indoor_name
|
||||
* @param string $path 注册解析注解的路径
|
||||
* @param string $indoor_name 起始命名空间的名称
|
||||
*/
|
||||
public function addRegisterPath($path, $indoor_name)
|
||||
public function addRegisterPath(string $path, string $indoor_name)
|
||||
{
|
||||
if (server()->worker_id === 0) {
|
||||
Console::verbose('Add register path: ' . $path . ' => ' . $indoor_name);
|
||||
@@ -219,10 +231,12 @@ class AnnotationParser
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $events
|
||||
* @param array $events 需要排序的
|
||||
* @param string $class_name 排序的类名
|
||||
* @param string $prefix 前缀
|
||||
* @internal 用于 level 排序
|
||||
*/
|
||||
public function sortByLevel(&$events, string $class_name, string $prefix = '')
|
||||
public function sortByLevel(array &$events, string $class_name, string $prefix = '')
|
||||
{
|
||||
if (is_a($class_name, Level::class, true)) {
|
||||
$class_name .= $prefix;
|
||||
|
||||
@@ -35,7 +35,7 @@ class CQBefore extends AnnotationBase implements Level
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
* @return int 返回等级
|
||||
*/
|
||||
public function getLevel(): int
|
||||
{
|
||||
|
||||
@@ -36,7 +36,7 @@ class CQMetaEvent extends AnnotationBase implements Level
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
* @return int 返回等级
|
||||
*/
|
||||
public function getLevel(): int
|
||||
{
|
||||
|
||||
146
src/ZM/Annotation/CQ/CommandArgument.php
Normal file
146
src/ZM/Annotation/CQ/CommandArgument.php
Normal file
@@ -0,0 +1,146 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace ZM\Annotation\CQ;
|
||||
|
||||
use Attribute;
|
||||
use Doctrine\Common\Annotations\Annotation\NamedArgumentConstructor;
|
||||
use Doctrine\Common\Annotations\Annotation\Required;
|
||||
use ZM\Annotation\AnnotationBase;
|
||||
use ZM\Annotation\Interfaces\ErgodicAnnotation;
|
||||
use ZM\Exception\InvalidArgumentException;
|
||||
use ZM\Exception\ZMKnownException;
|
||||
|
||||
/**
|
||||
* Class CommandArgument
|
||||
* @Annotation
|
||||
* @NamedArgumentConstructor()
|
||||
* @Target("ALL")
|
||||
*/
|
||||
#[Attribute(Attribute::IS_REPEATABLE | Attribute::TARGET_ALL)]
|
||||
class CommandArgument extends AnnotationBase implements ErgodicAnnotation
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
* @Required()
|
||||
*/
|
||||
public $name;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $description = '';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $type = 'string';
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
public $required = false;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $prompt = '';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $default = '';
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
public $timeout = 60;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
public $error_prompt_policy = 1;
|
||||
|
||||
/**
|
||||
* @param string $name 参数名称(可以是中文)
|
||||
* @param string $description 参数描述(默认为空)
|
||||
* @param bool $required 参数是否必需,如果是必需,为true(默认为false)
|
||||
* @param string $prompt 当参数为必需时,返回给用户的提示输入的消息(默认为"请输入$name")
|
||||
* @param string $default 当required为false时,未匹配到参数将自动使用default值(默认为空)
|
||||
* @param int $timeout prompt超时时间(默认为60秒)
|
||||
* @throws InvalidArgumentException|ZMKnownException
|
||||
*/
|
||||
public function __construct(
|
||||
string $name,
|
||||
string $description = '',
|
||||
string $type = 'string',
|
||||
bool $required = false,
|
||||
string $prompt = '',
|
||||
string $default = '',
|
||||
int $timeout = 60,
|
||||
int $error_prompt_policy = 1
|
||||
) {
|
||||
$this->name = $name;
|
||||
$this->description = $description;
|
||||
$this->type = $this->fixTypeName($type);
|
||||
$this->required = $required;
|
||||
$this->prompt = $prompt;
|
||||
$this->default = $default;
|
||||
$this->timeout = $timeout;
|
||||
$this->error_prompt_policy = $error_prompt_policy;
|
||||
if ($this->type === 'bool') {
|
||||
if ($this->default === '') {
|
||||
$this->default = 'yes';
|
||||
}
|
||||
if (!in_array($this->default, array_merge(TRUE_LIST, FALSE_LIST))) {
|
||||
throw new InvalidArgumentException('CommandArgument参数 ' . $name . ' 类型传入类型应为布尔型,检测到非法的默认值 ' . $this->default);
|
||||
}
|
||||
} elseif ($this->type === 'number') {
|
||||
if ($this->default === '') {
|
||||
$this->default = '0';
|
||||
}
|
||||
if (!is_numeric($this->default)) {
|
||||
throw new InvalidArgumentException('CommandArgument参数 ' . $name . ' 类型传入类型应为数字型,检测到非法的默认值 ' . $this->default);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function getTypeErrorPrompt(): string
|
||||
{
|
||||
return '参数类型错误,请重新输入!';
|
||||
}
|
||||
|
||||
public function getErrorQuitPrompt(): string
|
||||
{
|
||||
return '参数类型错误,停止输入!';
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws ZMKnownException
|
||||
*/
|
||||
protected function fixTypeName(string $type): string
|
||||
{
|
||||
$table = [
|
||||
'str' => 'string',
|
||||
'string' => 'string',
|
||||
'strings' => 'string',
|
||||
'byte' => 'string',
|
||||
'num' => 'number',
|
||||
'number' => 'number',
|
||||
'int' => 'number',
|
||||
'float' => 'number',
|
||||
'double' => 'number',
|
||||
'boolean' => 'bool',
|
||||
'bool' => 'bool',
|
||||
'true' => 'bool',
|
||||
'any' => 'any',
|
||||
'all' => 'any',
|
||||
'*' => 'any',
|
||||
];
|
||||
if (array_key_exists($type, $table)) {
|
||||
return $table[$type];
|
||||
}
|
||||
throw new ZMKnownException(zm_internal_errcode('E00077') . 'Invalid argument type: ' . $type . ', only support any, string, number and bool !');
|
||||
}
|
||||
}
|
||||
@@ -38,7 +38,7 @@ class OnTask extends AnnotationBase implements Rule
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
* @return string 返回规则语句
|
||||
*/
|
||||
public function getRule(): string
|
||||
{
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user