mirror of
https://github.com/zhamao-robot/zhamao-framework.git
synced 2026-07-03 14:55:36 +08:00
Compare commits
82 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
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
|
||||
65
.github/workflows/increment-build-number.yml
vendored
Normal file
65
.github/workflows/increment-build-number.yml
vendored
Normal file
@@ -0,0 +1,65 @@
|
||||
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
|
||||
run: bin/gendoc
|
||||
|
||||
- name: Commit api docs
|
||||
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"
|
||||
|
||||
2
.github/workflows/vuepress-deploy.yml
vendored
2
.github/workflows/vuepress-deploy.yml
vendored
@@ -3,6 +3,8 @@ on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
paths:
|
||||
- 'docs/**'
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
||||
67
.gitignore
vendored
67
.gitignore
vendored
@@ -1,21 +1,23 @@
|
||||
.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快速安装启动相关(可能被废弃)
|
||||
# 进程锁文件
|
||||
.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 +25,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
|
||||
|
||||
@@ -65,11 +65,11 @@ return (new PhpCsFixer\Config())
|
||||
'standardize_not_equals' => true,
|
||||
'multiline_comment_opening_closing' => true,
|
||||
'phpdoc_summary' => false,
|
||||
'php_unit_test_class_requires_covers' => false,
|
||||
])
|
||||
->setFinder(
|
||||
PhpCsFixer\Finder::create()
|
||||
->exclude('vendor')
|
||||
->exclude('docs')
|
||||
->in(__DIR__ . '/src')
|
||||
->in(__DIR__ . '/tests')
|
||||
)
|
||||
->setUsingCache(false);
|
||||
|
||||
42
README.md
42
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>
|
||||
|
||||
|
||||
@@ -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;
|
||||
@@ -231,7 +230,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 +263,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";
|
||||
}
|
||||
|
||||
// 返回值
|
||||
|
||||
125
bin/phpunit-swoole
Normal file → Executable file
125
bin/phpunit-swoole
Normal file → Executable file
@@ -1,69 +1,86 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
/**
|
||||
* Copyright: Swlib
|
||||
* Author: Twosee <twose@qq.com>
|
||||
* Date: 2018/4/14 下午10:58
|
||||
/** For Swoole coroutine tests */
|
||||
|
||||
use ZM\Command\RunServerCommand;
|
||||
use ZM\Store\ZMAtomic;
|
||||
|
||||
$root = dirname(__DIR__);
|
||||
|
||||
co::set([
|
||||
'log_level' => SWOOLE_LOG_INFO,
|
||||
'trace_flags' => 0,
|
||||
]);
|
||||
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use Swoole\Coroutine;
|
||||
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
|
||||
)
|
||||
);
|
||||
|
||||
Coroutine::set([
|
||||
'log_level' => SWOOLE_LOG_INFO,
|
||||
'trace_flags' => 0
|
||||
]);
|
||||
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 = \ZM\ConsoleApplication::VERSION_ID;
|
||||
const ZM_VERSION = \ZM\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);
|
||||
}
|
||||
}
|
||||
}
|
||||
/** @noinspection PhpIncludeInspection */
|
||||
require PHPUNIT_COMPOSER_INSTALL;
|
||||
$starttime = microtime(true);
|
||||
go(function () {
|
||||
// 模拟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;
|
||||
\ZM\Console\Console::setLevel(0);
|
||||
$framework = new \ZM\Framework($options);
|
||||
$start = new \ZM\Annotation\Swoole\OnStart();
|
||||
$start->method = function () {
|
||||
try {
|
||||
require_once __DIR__.'/../test/bootstrap.php';
|
||||
PHPUnit\TextUI\Command::main(false);
|
||||
} catch (Exception $e) {
|
||||
echo $e->getMessage() . PHP_EOL;
|
||||
\ZM\Console\Console::setLevel(4);
|
||||
$retcode = PHPUnit\TextUI\Command::main(false);
|
||||
\ZM\Console\Console::setLevel(0);
|
||||
} finally {
|
||||
\ZM\Utils\ZMUtil::stop(($retcode ?? 1) !== 0);
|
||||
}
|
||||
});
|
||||
};
|
||||
\ZM\Event\EventManager::addEvent(\ZM\Annotation\Swoole\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,13 @@
|
||||
{
|
||||
"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"
|
||||
}
|
||||
],
|
||||
"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": "*",
|
||||
@@ -52,6 +27,14 @@
|
||||
"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",
|
||||
"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 +42,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 +55,44 @@
|
||||
"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
|
||||
},
|
||||
"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"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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/Framework","ZM/ConsoleApplication","ZM/ZMServer"]},{"title":"ZM/API","collapsable":true,"children":["ZM/API/TuringAPI","ZM/API/GoCqhttpAPIV11","ZM/API/CQ","ZM/API/OneBotV11"]},{"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/Module","collapsable":true,"children":["ZM/Command/Module/ModuleListCommand","ZM/Command/Module/ModulePackCommand"]},{"title":"ZM/Context","collapsable":true,"children":["ZM/Context/Context"]},{"title":"ZM/DB","collapsable":true,"children":["ZM/DB/InsertBody","ZM/DB/DB","ZM/DB/DeleteBody","ZM/DB/UpdateBody","ZM/DB/Table","ZM/DB/SelectBody"]},{"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/ModuleBase","ZM/Module/ModuleUnpacker","ZM/Module/QQBot","ZM/Module/ModulePacker"]},{"title":"ZM/MySQL","collapsable":true,"children":["ZM/MySQL/MySQLConnection","ZM/MySQL/MySQLQueryBuilder","ZM/MySQL/MySQLStatement","ZM/MySQL/MySQLPool","ZM/MySQL/MySQLStatementWrapper","ZM/MySQL/MySQLWrapper"]},{"title":"ZM/Store","collapsable":true,"children":["ZM/Store/LightCacheInside","ZM/Store/LightCache","ZM/Store/ZMAtomic"]},{"title":"ZM/Store/Redis","collapsable":true,"children":["ZM/Store/Redis/ZMRedis"]},{"title":"ZM/Utils","collapsable":true,"children":["ZM/Utils/ZMUtil","ZM/Utils/DataProvider","ZM/Utils/HttpUtil","ZM/Utils/SignalListener","ZM/Utils/MessageUtil","ZM/Utils/Terminal","ZM/Utils/CoMessage"]},{"title":"ZM/Utils/Manager","collapsable":true,"children":["ZM/Utils/Manager/CronManager","ZM/Utils/Manager/ModuleManager","ZM/Utils/Manager/WorkerManager"]}]
|
||||
@@ -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>
|
||||
|
||||
@@ -2,7 +2,7 @@ const apiConfig = require('./api')
|
||||
|
||||
module.exports = {
|
||||
title: '炸毛框架',
|
||||
description: '一个聊天机器人 + Web 框架',
|
||||
description: '一个高性能聊天机器人 + Web 框架',
|
||||
theme: 'antdocs',
|
||||
markdown: {
|
||||
lineNumbers: true
|
||||
@@ -189,4 +189,4 @@ module.exports = {
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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(string $type, int|string $id): string
|
||||
```
|
||||
|
||||
### 描述
|
||||
@@ -257,19 +265,20 @@ public function contact(mixed $type, mixed $id): string
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| type | mixed | |
|
||||
| id | mixed | |
|
||||
| type | 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(string $msg, bool $is_content): string
|
||||
```
|
||||
|
||||
### 描述
|
||||
@@ -340,19 +466,43 @@ public function decode(mixed $msg, mixed $is_content): mixed
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| msg | mixed | |
|
||||
| is_content | mixed | |
|
||||
| msg | string | 字符串 |
|
||||
| is_content | bool | 如果是解码CQ码本体内容,则为false(默认),如果是参数内的字符串,则为true |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| mixed | |
|
||||
| string | 转义后的CQ码 |
|
||||
|
||||
|
||||
## replace
|
||||
|
||||
```php
|
||||
public function replace(string $str): string
|
||||
```
|
||||
|
||||
### 描述
|
||||
|
||||
简单反转义替换CQ码的方括号
|
||||
|
||||
### 参数
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| str | string | 字符串 |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| string | 字符串 |
|
||||
|
||||
|
||||
## escape
|
||||
|
||||
```php
|
||||
public function escape(mixed $msg, mixed $is_content): mixed
|
||||
public function escape(string $msg, bool $is_content): string
|
||||
```
|
||||
|
||||
### 描述
|
||||
@@ -363,19 +513,20 @@ public function escape(mixed $msg, mixed $is_content): mixed
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| msg | mixed | |
|
||||
| is_content | mixed | |
|
||||
| msg | string | 字符串 |
|
||||
| is_content | bool | 如果是转义CQ码本体内容,则为false(默认),如果是参数内的字符串,则为true |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| mixed | |
|
||||
| string | 转义后的CQ码 |
|
||||
|
||||
|
||||
## encode
|
||||
|
||||
```php
|
||||
public function encode(mixed $msg, mixed $is_content): mixed
|
||||
public function encode(string $msg, bool $is_content): string
|
||||
```
|
||||
|
||||
### 描述
|
||||
@@ -386,19 +537,20 @@ public function encode(mixed $msg, mixed $is_content): mixed
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| msg | mixed | |
|
||||
| is_content | mixed | |
|
||||
| msg | string | 字符串 |
|
||||
| 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) |
|
||||
|
||||
@@ -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 | 错误消息或成功鸥鸟 |
|
||||
|
||||
@@ -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 | |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
|
||||
@@ -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 | |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
|
||||
@@ -16,6 +16,7 @@ public function onCall(Swoole\Server $server, Swoole\Server\Task $task): mixed
|
||||
| -------- | ---- | ----------- |
|
||||
| server | Swoole\Server | |
|
||||
| task | Swoole\Server\Task | |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
|
||||
@@ -17,6 +17,7 @@ public function saveProcessState(int|string $pid, int $type, array $data): mixed
|
||||
| pid | int|string | |
|
||||
| type | int | |
|
||||
| data | array | |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
@@ -40,6 +41,7 @@ public function getProcessState(mixed $id_or_name, int $type): false|int|mixed
|
||||
| -------- | ---- | ----------- |
|
||||
| id_or_name | mixed | |
|
||||
| type | int | |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
@@ -50,7 +52,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 +63,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 +110,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 +121,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 | |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
|
||||
@@ -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 | |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
|
||||
@@ -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 | |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
|
||||
@@ -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|string $relative): array|false
|
||||
```
|
||||
|
||||
### 描述
|
||||
@@ -166,9 +169,10 @@ public function scanDirFiles(mixed $dir, bool|string $relative, bool $recursive)
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| dir | mixed | |
|
||||
| relative | bool|string | |
|
||||
| recursive | bool | |
|
||||
| dir | string | 目录 |
|
||||
| recursive | bool | 是否递归扫描子目录 |
|
||||
| relative | bool|string | 是否返回相对目录,如果为true则返回相对目录,如果为false则返回绝对目录 |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
@@ -179,7 +183,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 +194,10 @@ public function isRelativePath(mixed $path): bool
|
||||
|
||||
| 名称 | 类型 | 描述 |
|
||||
| -------- | ---- | ----------- |
|
||||
| path | mixed | |
|
||||
| path | string | 路径 |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
| ---- | ----------- |
|
||||
| bool | |
|
||||
| bool | 返回结果 |
|
||||
|
||||
@@ -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 | |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
|
||||
@@ -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 | 是否返回文件路径,返回文件路径的话传入字符串 |
|
||||
|
||||
### 返回
|
||||
|
||||
| 类型 | 描述 |
|
||||
|
||||
@@ -4,6 +4,41 @@
|
||||
|
||||
同时此处将只使用 build 版本号进行区分。
|
||||
|
||||
## 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,26 @@
|
||||
# 更新日志(v2 版本)
|
||||
|
||||
## 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
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
parameters:
|
||||
reportUnmatchedIgnoredErrors: false
|
||||
level: 0
|
||||
level: 4
|
||||
paths:
|
||||
- ./src/
|
||||
ignoreErrors:
|
||||
- '#Used constant OS_TYPE_(LINUX|WINDOWS) not found#'
|
||||
- '#Constant .* not found#'
|
||||
dynamicConstantNames:
|
||||
- SWOOLE_VERSION
|
||||
|
||||
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>
|
||||
@@ -15,6 +15,7 @@ use ZM\Annotation\Swoole\OnRequestEvent;
|
||||
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\Event\EventDispatcher;
|
||||
@@ -95,11 +96,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();
|
||||
@@ -170,10 +171,10 @@ 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 +182,7 @@ class Hello
|
||||
/**
|
||||
* 在机器人连接后向终端输出信息
|
||||
* @OnOpenEvent("qq")
|
||||
* @param $conn
|
||||
* @param ConnectionObject $conn WebSocket 连接对象
|
||||
*/
|
||||
public function onConnect(ConnectionObject $conn)
|
||||
{
|
||||
|
||||
@@ -11,10 +11,10 @@ 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 . ']';
|
||||
@@ -25,10 +25,10 @@ class CQ
|
||||
|
||||
/**
|
||||
* 发送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 . ']';
|
||||
@@ -39,10 +39,14 @@ class CQ
|
||||
|
||||
/**
|
||||
* 发送图片
|
||||
* @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) .
|
||||
@@ -55,15 +59,19 @@ class CQ
|
||||
|
||||
/**
|
||||
* 发送语音
|
||||
* @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' : '') .
|
||||
(!$cache ? ',cache=0' : '') .
|
||||
(!$proxy ? ',proxy=false' : '') .
|
||||
($timeout != -1 ? (',timeout=' . $timeout) : '') .
|
||||
']';
|
||||
@@ -71,10 +79,13 @@ class CQ
|
||||
|
||||
/**
|
||||
* 发送短视频
|
||||
* @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) .
|
||||
@@ -86,60 +97,62 @@ class CQ
|
||||
|
||||
/**
|
||||
* 发送投掷骰子(只能在单条回复中单独使用)
|
||||
* @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)) : '') . ']';
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送匿名消息
|
||||
* @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' : '') . ']';
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送链接分享(只能在单条回复中单独使用)
|
||||
* @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 = '';
|
||||
@@ -156,26 +169,28 @@ class CQ
|
||||
|
||||
/**
|
||||
* 发送好友或群推荐名片
|
||||
* @param $type
|
||||
* @param $id
|
||||
* @return string
|
||||
* @param string $type 名片类型
|
||||
* @param int|string $id 好友或群ID
|
||||
* @return string CQ码
|
||||
*/
|
||||
public static function contact($type, $id)
|
||||
public static function contact(string $type, $id): string
|
||||
{
|
||||
return "[CQ: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) .
|
||||
',lat=' . self::encode((string) $lat, true) .
|
||||
',lon=' . self::encode((string) $lon, true) .
|
||||
($title != '' ? (',title=' . self::encode($title, true)) : '') .
|
||||
($content != '' ? (',content=' . self::encode($content, true)) : '') .
|
||||
']';
|
||||
@@ -183,23 +198,18 @@ class CQ
|
||||
|
||||
/**
|
||||
* 发送音乐分享(只能在单条回复中单独使用)
|
||||
*
|
||||
* 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':
|
||||
@@ -231,27 +241,60 @@ class CQ
|
||||
}
|
||||
}
|
||||
|
||||
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 '[CQ:forward,id=' . self::encode((string) $id) . ']';
|
||||
}
|
||||
|
||||
public static function node($user_id, $nickname, $content)
|
||||
/**
|
||||
* 合并转发消息节点
|
||||
* 特殊说明: 需要使用单独的API /send_group_forward_msg 发送, 并且由于消息段较为复杂, 仅支持Array形式入参。
|
||||
* 如果引用消息和自定义消息同时出现, 实际查看顺序将取消息段顺序。
|
||||
* 另外按 CQHTTP 文档说明, data 应全为字符串, 但由于需要接收message 类型的消息, 所以 仅限此Type的content字段 支持Array套娃
|
||||
* @deprecated 这个不推荐使用,因为 go-cqhttp 官方没有对其提供CQ码模式相关支持,仅支持Array模式发送
|
||||
* @param int|string $user_id 转发消息id
|
||||
* @param string $nickname 发送者显示名字
|
||||
* @param string $content 具体消息
|
||||
* @return string CQ码
|
||||
*/
|
||||
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) . ']';
|
||||
}
|
||||
|
||||
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) . ']';
|
||||
}
|
||||
|
||||
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 '[CQ:json,data=' . self::encode($data, true) . ',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) {
|
||||
@@ -263,10 +306,11 @@ class CQ
|
||||
|
||||
/**
|
||||
* 反转义字符串中的CQ码敏感符号
|
||||
* @param mixed $msg
|
||||
* @param mixed $is_content
|
||||
* @param string $msg 字符串
|
||||
* @param bool $is_content 如果是解码CQ码本体内容,则为false(默认),如果是参数内的字符串,则为true
|
||||
* @return string 转义后的CQ码
|
||||
*/
|
||||
public static function decode($msg, $is_content = false)
|
||||
public static function decode(string $msg, bool $is_content = false): string
|
||||
{
|
||||
$msg = str_replace(['&', '[', ']'], ['&', '[', ']'], $msg);
|
||||
if ($is_content) {
|
||||
@@ -275,7 +319,12 @@ class CQ
|
||||
return $msg;
|
||||
}
|
||||
|
||||
public static function replace($str)
|
||||
/**
|
||||
* 简单反转义替换CQ码的方括号
|
||||
* @param string $str 字符串
|
||||
* @return string 字符串
|
||||
*/
|
||||
public static function replace(string $str): string
|
||||
{
|
||||
$str = str_replace('{{', '[', $str);
|
||||
return str_replace('}}', ']', $str);
|
||||
@@ -283,10 +332,11 @@ class CQ
|
||||
|
||||
/**
|
||||
* 转义CQ码的特殊字符,同encode
|
||||
* @param mixed $msg
|
||||
* @param mixed $is_content
|
||||
* @param string $msg 字符串
|
||||
* @param bool $is_content 如果是转义CQ码本体内容,则为false(默认),如果是参数内的字符串,则为true
|
||||
* @return string 转义后的CQ码
|
||||
*/
|
||||
public static function escape($msg, $is_content = false)
|
||||
public static function escape(string $msg, bool $is_content = false): string
|
||||
{
|
||||
$msg = str_replace(['&', '[', ']'], ['&', '[', ']'], $msg);
|
||||
if ($is_content) {
|
||||
@@ -297,10 +347,11 @@ class CQ
|
||||
|
||||
/**
|
||||
* 转义CQ码的特殊字符
|
||||
* @param mixed $msg
|
||||
* @param mixed $is_content
|
||||
* @param string $msg 字符串
|
||||
* @param bool $is_content 如果是转义CQ码本体内容,则为false(默认),如果是参数内的字符串,则为true
|
||||
* @return string 转义后的CQ码
|
||||
*/
|
||||
public static function encode($msg, $is_content = false)
|
||||
public static function encode(string $msg, bool $is_content = false): string
|
||||
{
|
||||
$msg = str_replace(['&', '[', ']'], ['&', '[', ']'], $msg);
|
||||
if ($is_content) {
|
||||
@@ -311,10 +362,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 +379,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,10 +408,11 @@ 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;
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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,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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
@@ -115,7 +116,7 @@ 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();
|
||||
@@ -207,10 +208,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 +220,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
|
||||
{
|
||||
|
||||
@@ -38,7 +38,7 @@ class OnTask extends AnnotationBase implements Rule
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
* @return string 返回规则语句
|
||||
*/
|
||||
public function getRule(): string
|
||||
{
|
||||
|
||||
46
src/ZM/Command/Module/ModuleCommand.php
Normal file
46
src/ZM/Command/Module/ModuleCommand.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace ZM\Command\Module;
|
||||
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use ZM\Config\ZMConfig;
|
||||
use ZM\Console\Console;
|
||||
use ZM\Utils\DataProvider;
|
||||
|
||||
abstract class ModuleCommand extends Command
|
||||
{
|
||||
protected function configure()
|
||||
{
|
||||
$this->addOption('env', null, InputOption::VALUE_REQUIRED, '设置环境类型 (production, development, staging)', '');
|
||||
$this->addOption('log-theme', null, InputOption::VALUE_REQUIRED, '改变终端的主题配色', 'default');
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output): int
|
||||
{
|
||||
ZMConfig::setDirectory(DataProvider::getSourceRootDir() . '/config');
|
||||
ZMConfig::setEnv($input->getOption('env'));
|
||||
if (ZMConfig::get('global') === false) {
|
||||
exit(zm_internal_errcode('E00007') . 'Global config load failed: ' . ZMConfig::$last_error . "\nPlease init first!\nSee: https://github.com/zhamao-robot/zhamao-framework/issues/37\n");
|
||||
}
|
||||
|
||||
// 定义常量
|
||||
/** @noinspection PhpIncludeInspection */
|
||||
include_once DataProvider::getFrameworkRootDir() . '/src/ZM/global_defines.php';
|
||||
|
||||
Console::init(
|
||||
ZMConfig::get('global', 'info_level') ?? 2,
|
||||
null,
|
||||
$input->getOption('log-theme'),
|
||||
($o = ZMConfig::get('console_color')) === false ? [] : $o
|
||||
);
|
||||
|
||||
$timezone = ZMConfig::get('global', 'timezone') ?? 'Asia/Shanghai';
|
||||
date_default_timezone_set($timezone);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -4,47 +4,31 @@ declare(strict_types=1);
|
||||
|
||||
namespace ZM\Command\Module;
|
||||
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use ZM\Config\ZMConfig;
|
||||
use ZM\Console\Console;
|
||||
use ZM\Exception\ZMException;
|
||||
use ZM\Utils\DataProvider;
|
||||
use ZM\Utils\Manager\ModuleManager;
|
||||
|
||||
class ModuleListCommand extends Command
|
||||
class ModuleListCommand extends ModuleCommand
|
||||
{
|
||||
// the name of the command (the part after "bin/console")
|
||||
protected static $defaultName = 'module:list';
|
||||
|
||||
protected function configure()
|
||||
{
|
||||
parent::configure();
|
||||
$this->setDescription('查看所有模块信息');
|
||||
$this->setHelp('此功能将会把炸毛框架的模块列举出来。');
|
||||
// ...
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws ZMException
|
||||
*/
|
||||
protected function execute(InputInterface $input, OutputInterface $output): int
|
||||
{
|
||||
ZMConfig::setDirectory(DataProvider::getSourceRootDir() . '/config');
|
||||
ZMConfig::setEnv($args['env'] ?? '');
|
||||
if (ZMConfig::get('global') === false) {
|
||||
exit(zm_internal_errcode('E00007') . 'Global config load failed: ' . ZMConfig::$last_error . "\nPlease init first!\nSee: https://github.com/zhamao-robot/zhamao-framework/issues/37\n");
|
||||
}
|
||||
|
||||
// 定义常量
|
||||
/** @noinspection PhpIncludeInspection */
|
||||
include_once DataProvider::getFrameworkRootDir() . '/src/ZM/global_defines.php';
|
||||
|
||||
Console::init(
|
||||
ZMConfig::get('global', 'info_level') ?? 2,
|
||||
null,
|
||||
$args['log-theme'] ?? 'default',
|
||||
($o = ZMConfig::get('console_color')) === false ? [] : $o
|
||||
);
|
||||
|
||||
$timezone = ZMConfig::get('global', 'timezone') ?? 'Asia/Shanghai';
|
||||
date_default_timezone_set($timezone);
|
||||
parent::execute($input, $output);
|
||||
|
||||
$list = ModuleManager::getConfiguredModules();
|
||||
|
||||
|
||||
@@ -4,57 +4,41 @@ declare(strict_types=1);
|
||||
|
||||
namespace ZM\Command\Module;
|
||||
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use ZM\Config\ZMConfig;
|
||||
use ZM\Console\Console;
|
||||
use ZM\Exception\ZMException;
|
||||
use ZM\Utils\DataProvider;
|
||||
use ZM\Utils\Manager\ModuleManager;
|
||||
|
||||
class ModulePackCommand extends Command
|
||||
class ModulePackCommand extends ModuleCommand
|
||||
{
|
||||
// the name of the command (the part after "bin/console")
|
||||
protected static $defaultName = 'module:pack';
|
||||
|
||||
protected function configure()
|
||||
{
|
||||
parent::configure();
|
||||
$this->addArgument('module-name', InputArgument::REQUIRED);
|
||||
$this->setDescription('将配置好的模块构建一个phar包');
|
||||
$this->setHelp('此功能将会把炸毛框架的模块打包为".phar",供发布和执行。');
|
||||
$this->addOption('target', 'D', InputOption::VALUE_REQUIRED, 'Output Directory | 指定输出目录');
|
||||
// ...
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws ZMException
|
||||
*/
|
||||
protected function execute(InputInterface $input, OutputInterface $output): int
|
||||
{
|
||||
ZMConfig::setDirectory(DataProvider::getSourceRootDir() . '/config');
|
||||
ZMConfig::setEnv($args['env'] ?? '');
|
||||
if (ZMConfig::get('global') === false) {
|
||||
exit(zm_internal_errcode('E00007') . 'Global config load failed: ' . ZMConfig::$last_error . "\nPlease init first!\nSee: https://github.com/zhamao-robot/zhamao-framework/issues/37\n");
|
||||
}
|
||||
|
||||
// 定义常量
|
||||
include_once DataProvider::getFrameworkRootDir() . '/src/ZM/global_defines.php';
|
||||
|
||||
Console::init(
|
||||
ZMConfig::get('global', 'info_level') ?? 2,
|
||||
null,
|
||||
$args['log-theme'] ?? 'default',
|
||||
($o = ZMConfig::get('console_color')) === false ? [] : $o
|
||||
);
|
||||
|
||||
$timezone = ZMConfig::get('global', 'timezone') ?? 'Asia/Shanghai';
|
||||
date_default_timezone_set($timezone);
|
||||
|
||||
parent::execute($input, $output);
|
||||
$list = ModuleManager::getConfiguredModules();
|
||||
if (!isset($list[$input->getArgument('module-name')])) {
|
||||
$output->writeln('<error>不存在模块 ' . $input->getArgument('module-name') . ' !</error>');
|
||||
return 1;
|
||||
}
|
||||
$result = ModuleManager::packModule($list[$input->getArgument('module-name')], $input->getOption('target'));
|
||||
$result = ModuleManager::packModule($list[$input->getArgument('module-name')], $input->getOption('target') ?? (DataProvider::getDataFolder() . '/output'));
|
||||
if ($result) {
|
||||
Console::success('打包完成!');
|
||||
} else {
|
||||
|
||||
@@ -4,56 +4,32 @@ declare(strict_types=1);
|
||||
|
||||
namespace ZM\Command\Module;
|
||||
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use ZM\Config\ZMConfig;
|
||||
use ZM\Console\Console;
|
||||
use ZM\Utils\DataProvider;
|
||||
use ZM\Utils\Manager\ModuleManager;
|
||||
|
||||
class ModuleUnpackCommand extends Command
|
||||
class ModuleUnpackCommand extends ModuleCommand
|
||||
{
|
||||
// the name of the command (the part after "bin/console")
|
||||
protected static $defaultName = 'module:unpack';
|
||||
|
||||
protected function configure()
|
||||
{
|
||||
$this->setDefinition([
|
||||
new InputArgument('module-name', InputArgument::REQUIRED),
|
||||
new InputOption('overwrite-light-cache', null, null, '覆盖现有的LightCache项目'),
|
||||
new InputOption('overwrite-zm-data', null, null, '覆盖现有的zm_data文件'),
|
||||
new InputOption('overwrite-source', null, null, '覆盖现有的源码文件'),
|
||||
new InputOption('ignore-depends', null, null, '解包时忽略检查依赖'),
|
||||
]);
|
||||
parent::configure();
|
||||
$this->addOption('overwrite-light-cache', null, null, '覆盖现有的LightCache项目');
|
||||
$this->addOption('overwrite-zm-data', null, null, '覆盖现有的zm_data文件');
|
||||
$this->addOption('overwrite-source', null, null, '覆盖现有的源码文件');
|
||||
$this->addOption('ignore-depends', null, null, '解包时忽略检查依赖');
|
||||
$this->addArgument('module-name', InputArgument::REQUIRED, '模块名称');
|
||||
$this->setDescription('解包一个phar模块到src目录');
|
||||
$this->setHelp('此功能将phar格式的模块包解包到src目录下。');
|
||||
// ...
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output): int
|
||||
{
|
||||
ZMConfig::setDirectory(DataProvider::getSourceRootDir() . '/config');
|
||||
ZMConfig::setEnv($args['env'] ?? '');
|
||||
if (ZMConfig::get('global') === false) {
|
||||
exit(zm_internal_errcode('E00007') . 'Global config load failed: ' . ZMConfig::$last_error . "\nPlease init first!\nSee: https://github.com/zhamao-robot/zhamao-framework/issues/37\n");
|
||||
}
|
||||
|
||||
// 定义常量
|
||||
/** @noinspection PhpIncludeInspection */
|
||||
include_once DataProvider::getFrameworkRootDir() . '/src/ZM/global_defines.php';
|
||||
|
||||
Console::init(
|
||||
ZMConfig::get('global', 'info_level') ?? 4,
|
||||
null,
|
||||
$args['log-theme'] ?? 'default',
|
||||
($o = ZMConfig::get('console_color')) === false ? [] : $o
|
||||
);
|
||||
|
||||
$timezone = ZMConfig::get('global', 'timezone') ?? 'Asia/Shanghai';
|
||||
date_default_timezone_set($timezone);
|
||||
parent::execute($input, $output);
|
||||
|
||||
$list = ModuleManager::getPackedModules();
|
||||
if (!isset($list[$input->getArgument('module-name')])) {
|
||||
|
||||
@@ -47,6 +47,7 @@ class RunServerCommand extends Command
|
||||
new InputOption('force-load-module', null, InputOption::VALUE_OPTIONAL, '强制打包状态下加载模块(使用英文逗号分割多个)'),
|
||||
new InputOption('polling-watch', null, null, '强制启用轮询模式监听'),
|
||||
new InputOption('no-state-check', null, null, '关闭启动前框架运行状态检查'),
|
||||
new InputOption('private-mode', null, null, '启动时隐藏MOTD和敏感信息'),
|
||||
]);
|
||||
$this->setDescription('Run zhamao-framework | 启动框架');
|
||||
$this->setHelp('直接运行可以启动');
|
||||
|
||||
@@ -28,7 +28,7 @@ use ZM\Exception\InitException;
|
||||
|
||||
class ConsoleApplication extends Application
|
||||
{
|
||||
public const VERSION_ID = 455;
|
||||
public const VERSION_ID = 460;
|
||||
|
||||
public const VERSION = '2.7.5';
|
||||
|
||||
|
||||
@@ -4,7 +4,9 @@ declare(strict_types=1);
|
||||
|
||||
namespace ZM\Context;
|
||||
|
||||
use Closure;
|
||||
use Exception;
|
||||
use Stringable;
|
||||
use Swoole\Coroutine;
|
||||
use Swoole\Http\Request;
|
||||
use Swoole\WebSocket\Frame;
|
||||
@@ -18,6 +20,7 @@ use ZM\Event\EventDispatcher;
|
||||
use ZM\Exception\InterruptException;
|
||||
use ZM\Exception\InvalidArgumentException;
|
||||
use ZM\Exception\WaitTimeoutException;
|
||||
use ZM\Exception\ZMKnownException;
|
||||
use ZM\Http\Response;
|
||||
use ZM\Utils\CoMessage;
|
||||
use ZM\Utils\MessageUtil;
|
||||
@@ -168,9 +171,9 @@ class Context implements ContextInterface
|
||||
|
||||
/**
|
||||
* only can used by cq->message event function
|
||||
* @param $msg
|
||||
* @param bool $yield
|
||||
* @return array|bool
|
||||
* @param array|string $msg 要回复的消息
|
||||
* @param bool|callable|Closure $yield 是否协程挂起(true),是否绑定异步事件(Closure)
|
||||
* @return array|bool 返回API调用结果
|
||||
*/
|
||||
public function reply($msg, $yield = false)
|
||||
{
|
||||
@@ -199,9 +202,9 @@ class Context implements ContextInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $msg
|
||||
* @param bool $yield
|
||||
* @throws InterruptException
|
||||
* @param array|string $msg 要回复的消息
|
||||
* @param bool $yield 是否协程挂起(true),是否绑定异步事件(Closure)
|
||||
* @throws InterruptException 阻止消息被后续插件处理
|
||||
*/
|
||||
public function finalReply($msg, $yield = false)
|
||||
{
|
||||
@@ -218,8 +221,7 @@ class Context implements ContextInterface
|
||||
* @param string $timeout_prompt
|
||||
* @throws WaitTimeoutException
|
||||
* @throws InvalidArgumentException
|
||||
* @return string
|
||||
* @noinspection PhpMissingReturnTypeInspection
|
||||
* @return string 返回用户输入的内容
|
||||
*/
|
||||
public function waitMessage($prompt = '', $timeout = 600, $timeout_prompt = '')
|
||||
{
|
||||
@@ -247,11 +249,13 @@ class Context implements ContextInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $mode
|
||||
* @param $prompt_msg
|
||||
* @throws WaitTimeoutException
|
||||
* 根据选定的模式获取消息参数
|
||||
* @param int|string $mode 获取的模式
|
||||
* @param string|Stringable $prompt_msg 提示语回复
|
||||
* @throws InvalidArgumentException
|
||||
* @return mixed|string
|
||||
* @throws ZMKnownException
|
||||
* @throws WaitTimeoutException
|
||||
* @return float|int|string
|
||||
*/
|
||||
public function getArgs($mode, $prompt_msg)
|
||||
{
|
||||
@@ -282,10 +286,12 @@ class Context implements ContextInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $prompt_msg
|
||||
* @throws WaitTimeoutException
|
||||
* 获取下一个参数
|
||||
* @param string $prompt_msg 提示语回复
|
||||
* @throws InvalidArgumentException
|
||||
* @return int|mixed|string
|
||||
* @throws ZMKnownException
|
||||
* @throws WaitTimeoutException
|
||||
* @return int|mixed|string 返回获取的参数
|
||||
*/
|
||||
public function getNextArg($prompt_msg = '')
|
||||
{
|
||||
@@ -293,10 +299,12 @@ class Context implements ContextInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $prompt_msg
|
||||
* @throws WaitTimeoutException
|
||||
* 获取接下来所有的消息当成一个完整的参数(包含空格)
|
||||
* @param string $prompt_msg 提示语回复
|
||||
* @throws InvalidArgumentException
|
||||
* @return int|mixed|string
|
||||
* @throws ZMKnownException
|
||||
* @throws WaitTimeoutException
|
||||
* @return int|mixed|string 返回获取的参数
|
||||
*/
|
||||
public function getFullArg($prompt_msg = '')
|
||||
{
|
||||
@@ -304,18 +312,23 @@ class Context implements ContextInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $prompt_msg
|
||||
* @throws WaitTimeoutException
|
||||
* 获取下一个数字类型的参数
|
||||
* @param string $prompt_msg 提示语回复
|
||||
* @throws InvalidArgumentException
|
||||
* @return int|mixed|string
|
||||
* @throws ZMKnownException
|
||||
* @throws WaitTimeoutException
|
||||
* @return int|mixed|string 返回获取的参数
|
||||
*/
|
||||
public function getNumArg($prompt_msg = '')
|
||||
{
|
||||
return $this->getArgs(ZM_MATCH_NUMBER, $prompt_msg);
|
||||
}
|
||||
|
||||
/** @noinspection PhpMissingReturnTypeInspection */
|
||||
public function cloneFromParent()
|
||||
/**
|
||||
* @throws ZMKnownException
|
||||
* @return ContextInterface 返回上下文
|
||||
*/
|
||||
public function cloneFromParent(): ContextInterface
|
||||
{
|
||||
set_coroutine_params(self::$context[Coroutine::getPcid()] ?? self::$context[$this->cid]);
|
||||
return context();
|
||||
|
||||
@@ -9,8 +9,6 @@ declare(strict_types=1);
|
||||
namespace ZM\DB;
|
||||
|
||||
use PDOException;
|
||||
use PDOStatement;
|
||||
use Swoole\Database\PDOStatementProxy;
|
||||
use ZM\Console\Console;
|
||||
use ZM\Exception\DbException;
|
||||
use ZM\MySQL\MySQLManager;
|
||||
@@ -25,10 +23,10 @@ class DB
|
||||
private static $table_list = [];
|
||||
|
||||
/**
|
||||
* @param $db_name
|
||||
* @param string $db_name 数据库名称
|
||||
* @throws DbException
|
||||
*/
|
||||
public static function initTableList($db_name)
|
||||
public static function initTableList(string $db_name)
|
||||
{
|
||||
if (!extension_loaded('mysqlnd')) {
|
||||
throw new DbException('Can not find mysqlnd PHP extension.');
|
||||
@@ -40,10 +38,11 @@ class DB
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $table_name
|
||||
* @param string $table_name 表名
|
||||
* @throws DbException
|
||||
* @return Table 返回表对象
|
||||
*/
|
||||
public static function table($table_name): Table
|
||||
public static function table(string $table_name): Table
|
||||
{
|
||||
if (Table::getTableInstance($table_name) === null) {
|
||||
if (in_array($table_name, self::$table_list)) {
|
||||
@@ -58,36 +57,34 @@ class DB
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $line
|
||||
* @param string $line SQL语句
|
||||
* @throws DbException
|
||||
*/
|
||||
public static function statement($line)
|
||||
public static function statement(string $line)
|
||||
{
|
||||
self::rawQuery($line, []);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $line
|
||||
* @throws DbException
|
||||
* @param string $line SQL语句
|
||||
* @return bool 返回查询是否成功的结果
|
||||
*/
|
||||
public static function unprepared($line): bool
|
||||
public static function unprepared(string $line): bool
|
||||
{
|
||||
try {
|
||||
$conn = SqlPoolStorage::$sql_pool->getConnection();
|
||||
if ($conn === false) {
|
||||
SqlPoolStorage::$sql_pool->putConnection(null);
|
||||
throw new DbException('无法连接SQL!' . $line);
|
||||
}
|
||||
$result = !($conn->query($line) === false);
|
||||
SqlPoolStorage::$sql_pool->putConnection($conn);
|
||||
return $result;
|
||||
} catch (DBException $e) {
|
||||
Console::warning($e->getMessage());
|
||||
throw $e;
|
||||
}
|
||||
$conn = SqlPoolStorage::$sql_pool->getConnection();
|
||||
$result = !($conn->query($line) === false);
|
||||
SqlPoolStorage::$sql_pool->putConnection($conn);
|
||||
return $result;
|
||||
}
|
||||
|
||||
public static function rawQuery(string $line, $params = [], $fetch_mode = ZM_DEFAULT_FETCH_MODE)
|
||||
/**
|
||||
* @param string $line SQL语句
|
||||
* @param array $params 查询参数
|
||||
* @param int $fetch_mode fetch规则
|
||||
* @throws DbException
|
||||
* @return array|false 返回结果集或false
|
||||
*/
|
||||
public static function rawQuery(string $line, array $params = [], int $fetch_mode = ZM_DEFAULT_FETCH_MODE)
|
||||
{
|
||||
if (!is_array($params)) {
|
||||
$params = [$params];
|
||||
@@ -98,20 +95,10 @@ class DB
|
||||
throw new DbException('未连接到任何数据库!');
|
||||
}
|
||||
$conn = SqlPoolStorage::$sql_pool->getConnection();
|
||||
if ($conn === false) {
|
||||
SqlPoolStorage::$sql_pool->putConnection(null);
|
||||
throw new DbException('无法连接SQL!' . $line);
|
||||
}
|
||||
$ps = $conn->prepare($line);
|
||||
if ($ps === false) {
|
||||
SqlPoolStorage::$sql_pool->putConnection(null);
|
||||
/* @noinspection PhpUndefinedFieldInspection */
|
||||
throw new DbException('SQL语句查询错误,' . $line . ',错误信息:' . $conn->error);
|
||||
}
|
||||
if (!($ps instanceof PDOStatement) && !($ps instanceof PDOStatementProxy)) {
|
||||
var_dump($ps);
|
||||
SqlPoolStorage::$sql_pool->putConnection(null);
|
||||
throw new DbException('语句查询错误!返回的不是 PDOStatement' . $line);
|
||||
throw new DbException('SQL语句查询错误,' . $line . ',错误信息:' . $conn->errorInfo()[2]);
|
||||
}
|
||||
if ($params == []) {
|
||||
$result = $ps->execute();
|
||||
@@ -129,7 +116,7 @@ class DB
|
||||
return $ps->fetchAll($fetch_mode);
|
||||
} catch (DbException $e) {
|
||||
if (mb_strpos($e->getMessage(), 'has gone away') !== false) {
|
||||
zm_sleep(0.2);
|
||||
zm_sleep();
|
||||
Console::warning('Gone away of MySQL! retrying!');
|
||||
return self::rawQuery($line, $params);
|
||||
}
|
||||
@@ -137,7 +124,7 @@ class DB
|
||||
throw $e;
|
||||
} catch (PDOException $e) {
|
||||
if (mb_strpos($e->getMessage(), 'has gone away') !== false) {
|
||||
zm_sleep(0.2);
|
||||
zm_sleep();
|
||||
Console::warning('Gone away of MySQL! retrying!');
|
||||
return self::rawQuery($line, $params);
|
||||
}
|
||||
|
||||
@@ -21,7 +21,8 @@ class InsertBody
|
||||
|
||||
/**
|
||||
* InsertBody constructor.
|
||||
* @param $row
|
||||
* @param Table $table 表对象
|
||||
* @param array|string $row 行数据
|
||||
*/
|
||||
public function __construct(Table $table, $row)
|
||||
{
|
||||
|
||||
@@ -47,7 +47,7 @@ class SelectBody
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $fetch_mode
|
||||
* @param mixed $fetch_mode
|
||||
* @throws DbException
|
||||
*/
|
||||
public function fetchAll($fetch_mode = ZM_DEFAULT_FETCH_MODE)
|
||||
@@ -66,7 +66,7 @@ class SelectBody
|
||||
}
|
||||
|
||||
/**
|
||||
* @param null $key
|
||||
* @param null|mixed $key
|
||||
* @throws DbException
|
||||
* @return null|mixed
|
||||
*/
|
||||
@@ -83,10 +83,9 @@ class SelectBody
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $fetch_mode
|
||||
* @throws DbException
|
||||
*/
|
||||
public function execute($fetch_mode = ZM_DEFAULT_FETCH_MODE)
|
||||
public function execute(int $fetch_mode = ZM_DEFAULT_FETCH_MODE)
|
||||
{
|
||||
$str = $this->queryPrepare();
|
||||
$this->result = DB::rawQuery($str[0], $str[1], $fetch_mode);
|
||||
|
||||
@@ -44,7 +44,7 @@ class UpdateBody
|
||||
$msg[] = $k . ' = ?';
|
||||
$arr[] = $v;
|
||||
}
|
||||
if (($msg ?? []) == []) {
|
||||
if ($msg == []) {
|
||||
throw new DbException('update value sets can not be empty!');
|
||||
}
|
||||
$line = 'UPDATE ' . $this->table->getTableName() . ' SET ' . implode(', ', $msg);
|
||||
|
||||
@@ -145,10 +145,11 @@ class EventDispatcher
|
||||
|
||||
/**
|
||||
* @param mixed $v
|
||||
* @param null $rule_func
|
||||
* @param null|mixed $rule_func
|
||||
* @param mixed ...$params
|
||||
* @throws InterruptException
|
||||
* @throws AnnotationException
|
||||
* @throws Error
|
||||
* @return bool
|
||||
* @noinspection PhpMissingReturnTypeInspection
|
||||
*/
|
||||
|
||||
@@ -43,7 +43,7 @@ class EventManager
|
||||
*/
|
||||
public static function loadEventByParser(AnnotationParser $parser)
|
||||
{
|
||||
self::$events = $parser->generateAnnotationEvents();
|
||||
self::$events = array_merge(self::$events, $parser->generateAnnotationEvents());
|
||||
self::$middlewares = $parser->getMiddlewares();
|
||||
self::$middleware_map = $parser->getMiddlewareMap();
|
||||
self::$req_mapping = $parser->getReqMapping();
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @noinspection PhpPropertyOnlyWrittenInspection
|
||||
* @noinspection PhpUnusedParameterInspection
|
||||
* @noinspection PhpComposerExtensionStubsInspection
|
||||
*/
|
||||
@@ -34,7 +33,12 @@ class OnManagerStart implements SwooleEvent
|
||||
{
|
||||
private static $last_hash = '';
|
||||
|
||||
private static $watch = -1;
|
||||
private static $watch_tick_id = -1;
|
||||
|
||||
public static function getWatchTickId(): int
|
||||
{
|
||||
return self::$watch_tick_id;
|
||||
}
|
||||
|
||||
public function onCall(Server $server)
|
||||
{
|
||||
@@ -51,8 +55,7 @@ class OnManagerStart implements SwooleEvent
|
||||
if (Framework::$argv['watch']) {
|
||||
if (extension_loaded('inotify')) {
|
||||
Console::info('Enabled File watcher, framework will reload automatically.');
|
||||
/* @noinspection PhpUndefinedFieldInspection */
|
||||
Framework::$server->inotify = $fd = inotify_init();
|
||||
$fd = inotify_init();
|
||||
$this->addWatcher(DataProvider::getSourceRootDir() . '/src', $fd);
|
||||
Event::add($fd, function () use ($fd) {
|
||||
$r = inotify_read($fd);
|
||||
@@ -66,7 +69,7 @@ class OnManagerStart implements SwooleEvent
|
||||
}
|
||||
}
|
||||
if (Framework::$argv['polling-watch']) {
|
||||
self::$watch = swoole_timer_tick(3000, function () use ($server) {
|
||||
self::$watch_tick_id = swoole_timer_tick(3000, function () use ($server) {
|
||||
$data = (DataProvider::scanDirFiles(DataProvider::getSourceRootDir() . '/src/'));
|
||||
$hash = md5('');
|
||||
foreach ($data as $file) {
|
||||
|
||||
@@ -4,10 +4,9 @@ declare(strict_types=1);
|
||||
|
||||
namespace ZM\Event\SwooleEvent;
|
||||
|
||||
use Error;
|
||||
use Exception;
|
||||
use Swoole\Coroutine;
|
||||
use Swoole\WebSocket\Frame;
|
||||
use Throwable;
|
||||
use ZM\Annotation\Swoole\OnMessageEvent;
|
||||
use ZM\Annotation\Swoole\OnSwooleEvent;
|
||||
use ZM\Annotation\Swoole\SwooleHandler;
|
||||
@@ -53,11 +52,7 @@ class OnMessage implements SwooleEvent
|
||||
$dispatcher1->dispatchEvents($conn);
|
||||
$dispatcher->dispatchEvents($conn);
|
||||
// Console::success("Used ".round((microtime(true) - $starttime) * 1000, 3)." ms!");
|
||||
} catch (Exception $e) {
|
||||
$error_msg = $e->getMessage() . ' at ' . $e->getFile() . '(' . $e->getLine() . ')';
|
||||
Console::error(zm_internal_errcode('E00017') . 'Uncaught exception ' . get_class($e) . ' when calling "message": ' . $error_msg);
|
||||
Console::trace();
|
||||
} catch (Error $e) {
|
||||
} catch (Throwable $e) {
|
||||
$error_msg = $e->getMessage() . ' at ' . $e->getFile() . '(' . $e->getLine() . ')';
|
||||
Console::error(zm_internal_errcode('E00017') . 'Uncaught ' . get_class($e) . ' when calling "message": ' . $error_msg);
|
||||
Console::trace();
|
||||
|
||||
@@ -6,9 +6,8 @@ declare(strict_types=1);
|
||||
|
||||
namespace ZM\Event\SwooleEvent;
|
||||
|
||||
use Error;
|
||||
use Exception;
|
||||
use Swoole\Server;
|
||||
use Throwable;
|
||||
use ZM\Annotation\Swoole\SwooleHandler;
|
||||
use ZM\Console\Console;
|
||||
use ZM\Event\SwooleEvent;
|
||||
@@ -25,11 +24,7 @@ class OnPipeMessage implements SwooleEvent
|
||||
$data = json_decode($data, true);
|
||||
try {
|
||||
WorkerManager::workerAction($src_worker_id, $data);
|
||||
} catch (Exception $e) {
|
||||
$error_msg = $e->getMessage() . ' at ' . $e->getFile() . '(' . $e->getLine() . ')';
|
||||
Console::error(zm_internal_errcode('E00021') . 'Uncaught exception ' . get_class($e) . ' when calling "pipeMessage": ' . $error_msg);
|
||||
Console::trace();
|
||||
} catch (Error $e) {
|
||||
} catch (Throwable $e) {
|
||||
$error_msg = $e->getMessage() . ' at ' . $e->getFile() . '(' . $e->getLine() . ')';
|
||||
Console::error(zm_internal_errcode('E00021') . 'Uncaught ' . get_class($e) . ' when calling "pipeMessage": ' . $error_msg);
|
||||
Console::trace();
|
||||
|
||||
@@ -13,7 +13,7 @@ use ReflectionException;
|
||||
use Swoole\Coroutine;
|
||||
use Swoole\Database\PDOConfig;
|
||||
use Swoole\Process;
|
||||
use Swoole\Server;
|
||||
use Swoole\WebSocket\Server;
|
||||
use ZM\Annotation\AnnotationParser;
|
||||
use ZM\Annotation\Swoole\OnMessageEvent;
|
||||
use ZM\Annotation\Swoole\OnStart;
|
||||
@@ -45,7 +45,7 @@ use ZM\Utils\SignalListener;
|
||||
*/
|
||||
class OnWorkerStart implements SwooleEvent
|
||||
{
|
||||
public function onCall(Server $server, $worker_id)
|
||||
public function onCall(Server $server, int $worker_id)
|
||||
{
|
||||
Console::debug('Calling onWorkerStart event(1)');
|
||||
if (!Framework::$argv['disable-safe-exit']) {
|
||||
@@ -68,12 +68,7 @@ class OnWorkerStart implements SwooleEvent
|
||||
return;
|
||||
}
|
||||
// DataProvider::saveBuffer();
|
||||
/* @var Server $server */
|
||||
if (server() === null) {
|
||||
$server->shutdown();
|
||||
} else {
|
||||
server()->shutdown();
|
||||
}
|
||||
$server->shutdown();
|
||||
});
|
||||
|
||||
Console::verbose("Worker #{$server->worker_id} starting");
|
||||
@@ -161,7 +156,7 @@ class OnWorkerStart implements SwooleEvent
|
||||
$exclude_annotations = array_merge($composer['extra']['exclude_annotate'] ?? [], $composer['extra']['zm']['exclude-annotation-path'] ?? []);
|
||||
foreach ($merge as $k => $v) {
|
||||
if (is_dir(DataProvider::getSourceRootDir() . '/' . $v)) {
|
||||
if (in_array(trim($k, '\\') . '\\', $exclude_annotations)) {
|
||||
if (in_array($v, $exclude_annotations)) {
|
||||
continue;
|
||||
}
|
||||
if (trim($k, '\\') == 'ZM') {
|
||||
|
||||
@@ -144,9 +144,9 @@ class Framework
|
||||
$this->server_set['log_level'] = SWOOLE_LOG_DEBUG;
|
||||
$add_port = ZMConfig::get('global', 'remote_terminal')['status'] ?? false;
|
||||
|
||||
// if ($instant_mode) {
|
||||
$this->loadServerEvents();
|
||||
// }
|
||||
if (!$instant_mode) {
|
||||
$this->loadServerEvents();
|
||||
}
|
||||
|
||||
$this->parseCliArgs(self::$argv, $add_port);
|
||||
|
||||
@@ -205,7 +205,9 @@ class Framework
|
||||
$out['terminal'] = $conf['host'] . ':' . $conf['port'];
|
||||
}
|
||||
|
||||
self::printProps($out, $tty_width, $args['log-theme'] === null);
|
||||
if (!self::$argv['private-mode']) {
|
||||
self::printProps($out, $tty_width, $args['log-theme'] === null);
|
||||
}
|
||||
if ($args['preview'] ?? false) {
|
||||
exit();
|
||||
}
|
||||
@@ -294,7 +296,9 @@ class Framework
|
||||
|
||||
self::$server->set($this->server_set);
|
||||
Console::setServer(self::$server);
|
||||
self::printMotd($tty_width);
|
||||
if (!self::$argv['private-mode']) {
|
||||
self::printMotd($tty_width);
|
||||
}
|
||||
|
||||
global $asd;
|
||||
$asd = get_included_files();
|
||||
@@ -443,7 +447,7 @@ class Framework
|
||||
}
|
||||
|
||||
/**
|
||||
* @param null $id_or_name
|
||||
* @param null|int|string $id_or_name
|
||||
* @throws ZMKnownException
|
||||
* @internal
|
||||
*/
|
||||
@@ -655,10 +659,10 @@ class Framework
|
||||
|
||||
/**
|
||||
* 解析命令行的 $argv 参数们
|
||||
* @param $args
|
||||
* @param $add_port
|
||||
* @param array $args 命令行参数
|
||||
* @param bool|string $add_port 是否添加端口号
|
||||
*/
|
||||
private function parseCliArgs($args, &$add_port)
|
||||
private function parseCliArgs(array $args, &$add_port)
|
||||
{
|
||||
$coroutine_mode = true;
|
||||
global $terminal_id;
|
||||
|
||||
@@ -9,6 +9,8 @@ declare(strict_types=1);
|
||||
|
||||
namespace ZM\Http;
|
||||
|
||||
use Stringable;
|
||||
|
||||
class Response
|
||||
{
|
||||
public $fd = 0;
|
||||
@@ -55,11 +57,11 @@ class Response
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $name
|
||||
* @param mixed ...$params
|
||||
* @return mixed
|
||||
* @param string $name 名称
|
||||
* @param mixed ...$params 参数
|
||||
* @return mixed 返回值
|
||||
*/
|
||||
public function cookie($name, ...$params)
|
||||
public function cookie(string $name, ...$params)
|
||||
{
|
||||
return empty($params) ? $this->response->rawcookie($name) : $this->response->rawcookie($name, ...$params);
|
||||
}
|
||||
@@ -85,11 +87,10 @@ class Response
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $http_code
|
||||
* @param $reason
|
||||
* @param mixed ...$params
|
||||
* @return mixed
|
||||
*/
|
||||
public function status($http_code, ...$params)
|
||||
public function status(int $http_code, ...$params)
|
||||
{
|
||||
$this->status_code = $http_code;
|
||||
if (!$this->is_end) {
|
||||
@@ -104,11 +105,10 @@ class Response
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $http_code
|
||||
* @param $reason
|
||||
* @param mixed ...$params
|
||||
* @return mixed
|
||||
*/
|
||||
public function setStatusCode($http_code, ...$params)
|
||||
public function setStatusCode(int $http_code, ...$params)
|
||||
{
|
||||
if (!$this->is_end) {
|
||||
return empty($params) ? $this->response->status($http_code) : $this->response->status($http_code, ...$params);
|
||||
@@ -117,12 +117,11 @@ class Response
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $key
|
||||
* @param $value
|
||||
* @param $ucwords
|
||||
* @param array|string $value
|
||||
* @param null|array|string $ucwords
|
||||
* @return mixed
|
||||
*/
|
||||
public function header($key, $value, $ucwords = null)
|
||||
public function header(string $key, $value, $ucwords = null)
|
||||
{
|
||||
if (!$this->is_end) {
|
||||
return $ucwords === null ? $this->response->header($key, $value) : $this->response->header($key, $value, $ucwords);
|
||||
@@ -131,12 +130,11 @@ class Response
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $key
|
||||
* @param $value
|
||||
* @param $ucwords
|
||||
* @param array|string $value
|
||||
* @param null|array|string $ucwords
|
||||
* @return mixed
|
||||
*/
|
||||
public function setHeader($key, $value, $ucwords = null)
|
||||
public function setHeader(string $key, $value, $ucwords = null)
|
||||
{
|
||||
if (!$this->is_end) {
|
||||
return $ucwords === null ? $this->response->setHeader($key, $value) : $this->response->setHeader($key, $value, $ucwords);
|
||||
@@ -145,11 +143,10 @@ class Response
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $key
|
||||
* @param $value
|
||||
* @param array|string $value
|
||||
* @return mixed
|
||||
*/
|
||||
public function trailer($key, $value)
|
||||
public function trailer(string $key, $value)
|
||||
{
|
||||
return $this->response->trailer($key, $value);
|
||||
}
|
||||
@@ -163,7 +160,7 @@ class Response
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $content
|
||||
* @param string|Stringable $content
|
||||
* @return mixed
|
||||
*/
|
||||
public function write($content)
|
||||
@@ -172,7 +169,7 @@ class Response
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $content
|
||||
* @param null|string|Stringable $content
|
||||
* @return mixed
|
||||
*/
|
||||
public function end($content = null)
|
||||
@@ -196,22 +193,19 @@ class Response
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $filename
|
||||
* @param $offset
|
||||
* @param $length
|
||||
* @param null|int|string $offset
|
||||
* @param null|int|string $length
|
||||
* @return mixed
|
||||
*/
|
||||
public function sendfile($filename, $offset = null, $length = null)
|
||||
public function sendfile(string $filename, $offset = null, $length = null)
|
||||
{
|
||||
return $this->response->sendfile($filename, $offset, $length);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $location
|
||||
* @param $http_code
|
||||
* @return mixed
|
||||
*/
|
||||
public function redirect($location, $http_code = null)
|
||||
public function redirect(string $location, ?int $http_code = null)
|
||||
{
|
||||
$this->is_end = true;
|
||||
return $this->response->redirect($location, $http_code);
|
||||
@@ -226,7 +220,7 @@ class Response
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $fd
|
||||
* @param mixed $fd
|
||||
* @return mixed
|
||||
*/
|
||||
public static function create($fd)
|
||||
@@ -243,9 +237,9 @@ class Response
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $data
|
||||
* @param null $opcode
|
||||
* @param null $flags
|
||||
* @param mixed $data
|
||||
* @param mixed $opcode
|
||||
* @param mixed $flags
|
||||
* @return mixed
|
||||
*/
|
||||
public function push($data, $opcode = null, $flags = null)
|
||||
|
||||
@@ -19,17 +19,16 @@ class StaticFileHandler
|
||||
if (strpos($full_path, $path) !== 0) {
|
||||
$response->status(403);
|
||||
$response->end('403 Forbidden');
|
||||
return true;
|
||||
return;
|
||||
}
|
||||
if (is_file($full_path)) {
|
||||
$exp = strtolower(pathinfo($full_path)['extension'] ?? 'unknown');
|
||||
$response->setHeader('Content-Type', ZMConfig::get('file_header')[$exp] ?? 'application/octet-stream');
|
||||
$response->end(file_get_contents($full_path));
|
||||
return true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
$response->status(404);
|
||||
$response->end(HttpUtil::getHttpCodePage(404));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,9 +57,9 @@ class ModulePacker
|
||||
|
||||
/**
|
||||
* 设置输出文件夹
|
||||
* @param $path
|
||||
* @param string $path 输出路径
|
||||
*/
|
||||
public function setOutputPath($path)
|
||||
public function setOutputPath(string $path)
|
||||
{
|
||||
$this->output_path = $path;
|
||||
if (!is_dir($path)) {
|
||||
|
||||
@@ -5,6 +5,7 @@ declare(strict_types=1);
|
||||
namespace ZM\Module;
|
||||
|
||||
use Exception;
|
||||
use Iterator;
|
||||
use ZM\Annotation\CQ\CQAfter;
|
||||
use ZM\Annotation\CQ\CQAPIResponse;
|
||||
use ZM\Annotation\CQ\CQBefore;
|
||||
@@ -17,6 +18,7 @@ use ZM\Config\ZMConfig;
|
||||
use ZM\Event\EventDispatcher;
|
||||
use ZM\Exception\InterruptException;
|
||||
use ZM\Exception\WaitTimeoutException;
|
||||
use ZM\Exception\ZMKnownException;
|
||||
use ZM\Utils\CoMessage;
|
||||
use ZM\Utils\MessageUtil;
|
||||
use ZM\Utils\SingletonTrait;
|
||||
@@ -28,18 +30,24 @@ class QQBot
|
||||
{
|
||||
use SingletonTrait;
|
||||
|
||||
/**
|
||||
* @throws ZMKnownException
|
||||
* @throws InterruptException
|
||||
*/
|
||||
public function handleByEvent()
|
||||
{
|
||||
$data = json_decode(context()->getFrame()->data, true);
|
||||
$data = json_decode(ctx()->getFrame()->data, true);
|
||||
$this->handle($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $data
|
||||
* @param int $level
|
||||
* @param array|Iterator $data 数据包
|
||||
* @param int $level 递归等级
|
||||
* @throws InterruptException
|
||||
* @throws ZMKnownException
|
||||
* @throws Exception
|
||||
*/
|
||||
public function handle($data, $level = 0)
|
||||
public function handle($data, int $level = 0)
|
||||
{
|
||||
try {
|
||||
if ($level > 10) {
|
||||
@@ -102,11 +110,11 @@ class QQBot
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $data
|
||||
* @param $time
|
||||
* @param array|Iterator $data 数据包
|
||||
* @param string $time 类型(pre或post)
|
||||
* @throws Exception
|
||||
*/
|
||||
public function dispatchBeforeEvents($data, $time): EventDispatcher
|
||||
public function dispatchBeforeEvents($data, string $time): EventDispatcher
|
||||
{
|
||||
$before = new EventDispatcher(CQBefore::class);
|
||||
if ($time === 'pre') {
|
||||
@@ -128,7 +136,7 @@ class QQBot
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $data
|
||||
* @param array|Iterator $data 数据包
|
||||
* @throws InterruptException
|
||||
* @throws Exception
|
||||
*/
|
||||
@@ -147,7 +155,11 @@ class QQBot
|
||||
EventDispatcher::interrupt();
|
||||
}
|
||||
});
|
||||
$s = MessageUtil::matchCommand(ctx()->getStringMessage(), ctx()->getData());
|
||||
$msg = $data['message'];
|
||||
if (is_array($msg)) {
|
||||
$msg = MessageUtil::arrayToStr($msg);
|
||||
}
|
||||
$s = MessageUtil::matchCommand($msg, ctx()->getData());
|
||||
if ($s->status !== false) {
|
||||
if (!empty($s->match)) {
|
||||
ctx()->setCache('match', $s->match);
|
||||
@@ -173,7 +185,7 @@ class QQBot
|
||||
// 分发CQMessage事件
|
||||
$msg_dispatcher = new EventDispatcher(CQMessage::class);
|
||||
$msg_dispatcher->setRuleFunction(function ($v) {
|
||||
return ($v->message == '' || ($v->message == ctx()->getStringMessage()))
|
||||
return ($v->message == '' || ($v->message == ctx()->getMessage()))
|
||||
&& ($v->user_id == 0 || ($v->user_id == ctx()->getUserId()))
|
||||
&& ($v->group_id == 0 || ($v->group_id == (ctx()->getGroupId() ?? 0)))
|
||||
&& ($v->message_type == '' || ($v->message_type == ctx()->getMessageType()))
|
||||
@@ -190,7 +202,7 @@ class QQBot
|
||||
// Console::success("当前数据包:".json_encode(ctx()->getData()));
|
||||
$dispatcher = new EventDispatcher(CQMetaEvent::class);
|
||||
$dispatcher->setRuleFunction(function (CQMetaEvent $v) {
|
||||
return $v->meta_event_type == '' || ($v->meta_event_type != '' && $v->meta_event_type == ctx()->getData()['meta_event_type']);
|
||||
return $v->meta_event_type == '' || ($v->meta_event_type == ctx()->getData()['meta_event_type']);
|
||||
});
|
||||
// eval(BP);
|
||||
$dispatcher->dispatchEvents(ctx()->getData());
|
||||
@@ -199,26 +211,30 @@ class QQBot
|
||||
$dispatcher = new EventDispatcher(CQNotice::class);
|
||||
$dispatcher->setRuleFunction(function (CQNotice $v) {
|
||||
return
|
||||
($v->notice_type == '' || ($v->notice_type != '' && $v->notice_type == ctx()->getData()['notice_type']))
|
||||
&& ($v->sub_type == '' || ($v->sub_type != '' && $v->sub_type == ctx()->getData()['sub_type']))
|
||||
&& ($v->group_id == '' || ($v->group_id != '' && $v->group_id == ctx()->getData()['group_id']))
|
||||
&& ($v->operator_id == '' || ($v->operator_id != '' && $v->operator_id == ctx()->getData()['operator_id']));
|
||||
($v->notice_type == '' || ($v->notice_type == ctx()->getData()['notice_type']))
|
||||
&& ($v->sub_type == '' || ($v->sub_type == ctx()->getData()['sub_type']))
|
||||
&& ($v->group_id == '' || ($v->group_id == ctx()->getData()['group_id']))
|
||||
&& ($v->operator_id == '' || ($v->operator_id == ctx()->getData()['operator_id']));
|
||||
});
|
||||
$dispatcher->dispatchEvents(ctx()->getData());
|
||||
return;
|
||||
case 'request':
|
||||
$dispatcher = new EventDispatcher(CQRequest::class);
|
||||
$dispatcher->setRuleFunction(function (CQRequest $v) {
|
||||
return ($v->request_type == '' || ($v->request_type != '' && $v->request_type == ctx()->getData()['request_type']))
|
||||
&& ($v->sub_type == '' || ($v->sub_type != '' && $v->sub_type == ctx()->getData()['sub_type']))
|
||||
&& ($v->user_id == 0 || ($v->user_id != 0 && $v->user_id == ctx()->getData()['user_id']))
|
||||
&& ($v->comment == '' || ($v->comment != '' && $v->comment == ctx()->getData()['comment']));
|
||||
return ($v->request_type == '' || ($v->request_type == ctx()->getData()['request_type']))
|
||||
&& ($v->sub_type == '' || ($v->sub_type == ctx()->getData()['sub_type']))
|
||||
&& ($v->user_id == 0 || ($v->user_id == ctx()->getData()['user_id']))
|
||||
&& ($v->comment == '' || ($v->comment == ctx()->getData()['comment']));
|
||||
});
|
||||
$dispatcher->dispatchEvents(ctx()->getData());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $data 分发事件数据包
|
||||
* @throws Exception
|
||||
*/
|
||||
private function dispatchAfterEvents($data): EventDispatcher
|
||||
{
|
||||
$after = new EventDispatcher(CQAfter::class);
|
||||
@@ -230,7 +246,7 @@ class QQBot
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $req
|
||||
* @param mixed $req
|
||||
* @throws Exception
|
||||
*/
|
||||
private function dispatchAPIResponse($req)
|
||||
|
||||
@@ -10,9 +10,7 @@ use Doctrine\DBAL\Driver\Connection;
|
||||
use Doctrine\DBAL\ParameterType;
|
||||
use PDO;
|
||||
use PDOException;
|
||||
use PDOStatement;
|
||||
use Swoole\Database\PDOProxy;
|
||||
use Swoole\Database\PDOStatementProxy;
|
||||
use ZM\Console\Console;
|
||||
use ZM\Exception\DbException;
|
||||
use ZM\Store\MySQL\SqlPoolStorage;
|
||||
@@ -34,23 +32,31 @@ class MySQLConnection implements Connection
|
||||
SqlPoolStorage::$sql_pool->putConnection($this->conn);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $sql
|
||||
* @param mixed $options
|
||||
* @throws DbException
|
||||
*/
|
||||
public function prepare($sql, $options = [])
|
||||
{
|
||||
try {
|
||||
Console::debug('Running SQL prepare: ' . $sql);
|
||||
$statement = $this->conn->prepare($sql, $options);
|
||||
assert(($statement instanceof PDOStatementProxy) || ($statement instanceof PDOStatement));
|
||||
assert($statement !== false);
|
||||
} catch (PDOException $exception) {
|
||||
throw new DbException($exception->getMessage(), $exception->getCode(), $exception);
|
||||
}
|
||||
return new MySQLStatement($statement);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws DbException
|
||||
*/
|
||||
public function query(...$args)
|
||||
{
|
||||
try {
|
||||
$statement = $this->conn->query(...$args);
|
||||
assert(($statement instanceof PDOStatementProxy) || ($statement instanceof PDOStatement));
|
||||
assert($statement !== false);
|
||||
} catch (PDOException $exception) {
|
||||
throw new DbException($exception->getMessage(), $exception->getCode(), $exception);
|
||||
}
|
||||
@@ -62,6 +68,10 @@ class MySQLConnection implements Connection
|
||||
return $this->conn->quote($value, $type);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $sql
|
||||
* @throws DbException
|
||||
*/
|
||||
public function exec($sql)
|
||||
{
|
||||
try {
|
||||
@@ -74,6 +84,10 @@ class MySQLConnection implements Connection
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param null|mixed $name
|
||||
* @throws DbException
|
||||
*/
|
||||
public function lastInsertId($name = null)
|
||||
{
|
||||
try {
|
||||
|
||||
@@ -14,11 +14,10 @@ use Doctrine\DBAL\ParameterType;
|
||||
use IteratorAggregate;
|
||||
use PDO;
|
||||
use PDOStatement;
|
||||
use Swoole\Database\PDOStatementProxy;
|
||||
|
||||
class MySQLStatement implements IteratorAggregate, Statement
|
||||
{
|
||||
/** @var PDOStatement|PDOStatementProxy */
|
||||
/** @var PDOStatement */
|
||||
private $statement;
|
||||
|
||||
public function __construct($obj)
|
||||
@@ -108,8 +107,15 @@ class MySQLStatement implements IteratorAggregate, Statement
|
||||
return new StatementIterator($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated 最好不使用此方法,此方法可能存在 Bug
|
||||
* @return mixed
|
||||
*/
|
||||
public function current()
|
||||
{
|
||||
return $this->statement->current();
|
||||
if (method_exists($this->statement, 'current')) {
|
||||
return $this->statement->current();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,12 +13,14 @@ use Doctrine\DBAL\Cache\QueryCacheProfile;
|
||||
use Doctrine\DBAL\Connection;
|
||||
use Doctrine\DBAL\DriverManager;
|
||||
use Doctrine\DBAL\ParameterType;
|
||||
use Doctrine\DBAL\Types\Type;
|
||||
use Throwable;
|
||||
use Traversable;
|
||||
use ZM\Exception\DbException;
|
||||
|
||||
class MySQLWrapper
|
||||
{
|
||||
/** @var Connection */
|
||||
private $connection;
|
||||
|
||||
/**
|
||||
@@ -57,11 +59,10 @@ class MySQLWrapper
|
||||
|
||||
/**
|
||||
* wrapper method
|
||||
* @param $autoCommit
|
||||
*/
|
||||
public function setAutoCommit($autoCommit)
|
||||
public function setAutoCommit(bool $auto_commit)
|
||||
{
|
||||
$this->connection->setAutoCommit($autoCommit);
|
||||
$this->connection->setAutoCommit($auto_commit);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -114,10 +115,10 @@ class MySQLWrapper
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $table
|
||||
* @param string $table 表
|
||||
* @throws DbException
|
||||
*/
|
||||
public function delete($table, array $criteria, array $types = []): int
|
||||
public function delete(string $table, array $criteria, array $types = []): int
|
||||
{
|
||||
try {
|
||||
return $this->connection->delete($table, $criteria, $types);
|
||||
@@ -128,9 +129,9 @@ class MySQLWrapper
|
||||
|
||||
/**
|
||||
* wrapper method
|
||||
* @param $level
|
||||
* @param int $level Sets the transaction isolation level
|
||||
*/
|
||||
public function setTransactionIsolation($level): int
|
||||
public function setTransactionIsolation(int $level): int
|
||||
{
|
||||
return $this->connection->setTransactionIsolation($level);
|
||||
}
|
||||
@@ -145,10 +146,10 @@ class MySQLWrapper
|
||||
|
||||
/**
|
||||
* wrapper method
|
||||
* @param $table
|
||||
* @param string $table 表名
|
||||
* @throws DbException
|
||||
*/
|
||||
public function update($table, array $data, array $criteria, array $types = []): int
|
||||
public function update(string $table, array $data, array $criteria, array $types = []): int
|
||||
{
|
||||
try {
|
||||
return $this->connection->update($table, $data, $criteria, $types);
|
||||
@@ -159,10 +160,10 @@ class MySQLWrapper
|
||||
|
||||
/**
|
||||
* wrapper method
|
||||
* @param $table
|
||||
* @param string $table 表名
|
||||
* @throws DbException
|
||||
*/
|
||||
public function insert($table, array $data, array $types = []): int
|
||||
public function insert(string $table, array $data, array $types = []): int
|
||||
{
|
||||
try {
|
||||
return $this->connection->insert($table, $data, $types);
|
||||
@@ -173,18 +174,17 @@ class MySQLWrapper
|
||||
|
||||
/**
|
||||
* wrapper method
|
||||
* @param $str
|
||||
* @param string $str The name to be quoted
|
||||
*/
|
||||
public function quoteIdentifier($str): string
|
||||
public function quoteIdentifier(string $str): string
|
||||
{
|
||||
return $this->connection->quoteIdentifier($str);
|
||||
}
|
||||
|
||||
/**
|
||||
* wrapper method
|
||||
* @param $value
|
||||
* @param int $type
|
||||
* @return mixed
|
||||
* @param mixed $value
|
||||
* @param null|int|string|Type $type
|
||||
*/
|
||||
public function quote($value, $type = ParameterType::STRING)
|
||||
{
|
||||
@@ -193,7 +193,12 @@ class MySQLWrapper
|
||||
|
||||
/**
|
||||
* wrapper method
|
||||
* @param string $query SQL query
|
||||
* @param array<int, mixed>|array<string, mixed> $params Query parameters
|
||||
* @param array<int, null|int|string|Type>|array<string, null|int|string|Type> $types Parameter types
|
||||
*
|
||||
* @throws DbException
|
||||
* @return array<int,array<int,mixed>>
|
||||
*/
|
||||
public function fetchAllNumeric(string $query, array $params = [], array $types = []): array
|
||||
{
|
||||
@@ -206,7 +211,12 @@ class MySQLWrapper
|
||||
|
||||
/**
|
||||
* wrapper method
|
||||
* @param string $query SQL query
|
||||
* @param array<int, mixed>|array<string, mixed> $params Query parameters
|
||||
* @param array<int, null|int|string|Type>|array<string, null|int|string|Type> $types Parameter types
|
||||
*
|
||||
* @throws DbException
|
||||
* @return array<int,array<string,mixed>>
|
||||
*/
|
||||
public function fetchAllAssociative(string $query, array $params = [], array $types = []): array
|
||||
{
|
||||
@@ -219,6 +229,10 @@ class MySQLWrapper
|
||||
|
||||
/**
|
||||
* wrapper method
|
||||
* @param string $query SQL query
|
||||
* @param array<int, mixed>|array<string, mixed> $params Query parameters
|
||||
* @param array<int, int|string>|array<string, int|string> $types Parameter types
|
||||
*
|
||||
* @throws DbException
|
||||
*/
|
||||
public function fetchAllKeyValue(string $query, array $params = [], array $types = []): array
|
||||
@@ -232,7 +246,12 @@ class MySQLWrapper
|
||||
|
||||
/**
|
||||
* wrapper method
|
||||
* @param string $query SQL query
|
||||
* @param array<int, mixed>|array<string, mixed> $params Query parameters
|
||||
* @param array<int, int|string>|array<string, int|string> $types Parameter types
|
||||
*
|
||||
* @throws DbException
|
||||
* @return array<mixed,array<string,mixed>>
|
||||
*/
|
||||
public function fetchAllAssociativeIndexed(string $query, array $params = [], array $types = []): array
|
||||
{
|
||||
@@ -245,7 +264,12 @@ class MySQLWrapper
|
||||
|
||||
/**
|
||||
* wrapper method
|
||||
* @param string $query SQL query
|
||||
* @param array<int, mixed>|array<string, mixed> $params Query parameters
|
||||
* @param array<int, null|int|string|Type>|array<string, null|int|string|Type> $types Parameter types
|
||||
*
|
||||
* @throws DbException
|
||||
* @return array<int,mixed>
|
||||
*/
|
||||
public function fetchFirstColumn(string $query, array $params = [], array $types = []): array
|
||||
{
|
||||
@@ -258,7 +282,12 @@ class MySQLWrapper
|
||||
|
||||
/**
|
||||
* wrapper method
|
||||
* @param string $query SQL query
|
||||
* @param array<int, mixed>|array<string, mixed> $params Query parameters
|
||||
* @param array<int, null|int|string|Type>|array<string, null|int|string|Type> $types Parameter types
|
||||
*
|
||||
* @throws DbException
|
||||
* @return Traversable<int,array<int,mixed>>
|
||||
*/
|
||||
public function iterateNumeric(string $query, array $params = [], array $types = []): Traversable
|
||||
{
|
||||
@@ -271,7 +300,12 @@ class MySQLWrapper
|
||||
|
||||
/**
|
||||
* wrapper method
|
||||
* @param string $query SQL query
|
||||
* @param array<int, mixed>|array<string, mixed> $params Query parameters
|
||||
* @param array<int, null|int|string|Type>|array<string, null|int|string|Type> $types Parameter types
|
||||
*
|
||||
* @throws DbException
|
||||
* @return Traversable<int,array<string,mixed>>
|
||||
*/
|
||||
public function iterateAssociative(string $query, array $params = [], array $types = []): Traversable
|
||||
{
|
||||
@@ -284,7 +318,12 @@ class MySQLWrapper
|
||||
|
||||
/**
|
||||
* wrapper method
|
||||
* @param string $query SQL query
|
||||
* @param array<int, mixed>|array<string, mixed> $params Query parameters
|
||||
* @param array<int, int|string>|array<string, int|string> $types Parameter types
|
||||
*
|
||||
* @throws DbException
|
||||
* @return Traversable<mixed,mixed>
|
||||
*/
|
||||
public function iterateKeyValue(string $query, array $params = [], array $types = []): Traversable
|
||||
{
|
||||
@@ -297,7 +336,12 @@ class MySQLWrapper
|
||||
|
||||
/**
|
||||
* wrapper method
|
||||
* @param string $query SQL query
|
||||
* @param array<int, mixed>|array<string, mixed> $params Query parameters
|
||||
* @param array<int, int|string>|array<string, int|string> $types Parameter types
|
||||
*
|
||||
* @throws DbException
|
||||
* @return Traversable<mixed,array<string,mixed>>
|
||||
*/
|
||||
public function iterateAssociativeIndexed(string $query, array $params = [], array $types = []): Traversable
|
||||
{
|
||||
@@ -310,7 +354,12 @@ class MySQLWrapper
|
||||
|
||||
/**
|
||||
* wrapper method
|
||||
* @param string $query SQL query
|
||||
* @param array<int, mixed>|array<string, mixed> $params Query parameters
|
||||
* @param array<int, null|int|string|Type>|array<string, null|int|string|Type> $types Parameter types
|
||||
*
|
||||
* @throws DbException
|
||||
* @return Traversable<int,mixed>
|
||||
*/
|
||||
public function iterateColumn(string $query, array $params = [], array $types = []): Traversable
|
||||
{
|
||||
@@ -323,11 +372,13 @@ class MySQLWrapper
|
||||
|
||||
/**
|
||||
* wrapper method
|
||||
* @param $sql
|
||||
* @param array $types
|
||||
* @param string $sql SQL query
|
||||
* @param array<int, mixed>|array<string, mixed> $params Query parameters
|
||||
* @param array<int, null|int|string|Type>|array<string, null|int|string|Type> $types Parameter types
|
||||
*
|
||||
* @throws DbException
|
||||
*/
|
||||
public function executeQuery($sql, array $params = [], $types = [], ?QueryCacheProfile $qcp = null): MySQLStatementWrapper
|
||||
public function executeQuery(string $sql, array $params = [], array $types = [], ?QueryCacheProfile $qcp = null): MySQLStatementWrapper
|
||||
{
|
||||
try {
|
||||
$query = $this->connection->executeQuery($sql, $params, $types, $qcp);
|
||||
@@ -339,12 +390,12 @@ class MySQLWrapper
|
||||
|
||||
/**
|
||||
* wrapper method
|
||||
* @param $sql
|
||||
* @param $params
|
||||
* @param $types
|
||||
* @param string $sql SQL query
|
||||
* @param array<int, mixed>|array<string, mixed> $params Query parameters
|
||||
* @param array<int, null|int|string|Type>|array<string, null|int|string|Type> $types Parameter types
|
||||
* @throws DbException
|
||||
*/
|
||||
public function executeCacheQuery($sql, $params, $types, QueryCacheProfile $qcp): MySQLStatementWrapper
|
||||
public function executeCacheQuery(string $sql, array $params, array $types, QueryCacheProfile $qcp): MySQLStatementWrapper
|
||||
{
|
||||
try {
|
||||
$query = $this->connection->executeCacheQuery($sql, $params, $types, $qcp);
|
||||
@@ -356,10 +407,14 @@ class MySQLWrapper
|
||||
|
||||
/**
|
||||
* wrapper method
|
||||
* @param $sql
|
||||
* @param string $sql SQL statement
|
||||
* @param array<int, mixed>|array<string, mixed> $params Statement parameters
|
||||
* @param array<int, null|int|string|Type>|array<string, null|int|string|Type> $types Parameter types
|
||||
*
|
||||
* @throws DbException
|
||||
* @return int|string the number of affected rows
|
||||
*/
|
||||
public function executeStatement($sql, array $params = [], array $types = []): int
|
||||
public function executeStatement(string $sql, array $params = [], array $types = [])
|
||||
{
|
||||
try {
|
||||
return $this->connection->executeStatement($sql, $params, $types);
|
||||
@@ -378,9 +433,10 @@ class MySQLWrapper
|
||||
|
||||
/**
|
||||
* wrapper method
|
||||
* @param null $name
|
||||
* @param null|string $name name of the sequence object from which the ID should be returned
|
||||
* @return false|int|string a string representation of the last inserted ID
|
||||
*/
|
||||
public function lastInsertId($name = null): string
|
||||
public function lastInsertId(?string $name = null)
|
||||
{
|
||||
return $this->connection->lastInsertId($name);
|
||||
}
|
||||
@@ -405,13 +461,12 @@ class MySQLWrapper
|
||||
|
||||
/**
|
||||
* wrapper method
|
||||
* @param $nestTransactionsWithSavepoints
|
||||
* @throws DbException
|
||||
*/
|
||||
public function setNestTransactionsWithSavepoints($nestTransactionsWithSavepoints)
|
||||
public function setNestTransactionsWithSavepoints(bool $nest_transactions_with_savepoints)
|
||||
{
|
||||
try {
|
||||
$this->connection->setNestTransactionsWithSavepoints($nestTransactionsWithSavepoints);
|
||||
$this->connection->setNestTransactionsWithSavepoints($nest_transactions_with_savepoints);
|
||||
} catch (Throwable $e) {
|
||||
throw new DbException($e->getMessage(), $e->getCode(), $e);
|
||||
}
|
||||
@@ -461,10 +516,10 @@ class MySQLWrapper
|
||||
|
||||
/**
|
||||
* wrapper method
|
||||
* @param $savepoint
|
||||
* @param string $savepoint the name of the savepoint to create
|
||||
* @throws DbException
|
||||
*/
|
||||
public function createSavepoint($savepoint)
|
||||
public function createSavepoint(string $savepoint)
|
||||
{
|
||||
try {
|
||||
$this->connection->createSavepoint($savepoint);
|
||||
@@ -475,10 +530,10 @@ class MySQLWrapper
|
||||
|
||||
/**
|
||||
* wrapper method
|
||||
* @param $savepoint
|
||||
* @param string $savepoint the name of the savepoint to release
|
||||
* @throws DbException
|
||||
*/
|
||||
public function releaseSavepoint($savepoint)
|
||||
public function releaseSavepoint(string $savepoint)
|
||||
{
|
||||
try {
|
||||
$this->connection->releaseSavepoint($savepoint);
|
||||
@@ -489,10 +544,10 @@ class MySQLWrapper
|
||||
|
||||
/**
|
||||
* wrapper method
|
||||
* @param $savepoint
|
||||
* @param string $savepoint the name of the savepoint to rollback to
|
||||
* @throws DbException
|
||||
*/
|
||||
public function rollbackSavepoint($savepoint)
|
||||
public function rollbackSavepoint(string $savepoint)
|
||||
{
|
||||
try {
|
||||
$this->connection->rollbackSavepoint($savepoint);
|
||||
|
||||
@@ -24,11 +24,11 @@ class LightCache
|
||||
private static $config = [];
|
||||
|
||||
/**
|
||||
* @param $config
|
||||
* @param array $config 配置
|
||||
* @throws Exception
|
||||
* @return bool|mixed
|
||||
* @return bool|mixed 返回失败(false)或创建SwooleTable成功结果
|
||||
*/
|
||||
public static function init($config)
|
||||
public static function init(array $config)
|
||||
{
|
||||
self::$config = $config;
|
||||
self::$kv_table = new Table($config['size'], $config['hash_conflict_proportion']);
|
||||
@@ -169,7 +169,7 @@ class LightCache
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $value
|
||||
* @param mixed $value
|
||||
* @throws ZMException
|
||||
* @return bool
|
||||
*/
|
||||
|
||||
@@ -38,8 +38,7 @@ class LightCacheInside
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|int|string $value
|
||||
* @return mixed
|
||||
* @param array|int|string $value
|
||||
*/
|
||||
public static function set(string $table, string $key, $value): bool
|
||||
{
|
||||
@@ -58,13 +57,10 @@ class LightCacheInside
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $name
|
||||
* @param $size
|
||||
* @param $str_size
|
||||
* @param int $conflict_proportion
|
||||
* @param float|int $conflict_proportion
|
||||
* @throws ZMException
|
||||
*/
|
||||
private static function createTable($name, $size, $str_size, $conflict_proportion = 0)
|
||||
private static function createTable(string $name, int $size, int $str_size, $conflict_proportion = 0)
|
||||
{
|
||||
self::$kv_table[$name] = new Table($size, $conflict_proportion);
|
||||
self::$kv_table[$name]->column('value', Table::TYPE_STRING, $str_size);
|
||||
|
||||
@@ -8,6 +8,6 @@ use ZM\MySQL\MySQLPool;
|
||||
|
||||
class SqlPoolStorage
|
||||
{
|
||||
/** @var MySQLPool */
|
||||
/** @var null|MySQLPool */
|
||||
public static $sql_pool;
|
||||
}
|
||||
|
||||
@@ -12,10 +12,7 @@ class ZMAtomic
|
||||
/** @var Atomic[] */
|
||||
public static $atomics;
|
||||
|
||||
/**
|
||||
* @param $name
|
||||
*/
|
||||
public static function get($name): ?Atomic
|
||||
public static function get(string $name): ?Atomic
|
||||
{
|
||||
return self::$atomics[$name] ?? null;
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user