fix: adapter api

This commit is contained in:
手瓜一十雪
2024-11-14 20:25:08 +08:00
parent d9a67de683
commit a1b199fcde
4 changed files with 17 additions and 8 deletions

View File

@@ -22,8 +22,10 @@ class GetMsg extends BaseAction<Payload, OB11Message> {
actionName = ActionName.GetMsg;
payloadSchema = SchemaData;
async _handle(payload: Payload) {
async _handle(payload: Payload, adapter: string) {
// log("history msg ids", Object.keys(msgHistory));
let network = Object.values(this.obContext.configLoader.configData.network) as Array<typeof this.obContext.configLoader.configData.network[keyof typeof this.obContext.configLoader.configData.network]>;
let msgFormat = network.flat().find(e => e.name === adapter)?.messagePostFormat ?? 'array';
if (!payload.message_id) {
throw Error('参数message_id不能为空');
}
@@ -40,7 +42,7 @@ class GetMsg extends BaseAction<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);
const retMsg = await this.obContext.apis.MsgApi.parseMessage(msg, msgFormat);
if (!retMsg) throw Error('消息为空');
try {
retMsg.message_id = MessageUnique.createUniqueMsgId(peer, msg.msgId)!;