From 0418b926febeb9af9a314e5e154e8a80bd798b22 Mon Sep 17 00:00:00 2001 From: Alen Date: Sat, 14 Sep 2024 00:42:10 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E7=82=B9=E8=B5=9E=E9=80=9A=E7=9F=A5?= =?UTF-8?q?=E8=A7=A3=E6=9E=90=E5=A4=B1=E8=B4=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/core/proto/ProfileLike.ts | 18 +++++++++++++++--- src/onebot/api/user.ts | 5 +++-- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/core/proto/ProfileLike.ts b/src/core/proto/ProfileLike.ts index dd12844c..ba9aadcc 100644 --- a/src/core/proto/ProfileLike.ts +++ b/src/core/proto/ProfileLike.ts @@ -14,9 +14,15 @@ export interface LikeMsgType { detail: LikeDetailType; } -export interface ProfileLikeTipType { +export interface profileLikeSubTipType { msg: LikeMsgType; } + +export interface ProfileLikeTipType { + msgType: number; + subType: number; + content: profileLikeSubTipType; +} export interface SysMessageHeaderType { id: string; timestamp: number; @@ -78,6 +84,12 @@ export const likeMsg = new pb.Type("likeMsg") .add(new pb.Field("time", 2, "int32")) .add(new pb.Field("detail", 3, "likeDetail")); -export const profileLikeTip = new pb.Type("profileLikeTip") +export const profileLikeSubTip = new pb.Type("profileLikeSubTip") .add(likeMsg) - .add(new pb.Field("msg", 14, "likeMsg")); + .add(new pb.Field("msg", 14, "likeMsg")) + +export const profileLikeTip = new pb.Type("profileLikeTip") + .add(profileLikeSubTip) + .add(new pb.Field("msgType", 1, "int32")) + .add(new pb.Field("subType", 2, "int32")) + .add(new pb.Field("content", 203, "profileLikeSubTip")); diff --git a/src/onebot/api/user.ts b/src/onebot/api/user.ts index 14385b1c..a84fcaa5 100644 --- a/src/onebot/api/user.ts +++ b/src/onebot/api/user.ts @@ -13,9 +13,10 @@ export class OneBotUserApi { this.core = core; } async parseLikeEvent(wrappedBody: Uint8Array): Promise { - const likeTip = profileLikeTip.decode(Uint8Array.from(wrappedBody.slice(12))) as unknown as ProfileLikeTipType; + const likeTip = profileLikeTip.decode(Uint8Array.from(wrappedBody)) as unknown as ProfileLikeTipType; + if (likeTip?.msgType !== 0 || likeTip?.subType !== 203) return; this.core.context.logger.logDebug("收到点赞通知消息"); - const likeMsg = likeTip.msg; + const likeMsg = likeTip.content.msg; if (!likeMsg) return; const detail = likeMsg.detail; if (!detail) return;