From e8faa09f1d0151c618b5c83e75994876b73ecc04 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: Sat, 16 Nov 2024 13:58:46 +0800 Subject: [PATCH] refactor: fetch->RequestUtil --- src/onebot/network/active-http.ts | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/onebot/network/active-http.ts b/src/onebot/network/active-http.ts index 16cec876..356f6e21 100644 --- a/src/onebot/network/active-http.ts +++ b/src/onebot/network/active-http.ts @@ -4,6 +4,7 @@ import { LogWrapper } from '@/common/log'; import { QuickAction, QuickActionEvent } from '../types'; import { NapCatCore } from '@/core'; import { NapCatOneBot11Adapter } from '..'; +import { RequestUtil } from '@/common/request'; export class OB11ActiveHttpAdapter implements IOB11NetworkAdapter { logger: LogWrapper; @@ -34,14 +35,10 @@ export class OB11ActiveHttpAdapter implements IOB11NetworkAdapter { const sig = hmac.digest('hex'); headers['x-signature'] = 'sha1=' + sig; } - fetch(this.url, { - method: 'POST', - headers, - body: msgStr, - }).then(async (res) => { + RequestUtil.HttpGetText(this.url, 'POST', msgStr, headers).then(async (res) => { let resJson: QuickAction; try { - resJson = await res.json(); + resJson = JSON.parse(res); //logDebug('新消息事件HTTP上报返回快速操作: ', JSON.stringify(resJson)); } catch (e) { this.logger.logDebug('[OneBot] [Http Client] 新消息事件HTTP上报没有返回快速操作,不需要处理');