test(onebot): confirm profile_like decode against real captures

Validated the 0x210/39 ProfileLikeTip field layout byte-exact against three
real captured like pushes (detail.txt='赞了我的资料卡N次', f3=uin, f5=nick).
Drop the pending-validation caveat; test now uses the real txt shape.
This commit is contained in:
DrSmoothl committed 2026-07-07 15:10:06 +08:00
1 parent 447b40a259
commit eda1c32994
3 files changed
+10 -9

No files matched your search

+5 -4
View File
@@ -322,15 +322,16 @@ describe('parseMsgPush Event0x210 subType=39 (profile like → 名片赞)', () =
}
it('emits friend_profile_like with liker uin, nick and parsed count', () => {
// txt shape taken from a real capture: "赞了我的资料卡N次".
const [event] = parseMsgPush(
makeLikePacket({ uin: 1787882683, nick: '東雪蓮', txt: '赞了你3次' }),
makeLikePacket({ uin: 1206069534, nick: '墨白灵MotricLuck', txt: '赞了我的资料卡2次' }),
makeIdentity(),
) as FriendProfileLikeEvent[];
expect(event.kind).toBe('friend_profile_like');
expect(event.operatorUin).toBe(1787882683);
expect(event.operatorNick).toBe('東雪蓮');
expect(event.times).toBe(3);
expect(event.operatorUin).toBe(1206069534);
expect(event.operatorNick).toBe('墨白灵MotricLuck');
expect(event.times).toBe(2);
expect(event.time).toBe(1710001111);
});
+3 -3
View File
@@ -284,9 +284,9 @@ export interface GroupSpecialTitleChange {
// Profile-like ("名片赞") notify — Event 0x210 subType 39, whose body.msgContent
// decodes as this ProfileLikeTip. subType 39 is multiplexed; only inner
// msgType==0 && subType==203 is a like. NOTE: proto shape sourced from NapCat's
// raw-bytes decoder (adaptDecoder.ts) — semantics only; pending a real like
// capture to confirm byte-exactly. times is parsed from `detail.txt`.
// msgType==0 && subType==203 is a like. Field numbers CONFIRMED byte-exact against
// real on-wire captures (detail.txt = "赞了我的资料卡N次", f3=liker uin, f5=nick);
// the like count is parsed from `detail.txt`.
export interface ProfileLikeDetail {
txt?: pb<1, string>;
uin?: pb<3, uint_64>;
@@ -165,8 +165,8 @@ function inputStatusText(eventType: number): string {
// 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.
// `times` is the like count parsed out of `detail.txt` ("赞了我的资料卡N次").
// Field layout confirmed byte-exact against real on-wire captures.
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,