mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2024-11-21 09:36:35 +00:00
refactor: fetch->RequestUtil
This commit is contained in:
parent
e80ed3b33e
commit
e8faa09f1d
@ -4,6 +4,7 @@ import { LogWrapper } from '@/common/log';
|
|||||||
import { QuickAction, QuickActionEvent } from '../types';
|
import { QuickAction, QuickActionEvent } from '../types';
|
||||||
import { NapCatCore } from '@/core';
|
import { NapCatCore } from '@/core';
|
||||||
import { NapCatOneBot11Adapter } from '..';
|
import { NapCatOneBot11Adapter } from '..';
|
||||||
|
import { RequestUtil } from '@/common/request';
|
||||||
|
|
||||||
export class OB11ActiveHttpAdapter implements IOB11NetworkAdapter {
|
export class OB11ActiveHttpAdapter implements IOB11NetworkAdapter {
|
||||||
logger: LogWrapper;
|
logger: LogWrapper;
|
||||||
@ -34,14 +35,10 @@ export class OB11ActiveHttpAdapter implements IOB11NetworkAdapter {
|
|||||||
const sig = hmac.digest('hex');
|
const sig = hmac.digest('hex');
|
||||||
headers['x-signature'] = 'sha1=' + sig;
|
headers['x-signature'] = 'sha1=' + sig;
|
||||||
}
|
}
|
||||||
fetch(this.url, {
|
RequestUtil.HttpGetText(this.url, 'POST', msgStr, headers).then(async (res) => {
|
||||||
method: 'POST',
|
|
||||||
headers,
|
|
||||||
body: msgStr,
|
|
||||||
}).then(async (res) => {
|
|
||||||
let resJson: QuickAction;
|
let resJson: QuickAction;
|
||||||
try {
|
try {
|
||||||
resJson = await res.json();
|
resJson = JSON.parse(res);
|
||||||
//logDebug('新消息事件HTTP上报返回快速操作: ', JSON.stringify(resJson));
|
//logDebug('新消息事件HTTP上报返回快速操作: ', JSON.stringify(resJson));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
this.logger.logDebug('[OneBot] [Http Client] 新消息事件HTTP上报没有返回快速操作,不需要处理');
|
this.logger.logDebug('[OneBot] [Http Client] 新消息事件HTTP上报没有返回快速操作,不需要处理');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user