diff --git a/dist.zip b/dist.zip new file mode 100644 index 00000000..2437f087 Binary files /dev/null and b/dist.zip differ diff --git a/src/core/src/services/NodeIKernelRecentContactService.ts b/src/core/src/services/NodeIKernelRecentContactService.ts index 882f6381..ffe8cc96 100644 --- a/src/core/src/services/NodeIKernelRecentContactService.ts +++ b/src/core/src/services/NodeIKernelRecentContactService.ts @@ -1,4 +1,4 @@ -import { Peer } from "../entities"; +import { ChatType, Peer } from "../entities"; import { NodeIKernelRecentContactListener } from "../listeners/NodeIKernelRecentContactListener"; import { GeneralCallResult } from "./common"; export interface FSABRecentContactParams { @@ -39,7 +39,13 @@ export interface NodeIKernelRecentContactService { errCode: number, errMsg: string, sortedContactList: Array, - changedList: Array + changedList: Array<{ + remark: any; + peerName: any; + sendMemberName: any; + sendNickName: any; + peerUid: string; peerUin: string, msgTime: string, chatType: ChatType, msgId: string + }> } }>; // 1 arguments diff --git a/src/onebot11/action/user/GetRecentContact.ts b/src/onebot11/action/user/GetRecentContact.ts index b6d62647..363c749d 100644 --- a/src/onebot11/action/user/GetRecentContact.ts +++ b/src/onebot11/action/user/GetRecentContact.ts @@ -1,12 +1,52 @@ +import { FromSchema, JSONSchema } from 'json-schema-to-ts'; import BaseAction from '../BaseAction'; import { ActionName } from '../types'; -import { NTQQUserApi } from '@/core'; +import { NTQQMsgApi, NTQQUserApi } from '@/core'; +import { OB11Constructor } from '@/onebot11/constructor'; -export default class GetRecentContact extends BaseAction { +const SchemaData = { + type: 'object', + properties: { + count: { type: ['number', 'string'] } + } +} as const satisfies JSONSchema; + +type Payload = FromSchema; + +export default class GetRecentContact extends BaseAction { actionName = ActionName.GetRecentContact; - protected async _handle(payload: void) { - //没有效果 - return await NTQQUserApi.getRecentContactListSnapShot(10); + PayloadSchema = SchemaData; + protected async _handle(payload: Payload) { + let ret = await NTQQUserApi.getRecentContactListSnapShot(parseInt((payload.count || 10).toString())); + let data = await Promise.all(ret.info.changedList.map(async (t) => { + let FastMsg = await NTQQMsgApi.getMsgsByMsgId({ chatType: t.chatType, peerUid: t.peerUid }, [t.msgId]); + if (FastMsg.msgList.length > 0) { + //扩展ret.info.changedList + let lastestMsg = await OB11Constructor.message(FastMsg.msgList[0]); + return { + lastestMsg: lastestMsg, + peerUin: t.peerUin, + remark: t.remark, + msgTime: t.msgTime, + chatType: t.chatType, + msgId: t.msgId, + sendNickName: t.sendNickName, + sendMemberName: t.sendMemberName, + peerName: t.peerName + }; + } + return { + peerUin: t.peerUin, + remark: t.remark, + msgTime: t.msgTime, + chatType: t.chatType, + msgId: t.msgId, + sendNickName: t.sendNickName, + sendMemberName: t.sendMemberName, + peerName: t.peerName + }; + })); + return data; } }