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

@@ -25,6 +25,8 @@ function parseGroupInviteCard(jsonText: string): { groupUin: number; sequence: n
export const decodeFriendMessage: MsgPushDecoder = (ctx) => {
const elements = decodeRichBody(ctx.body, false);
const sentBySelf = ctx.fromUin > 0 && ctx.fromUin === ctx.selfUin;
const peerUin = sentBySelf ? (ctx.responseHead?.toUin ?? 0) : ctx.fromUin;
// Stash the approval msgseq from a private group-invite card so a later
// `set_group_add_request` can approve a bot self-invite (issue #125).
for (const el of elements) {
@@ -39,6 +41,7 @@ export const decodeFriendMessage: MsgPushDecoder = (ctx) => {
selfUin: ctx.selfUin,
senderUin: ctx.fromUin,
senderUid: ctx.fromUid,
...(peerUin > 0 ? { peerUin } : {}),
msgSeq: ctx.head.sequence,
msgId: ctx.head.msgId & 0x7FFFFFFF,
elements,