fix: 进一步重构

This commit is contained in:
手瓜一十雪
2025-01-21 20:40:52 +08:00
parent ef89aac8b9
commit 07a51e8d75
14 changed files with 166 additions and 320 deletions

View File

@@ -1,7 +1,7 @@
import { OneBotAction } from '@/onebot/action/OneBotAction';
import { ActionName } from '@/onebot/action/router';
import { AdapterConfigWrap } from '@/onebot/config/config';
import { NetworkAdapterConfig } from '@/onebot/config/config';
import { Static, Type } from '@sinclair/typebox';
const SchemaData = Type.Object({
@@ -14,16 +14,14 @@ export default class GetRecentContact extends OneBotAction<Payload, any> {
actionName = ActionName.GetRecentContact;
payloadSchema = SchemaData;
async _handle(payload: Payload, adapter: string) {
async _handle(payload: Payload, adapter: string, config: NetworkAdapterConfig) {
const ret = await this.core.apis.UserApi.getRecentContactListSnapShot(+payload.count);
const network = Object.values(this.obContext.configLoader.configData.network) as Array<AdapterConfigWrap>;
//烘焙消息
const msgFormat = network.flat().find(e => e.name === adapter)?.messagePostFormat ?? 'array';
return await Promise.all(ret.info.changedList.map(async (t) => {
const FastMsg = await this.core.apis.MsgApi.getMsgsByMsgId({ chatType: t.chatType, peerUid: t.peerUid }, [t.msgId]);
if (FastMsg.msgList.length > 0) {
//扩展ret.info.changedList
const lastestMsg = await this.obContext.apis.MsgApi.parseMessage(FastMsg.msgList[0], msgFormat);
const lastestMsg = await this.obContext.apis.MsgApi.parseMessage(FastMsg.msgList[0], config.messagePostFormat);
return {
lastestMsg: lastestMsg,
peerUin: t.peerUin,