From 7449ce9c3ba68107318117d9ae30deba5d8b205e 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, 16 Apr 2024 18:32:02 +0800 Subject: [PATCH] fix --- .../action/go-cqhttp/GetFriendMsgHistory.ts | 24 ++++++------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/src/onebot11/action/go-cqhttp/GetFriendMsgHistory.ts b/src/onebot11/action/go-cqhttp/GetFriendMsgHistory.ts index cb51ca33..6fae23d3 100644 --- a/src/onebot11/action/go-cqhttp/GetFriendMsgHistory.ts +++ b/src/onebot11/action/go-cqhttp/GetFriendMsgHistory.ts @@ -1,6 +1,6 @@ import BaseAction from '../BaseAction'; import { OB11Message, OB11User } from '../../types'; -import { getFriend, friends, uid2UinMap } from '@/common/data'; +import { getFriend, friends, uid2UinMap, getUidByUin } from '@/common/data'; import { ActionName } from '../types'; import { ChatType } from '@/core/qqnt/entities'; import { dbUtil } from '@/common/utils/db'; @@ -21,26 +21,16 @@ interface Response { export default class GetFriendMsgHistory extends BaseAction { actionName = ActionName.GoCQHTTP_GetGroupMsgHistory; protected async _handle(payload: Payload): Promise { - if (!uid2UinMap?.[payload.user_id]) { + let uin = getUidByUin(payload.user_id.toString()) + if (!uin) { throw `记录${payload.user_id}不存在`; } const startMsgId = (await dbUtil.getMsgByShortId(payload.message_seq))?.msgId || '0'; - // log("startMsgId", startMsgId) - let friend = await getFriend(uid2UinMap?.[payload.user_id].toString()) - let historyResult = undefined; - if (friend) { - historyResult = (await NTQQMsgApi.getMsgHistory({ - chatType: ChatType.friend, - peerUid: uid2UinMap?.[payload.user_id] - }, startMsgId, parseInt(payload.count?.toString()) || 20)); - - } else { - historyResult = (await NTQQMsgApi.getMsgHistory({ - chatType: ChatType.temp, - peerUid: uid2UinMap?.[payload.user_id] - }, startMsgId, parseInt(payload.count?.toString()) || 20)); - } + let historyResult = (await NTQQMsgApi.getMsgHistory({ + chatType: friend ? ChatType.friend : ChatType.temp, + peerUid: uin + }, startMsgId, parseInt(payload.count?.toString()) || 20)); console.log(historyResult); const msgList = historyResult.msgList; await Promise.all(msgList.map(async msg => {