This commit is contained in:
crazywhalecc
2024-10-02 20:31:16 +08:00
committed by Jerry Ma
parent 2d9f879994
commit ef1a9646e4
72 changed files with 107 additions and 234 deletions

View File

@@ -14,7 +14,7 @@ class CatCode
* @param array|MessageSegment|string $message_segment MessageSegment 对象或数组
* @param bool $encode_text 是否对文本进行 CatCode 编码(默认为否)
*/
public static function fromSegment(string|array|MessageSegment $message_segment, bool $encode_text = false): string
public static function fromSegment(array|MessageSegment|string $message_segment, bool $encode_text = false): string
{
// 传入的必须是段数组或段对象
if (is_array($message_segment)) {
@@ -40,7 +40,7 @@ class CatCode
* @param bool $is_param 如果是转义CatCode本体内容则为false默认如果是参数内的字符串则为true
* @return string 转义后的CatCode
*/
public static function encode(\Stringable|int|string $msg, bool $is_param = false): string
public static function encode(int|string|\Stringable $msg, bool $is_param = false): string
{
$msg = str_replace(['&', '[', ']'], ['&', '[', ']'], (string) $msg);
if ($is_param) {
@@ -56,7 +56,7 @@ class CatCode
* @param bool $is_param 如果是解码CatCode本体内容则为false默认如果是参数内的字符串则为true
* @return string 转义后的CatCode
*/
public static function decode(\Stringable|int|string $msg, bool $is_param = false): string
public static function decode(int|string|\Stringable $msg, bool $is_param = false): string
{
$msg = str_replace(['&', '[', ']'], ['&', '[', ']'], (string) $msg);
if ($is_param) {

View File

@@ -14,9 +14,7 @@ use ZM\Utils\ZMUtil;
*/
class PluginGenerator
{
public function __construct(private string $name, private string $plugin_dir)
{
}
public function __construct(private string $name, private string $plugin_dir) {}
/**
* 开始生成

View File

@@ -61,7 +61,7 @@ class MessageUtil
return $arr;
}
public static function convertToArr(MessageSegment|\Stringable|array|string $message): array
public static function convertToArr(array|MessageSegment|string|\Stringable $message): array
{
if (is_array($message)) {
foreach ($message as $k => $v) {
@@ -99,7 +99,7 @@ class MessageUtil
return $ls;
}
public static function getAltMessage(null|array|string|MessageSegment $message): string
public static function getAltMessage(null|array|MessageSegment|string $message): string
{
if ($message === null) {
return '';

View File

@@ -59,10 +59,10 @@ class OneBot12FileDownloader
$name = $obj->data['name'];
$data = base64_decode($obj->data['data']);
// TODO: Walle-Q 返回的 sha256 是空的
/* if ($obj->data['sha256'] !== hash('sha256', $data)) {
$this->err = 'sha256 mismatch between ' . $obj->data['sha256'] . ' and ' . hash('sha256', $data) . "\n" . json_encode($obj);
return false;
}*/
/* if ($obj->data['sha256'] !== hash('sha256', $data)) {
$this->err = 'sha256 mismatch between ' . $obj->data['sha256'] . ' and ' . hash('sha256', $data) . "\n" . json_encode($obj);
return false;
}*/
} else {
$obj = $this->ctx->sendAction('get_file_fragmented', [
'stage' => 'prepare',

View File

@@ -20,9 +20,7 @@ class OneBot12FileUploader
* @param BotContext $ctx 机器人上下文,用于调用发送动作
* @param int $buffer_size 分片传输的大小,默认为 65536 字节,建议调整小于 2MB
*/
public function __construct(private BotContext $ctx, private int $buffer_size = 131072)
{
}
public function __construct(private BotContext $ctx, private int $buffer_size = 131072) {}
/**
* 通过文件内容上传一个文件

View File

@@ -81,7 +81,7 @@ class ReflectionUtil
* @param callable|string $callback 回调
* @throws \ReflectionException
*/
public static function isNonStaticMethod(callable|array|string $callback): bool
public static function isNonStaticMethod(array|callable|string $callback): bool
{
if (is_array($callback) && is_string($callback[0])) {
$reflection = new \ReflectionMethod($callback[0], $callback[1]);

View File

@@ -22,7 +22,7 @@ class ZMRequest
* @param bool $only_body 是否只返回 Response body 部分,默认为 True
* @return bool|ResponseInterface|string 返回 False 代表请求失败,返回 string 为仅 Body 的内容,返回 Response 接口对象表明是回包
*/
public static function get(string|UriInterface|\Stringable $url, array $headers = [], array $config = [], bool $only_body = true): bool|ResponseInterface|string
public static function get(string|\Stringable|UriInterface $url, array $headers = [], array $config = [], bool $only_body = true): bool|ResponseInterface|string
{
$socket = Framework::getInstance()->getDriver()->createHttpClientSocket(array_merge_recursive([
'url' => ($url instanceof UriInterface ? $url->__toString() : $url),
@@ -51,7 +51,7 @@ class ZMRequest
* @param bool $only_body 是否只返回 Response body 部分,默认为 True
* @return bool|ResponseInterface|string 返回 False 代表请求失败,返回 string 为仅 Body 的内容,返回 Response 接口对象表明是回包
*/
public static function post(string|UriInterface|\Stringable $url, array $header, mixed $data, array $config = [], bool $only_body = true): bool|ResponseInterface|string
public static function post(string|\Stringable|UriInterface $url, array $header, mixed $data, array $config = [], bool $only_body = true): bool|ResponseInterface|string
{
$socket = Framework::getInstance()->getDriver()->createHttpClientSocket(array_merge_recursive([
'url' => ($url instanceof UriInterface ? $url->__toString() : $url),