diff --git a/packages/napcat-onebot/api/msg.ts b/packages/napcat-onebot/api/msg.ts index 94f948aa..6f267d42 100644 --- a/packages/napcat-onebot/api/msg.ts +++ b/packages/napcat-onebot/api/msg.ts @@ -587,15 +587,33 @@ export class OneBotMsgApi { return at(atQQ, uid, NTMsgAtType.ATTYPEONE, info.nick || ''); }, - [OB11MessageDataType.reply]: async ({ data: { id } }) => { - const replyMsgM = MessageUnique.getMsgIdAndPeerByShortId(parseInt(id)); - if (!replyMsgM) { - this.core.context.logger.logWarn('回复消息不存在', id); + [OB11MessageDataType.reply]: async ({ data: { id, seq } }, context) => { + let replyMsg: RawMessage | undefined; + let replyMsgPeer: Peer | undefined; + + // 优先使用 seq + if (seq) { + const msgList = (await this.core.apis.MsgApi.getMsgsBySeqAndCount( + context.peer, seq.toString(), 1, true, true + )).msgList; + replyMsg = msgList[0]; + replyMsgPeer = context.peer; + } else if (id) { + // 降级使用 id + const replyMsgM = MessageUnique.getMsgIdAndPeerByShortId(parseInt(id)); + if (!replyMsgM) { + this.core.context.logger.logWarn('回复消息不存在', id); + return undefined; + } + replyMsg = (await this.core.apis.MsgApi.getMsgsByMsgId( + replyMsgM.Peer, [replyMsgM.MsgId])).msgList[0]; + replyMsgPeer = replyMsgM.Peer; + } else { + this.core.context.logger.logWarn('回复消息缺少id或seq参数'); return undefined; } - const replyMsg = (await this.core.apis.MsgApi.getMsgsByMsgId( - replyMsgM.Peer, [replyMsgM.MsgId])).msgList[0]; - return replyMsg + + return replyMsg && replyMsgPeer ? { elementType: ElementType.REPLY, elementId: '', @@ -605,7 +623,7 @@ export class OneBotMsgApi { senderUin: replyMsg.senderUin, senderUinStr: replyMsg.senderUin, replyMsgClientSeq: replyMsg.clientSeq, - _replyMsgPeer: replyMsgM.Peer, + _replyMsgPeer: replyMsgPeer, }, } : undefined; diff --git a/packages/napcat-onebot/types/message.ts b/packages/napcat-onebot/types/message.ts index 313f0ac5..6b8707de 100644 --- a/packages/napcat-onebot/types/message.ts +++ b/packages/napcat-onebot/types/message.ts @@ -159,7 +159,8 @@ export interface OB11MessageAt { export interface OB11MessageReply { type: OB11MessageDataType.reply; data: { - id: string; + id?: string; // msg_id 的短ID映射 + seq?: number; // msg_seq,优先使用 }; } diff --git a/packages/napcat-webui-frontend/src/components/display_card/common_card.tsx b/packages/napcat-webui-frontend/src/components/display_card/common_card.tsx index a4cfa857..30417ad4 100644 --- a/packages/napcat-webui-frontend/src/components/display_card/common_card.tsx +++ b/packages/napcat-webui-frontend/src/components/display_card/common_card.tsx @@ -93,7 +93,7 @@ const NetworkDisplayCard = ({ onPress={handleEnableDebug} isDisabled={editing} > - {debug ? '关闭调试' : '开启调试'} + {debug ? '默认' : '调试'}