From c2278e3536fd0e73cbdf1544c3b54ab608407a9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=89=8B=E7=93=9C=E4=B8=80=E5=8D=81=E9=9B=AA?= Date: Tue, 14 May 2024 16:40:23 +0800 Subject: [PATCH] build: v1.3.5-beta10 --- src/common/utils/request.ts | 17 +++++++++++------ src/core | 2 +- .../action/go-cqhttp/GetGroupHonorInfo.ts | 7 +++++-- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/src/common/utils/request.ts b/src/common/utils/request.ts index bdc2bee6..b53722ad 100644 --- a/src/common/utils/request.ts +++ b/src/common/utils/request.ts @@ -30,15 +30,15 @@ export class RequestUtil { } // 请求和回复都是JSON data传原始内容 自动编码json - static async HttpGetJson(url: string, method: string = 'GET', data?: any, headers: Record = {}): Promise { + static async HttpGetJson(url: string, method: string = 'GET', data?: any, headers: Record = {}, isJsonRet: boolean = true): Promise { let option = new URL(url); const protocol = url.startsWith('https://') ? https : http; const options = { hostname: option.hostname, port: option.port, path: option.href, - method, - headers, + method: method, + headers: headers }; return new Promise((resolve, reject) => { const req = protocol.request(options, (res: any) => { @@ -50,8 +50,12 @@ export class RequestUtil { res.on('end', () => { try { if (res.statusCode && res.statusCode >= 200 && res.statusCode < 300) { - const responseJson = JSON.parse(responseBody); - resolve(responseJson as T); + if (isJsonRet) { + const responseJson = JSON.parse(responseBody); + resolve(responseJson as T); + } else { + resolve(responseBody as T); + } } else { reject(new Error(`Unexpected status code: ${res.statusCode}`)); } @@ -73,6 +77,7 @@ export class RequestUtil { // 请求返回都是原始内容 static async HttpGetText(url: string, method: string = 'GET', data?: any, headers: Record = {}) { - return this.HttpGetJson(url, method, data, headers); + //console.log(url); + return this.HttpGetJson(url, method, data, headers, false); } } \ No newline at end of file diff --git a/src/core b/src/core index c30a351b..b1351835 160000 --- a/src/core +++ b/src/core @@ -1 +1 @@ -Subproject commit c30a351bbb9046c31b471e9a818d7b28f971541a +Subproject commit b1351835673f86d445d244fd515560bfcd0b7adb diff --git a/src/onebot11/action/go-cqhttp/GetGroupHonorInfo.ts b/src/onebot11/action/go-cqhttp/GetGroupHonorInfo.ts index 25b65e7d..ba1a2711 100644 --- a/src/onebot11/action/go-cqhttp/GetGroupHonorInfo.ts +++ b/src/onebot11/action/go-cqhttp/GetGroupHonorInfo.ts @@ -5,13 +5,16 @@ import BaseAction from '../BaseAction'; import { ActionName } from '../types'; import { NTQQUserApi, WebApi } from '@/core/apis'; interface Payload { - groud_id: string + group_id: number } export class GetGroupHonorInfo extends BaseAction> { actionName = ActionName.GetGroupHonorInfo; protected async _handle(payload: Payload) { // console.log(await NTQQUserApi.getRobotUinRange()); - return await WebApi.getGroupHonorInfo(payload.groud_id); + if(!payload.group_id){ + throw '缺少参数group_id'; + } + return await WebApi.getGroupHonorInfo(payload.group_id.toString()); } }