feat(onebot): reply into group temp sessions (临时会话) (#212)

send_private_msg / send_msg can now reply to a group temp-session message
by passing the source group_id. Inbound temp messages surface their
source group on sender.group_id; a reply is only made into a temp session
the bot has an inbound record of. Group temp replies route through
RoutingHead.grpTmp (field 3).
This commit is contained in:
DrSmoothl committed 2026-07-10 02:29:18 +08:00
1 parent b37b17f7d8
commit 3c73d1d5b0
19 files changed
+311 -15

No files matched your search

@@ -34,6 +34,18 @@ async function convertPrivateMessage(
ctx.messageIdResolver, false, event.senderUin, event.msgSeq, PRIVATE_MESSAGE_EVENT,
);
const segments = await toSegments(ctx, event.elements, false, event.senderUin);
const sender: JsonObject = {
user_id: event.senderUin,
nickname: event.senderNick,
sex: 'unknown',
age: 0,
};
// A temp (group-originated) message carries its source group so a client can
// reply via send_private_msg(user_id, group_id=sender.group_id). Mirrors
// go-cqhttp / NapCat, which expose it on sender.group_id.
if (subType === 'group' && 'groupId' in event && event.groupId > 0) {
sender.group_id = event.groupId;
}
return message(ctx, event, postType, {
message_type: 'private',
sub_type: subType,
@@ -43,12 +55,7 @@ async function convertPrivateMessage(
message: segments,
raw_message: segmentsToRawMessage(segments),
font: 0,
sender: {
user_id: event.senderUin,
nickname: event.senderNick,
sex: 'unknown',
age: 0,
},
sender,
});
}