From 938fb30359331747a29627e7134a3e28ab3cd5fb 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, 27 Apr 2024 20:49:00 +0800 Subject: [PATCH] fix --- src/common/utils/request.ts | 17 +++++++++++++++++ src/common/utils/umami.ts | 4 ++-- src/onebot11/action/user/GetCookies.ts | 2 ++ src/onebot11/action/user/SendLike.ts | 6 +++--- 4 files changed, 24 insertions(+), 5 deletions(-) create mode 100644 src/common/utils/request.ts diff --git a/src/common/utils/request.ts b/src/common/utils/request.ts new file mode 100644 index 000000000..9c875ae32 --- /dev/null +++ b/src/common/utils/request.ts @@ -0,0 +1,17 @@ +const https = require('node:https'); +export async function HttpGetWithCookies(url: string) { + const req = https.get(url, (res: any) => { + res.on('data', (data: any) => { + }); + res.on('end', () => { + const responseCookies = res.headers['set-cookie']; + console.log('获取到的 cookies:', responseCookies); + console.log(res.headers) + }); + }); + + req.on('error', (error: any) => { + // console.log(error) + }) + req.end() +} \ No newline at end of file diff --git a/src/common/utils/umami.ts b/src/common/utils/umami.ts index 5106a7faa..15b37c4f3 100644 --- a/src/common/utils/umami.ts +++ b/src/common/utils/umami.ts @@ -1,4 +1,4 @@ -import { request } from 'https'; +import { request } from 'node:https'; export function postLoginStatus() { const req = request( { @@ -34,7 +34,7 @@ export function postLoginStatus() { 'screen': '1920x1080', 'language': 'zh-CN', 'title': 'OneBot.Login', - 'url': '/login/onebot11', + 'url': '/login/onebot11/1.2.0', 'referrer': 'https://napcat.demo.cn/login?type=onebot11' } }; diff --git a/src/onebot11/action/user/GetCookies.ts b/src/onebot11/action/user/GetCookies.ts index 0eddc8019..fe746a44f 100644 --- a/src/onebot11/action/user/GetCookies.ts +++ b/src/onebot11/action/user/GetCookies.ts @@ -3,12 +3,14 @@ import { OB11Constructor } from '../../constructor'; import { friends } from '../../../common/data'; import BaseAction from '../BaseAction'; import { ActionName } from '../types'; +import { NTQQUserApi } from '@/core/apis'; export class GetCookies extends BaseAction { actionName = ActionName.GetCookies; protected async _handle(payload: null) { + NTQQUserApi.getSkey(); // 取Skey // 先NodeIKernelTicketService.forceFetchClientKey('') // 返回值 diff --git a/src/onebot11/action/user/SendLike.ts b/src/onebot11/action/user/SendLike.ts index f623a7b9e..3fbe3173d 100644 --- a/src/onebot11/action/user/SendLike.ts +++ b/src/onebot11/action/user/SendLike.ts @@ -1,8 +1,8 @@ -import { NTQQUserApi } from '../../../core/src/apis'; +import { NTQQUserApi } from '@/core/apis'; import BaseAction from '../BaseAction'; -import { getFriend, getUidByUin, uid2UinMap } from '../../../common/data'; +import { getFriend, getUidByUin, uid2UinMap } from '@/common/data'; import { ActionName } from '../types'; -import { log, logDebug } from '../../../common/utils/log'; +import { log, logDebug } from '@/common/utils/log'; interface Payload { user_id: number,