feat(onebot): expose bidirectional message history

Add reverse_order to group and private history actions, preserve latest-page behavior without an anchor, and keep local fallback results chronologically ordered.

Key self-sent private messages and reply targets by the conversation peer, reject cross-conversation anchors, and include request context when a server fetch falls back to local history.

Refs #229
This commit is contained in:
DrSmoothl committed 2026-07-17 17:45:30 +08:00
1 parent afa4ccc5e0
commit fadc7ce316
17 files changed
+468 -70

No files matched your search

+4 -4
View File
@@ -61,7 +61,7 @@ export function registerEventPipeline(ctx: OneBotInstanceContext): EventPipeline
);
disposers.push(
ctx.bridge.events.on('friend_message', (event) => track(event.kind, async () => {
cachePrivateMessageMeta(ctx, event.senderUin, event.msgSeq, event.time, event.msgId);
cachePrivateMessageMeta(ctx, event.peerUin ?? event.senderUin, event.msgSeq, event.time, event.msgId);
await convertAndDispatch(ctx, log, event);
})),
);
@@ -199,15 +199,15 @@ function cacheGroupMessageMeta(ctx: OneBotInstanceContext, event: Extract<QQEven
function cachePrivateMessageMeta(
ctx: OneBotInstanceContext,
senderUin: number,
sessionId: number,
msgSeq: number,
timestamp: number,
random: number,
): void {
const messageId = hashMessageIdInt32(msgSeq, senderUin, PRIVATE_MESSAGE_EVENT);
const messageId = hashMessageIdInt32(msgSeq, sessionId, PRIVATE_MESSAGE_EVENT);
ctx.cacheMessageMeta(messageId, {
isGroup: false,
targetId: senderUin,
targetId: sessionId,
sequence: msgSeq,
eventName: PRIVATE_MESSAGE_EVENT,
clientSequence: 0,