some patch for 3.0 release

This commit is contained in:
crazywhalecc 2023-02-10 16:03:21 +08:00 committed by Jerry
parent 70886ecd43
commit 77c1d5ab17
4 changed files with 6 additions and 8 deletions

View File

@ -240,7 +240,7 @@ function install_framework() {
$composer_executable init --name="zhamao/zhamao-v3-app" -n -q && \
if_use_aliyun && \
echo "$(nhead) 从 Composer 拉取框架 ..." && \
echo '{"minimum-stability":"dev"}' > composer.json && composer require -n zhamao/framework:^3 && \
echo '{"minimum-stability":"dev","prefer-stable":true}' > composer.json && composer require -n zhamao/framework:^3.0 && \
$composer_executable require -n --dev swoole/ide-helper:^4.5 && \
if_restore_native_runtime && \
echo "$(nhead) 初始化框架脚手架文件 ..." && \

View File

@ -9,14 +9,12 @@ use Symfony\Component\Console\Attribute\AsCommand;
#[AsCommand(name: 'check:config', description: '检查配置文件是否和框架当前版本有更新')]
class CheckConfigCommand extends Command
{
use SourceLoadModeOnly;
private bool $need_update = false;
protected function handle(): int
{
$current_cfg = SOURCE_ROOT_DIR . '/config/';
$remote_cfg = include FRAMEWORK_ROOT_DIR . '/config/global_old.php';
$remote_cfg = include FRAMEWORK_ROOT_DIR . '/config/global.php';
if (file_exists($current_cfg . 'global.php')) {
$this->check($remote_cfg, 'global.php');
}

View File

@ -46,7 +46,7 @@ class Framework
public const VERSION_ID = 682;
/** @var string 版本名称 */
public const VERSION = '3.0.0-beta8';
public const VERSION = '3.0.0';
/** @var array 传入的参数 */
protected array $argv;

View File

@ -20,7 +20,7 @@ class OneBot12FileUploader
* @param BotContext $ctx 机器人上下文,用于调用发送动作
* @param int $buffer_size 分片传输的大小,默认为 65536 字节,建议调整小于 2MB
*/
public function __construct(private BotContext $ctx, private int $buffer_size = 1048576)
public function __construct(private BotContext $ctx, private int $buffer_size = 131072)
{
}
@ -35,8 +35,7 @@ class OneBot12FileUploader
*/
public function uploadFromString(string $filename, string $content): bool|string
{
logger()->info('Uploading file, size: ' . strlen($content));
logger()->info('Uploading file, size: ' . strlen($content) . ', sha256: ' . hash('sha256', $content));
$size = strlen($content);
$offset = 0;
// 文件本身小于分片大小,直接一个包发送
@ -57,6 +56,7 @@ class OneBot12FileUploader
}
return $obj->data['file_id'];
}
logger()->info('分 ' . ceil($size / $this->buffer_size) . ' 个片');
// 其他情况,使用分片的方式发送,依次调用 prepare, transfer, finish
$obj = $this->ctx->sendAction('upload_file_fragmented', [
'stage' => 'prepare',