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

@@ -3,8 +3,8 @@ import { OneBotAction } from '@/onebot/action/OneBotAction';
import { ActionName } from '@/onebot/action/router';
import { MessageUnique } from '@/common/message-unique';
import { RawMessage } from '@/core';
import { AdapterConfigWrap } from '@/onebot/config/config';
import { Static, Type } from '@sinclair/typebox';
import { NetworkAdapterConfig } from '@/onebot/config/config';
export type ReturnDataType = OB11Message
@@ -18,10 +18,8 @@ class GetMsg extends OneBotAction<Payload, OB11Message> {
actionName = ActionName.GetMsg;
payloadSchema = SchemaData;
async _handle(payload: Payload, adapter: string) {
async _handle(payload: Payload, adapter: string, config: NetworkAdapterConfig) {
// log("history msg ids", Object.keys(msgHistory));
const network = Object.values(this.obContext.configLoader.configData.network) as Array<AdapterConfigWrap>;
const msgFormat = network.flat().find(e => e.name === adapter)?.messagePostFormat ?? 'array';
if (!payload.message_id) {
throw Error('参数message_id不能为空');
}
@@ -38,7 +36,7 @@ class GetMsg extends OneBotAction<Payload, OB11Message> {
} else {
msg = (await this.core.apis.MsgApi.getMsgsByMsgId(peer, [msgIdWithPeer?.MsgId || payload.message_id.toString()])).msgList[0];
}
const retMsg = await this.obContext.apis.MsgApi.parseMessage(msg, msgFormat);
const retMsg = await this.obContext.apis.MsgApi.parseMessage(msg, config.messagePostFormat);
if (!retMsg) throw Error('消息为空');
try {
retMsg.message_id = MessageUnique.createUniqueMsgId(peer, msg.msgId)!;