fix: 点赞通知解析失败

This commit is contained in:
Alen 2024-09-14 00:42:10 +08:00
parent be40bbdf40
commit 0418b926fe
2 changed files with 18 additions and 5 deletions

View File

@ -14,9 +14,15 @@ export interface LikeMsgType {
detail: LikeDetailType; detail: LikeDetailType;
} }
export interface ProfileLikeTipType { export interface profileLikeSubTipType {
msg: LikeMsgType; msg: LikeMsgType;
} }
export interface ProfileLikeTipType {
msgType: number;
subType: number;
content: profileLikeSubTipType;
}
export interface SysMessageHeaderType { export interface SysMessageHeaderType {
id: string; id: string;
timestamp: number; timestamp: number;
@ -78,6 +84,12 @@ export const likeMsg = new pb.Type("likeMsg")
.add(new pb.Field("time", 2, "int32")) .add(new pb.Field("time", 2, "int32"))
.add(new pb.Field("detail", 3, "likeDetail")); .add(new pb.Field("detail", 3, "likeDetail"));
export const profileLikeTip = new pb.Type("profileLikeTip") export const profileLikeSubTip = new pb.Type("profileLikeSubTip")
.add(likeMsg) .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"));

View File

@ -13,9 +13,10 @@ export class OneBotUserApi {
this.core = core; this.core = core;
} }
async parseLikeEvent(wrappedBody: Uint8Array): Promise<OB11ProfileLikeEvent | undefined> { async parseLikeEvent(wrappedBody: Uint8Array): Promise<OB11ProfileLikeEvent | undefined> {
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("收到点赞通知消息"); this.core.context.logger.logDebug("收到点赞通知消息");
const likeMsg = likeTip.msg; const likeMsg = likeTip.content.msg;
if (!likeMsg) return; if (!likeMsg) return;
const detail = likeMsg.detail; const detail = likeMsg.detail;
if (!detail) return; if (!detail) return;