feat(onebot): report profile like as notify/profile_like

Decode the multiplexed 0x210 subType-39 push: when body.msgContent is a
ProfileLikeTip with inner msgType==0/subType==203, emit notify/profile_like
{operator_id, operator_nick, times}. times is parsed from detail.txt.
Proto shape from NapCat's raw decoder; wiring + decode verified, but the
byte-exact wire is pending a real like capture to confirm.
This commit is contained in:
DrSmoothl committed 2026-07-07 03:05:14 +08:00
1 parent 0d4d58605f
commit 447b40a259
8 files changed
+135 -1

No files matched your search

@@ -12,6 +12,7 @@ import type {
GeneralGrayTipInfo,
InputStatusNotify,
NewFriend,
ProfileLikeTip,
} from '@snowluma/proto-defs/notify';
import type { PttTransPush } from '@snowluma/proto-defs/ptt-trans';
import type { MsgPushContext } from '../context';
@@ -25,6 +26,7 @@ import type { MsgPushDecoder } from '../registry';
type FriendRecallEvent = Extract<QQEventVariant, { kind: 'friend_recall' }>;
type FriendInputStatusEvent = Extract<QQEventVariant, { kind: 'friend_input_status' }>;
type FriendProfileLikeEvent = Extract<QQEventVariant, { kind: 'friend_profile_like' }>;
const unknownLog = createLogger('MsgPush.Unknown');
@@ -40,6 +42,7 @@ export const decodeEvent0x210: MsgPushDecoder = (ctx) => {
return decodeFriendRecall(ctx);
case Event0x210SubType.FriendPokeNotice: return decodeFriendPoke(ctx);
case Event0x210SubType.InputStatusNotice: return decodeInputStatus(ctx);
case Event0x210SubType.ProfileLikeNotice: return decodeProfileLike(ctx);
// 179 + 226 both carry the NewFriend payload — see enum comment.
case Event0x210SubType.NewFriendNotice:
case Event0x210SubType.NewFriendNoticeAlt:
@@ -159,6 +162,32 @@ function inputStatusText(eventType: number): string {
return eventType === 3 ? '对方正在讲话...' : '对方正在输入...';
}
// subType 39 is multiplexed; body.msgContent decodes as ProfileLikeTip and is a
// profile-like ("名片赞") only when inner msgType==0 && subType==203. Other 39
// variants (multi-device sync etc.) decode to a non-matching tip → dropped.
// `times` is the like count parsed out of `detail.txt`. Proto shape from NapCat's
// raw-bytes decoder — pending a real like capture to validate byte-exactly.
function decodeProfileLike(ctx: MsgPushContext): QQEventVariant[] {
const tip = protobuf_decode<ProfileLikeTip>(ctx.content);
// msgType 0 is the proto default → omitted on the wire → decodes as undefined,
// so treat missing as 0 (matches NapCat's `msgType !== 0` check).
if (!tip || (tip.msgType ?? 0) !== 0 || (tip.subType ?? 0) !== 203) return [];
const msg = tip.content?.msg;
const detail = msg?.detail;
const operatorUin = Number(detail?.uin ?? 0n);
if (!operatorUin) return [];
const times = Number.parseInt((detail?.txt ?? '').match(/\d+/)?.[0] ?? '0', 10) || 0;
const ev: FriendProfileLikeEvent = {
kind: 'friend_profile_like',
time: msg?.time || ctx.head.timestamp,
selfUin: ctx.selfUin,
operatorUin,
operatorNick: detail?.nickname ?? '',
times,
};
return [ev];
}
function decodeFriendPoke(ctx: MsgPushContext): QQEventVariant[] {
const grayTip = protobuf_decode<GeneralGrayTipInfo>(ctx.content);
if (!grayTip || (grayTip.busiType ?? 0n) !== 12n) return [];
+8
View File
@@ -67,6 +67,14 @@ export enum Event0x210SubType {
*/
NewFriendNotice = 179,
NewFriendNoticeAlt = 226,
/**
* Multiplexed subType (Lagrange calls it FriendDeleteOrPinChanged=39). One of
* its variants is the profile-like ("名片赞") push: body.msgContent decodes as
* `ProfileLikeTip` and is a like only when inner msgType==0 && subType==203.
* NapCat routes 528/39 → parseLikeEvent (`api/msg.ts:1547`); other 39 variants
* (multi-device sync etc.) fall through.
*/
ProfileLikeNotice = 39,
/**
* C2C input-status notify — the "对方正在输入…" push. subMsgType 0x115 (277).
* RE-confirmed against `wrapper.linux.node`