From cad09b2ed1c481ac7a204bca493e7613199edac7 Mon Sep 17 00:00:00 2001 From: idranme Date: Sat, 14 Sep 2024 19:56:46 +0800 Subject: [PATCH] fix --- src/ntqqapi/proto/compiled.d.ts | 66 +++++++++++- src/ntqqapi/proto/compiled.js | 134 +++++++++++++++++++++++-- src/ntqqapi/proto/profileLikeTip.proto | 22 ++-- src/onebot11/adapter.ts | 5 +- 4 files changed, 207 insertions(+), 20 deletions(-) diff --git a/src/ntqqapi/proto/compiled.d.ts b/src/ntqqapi/proto/compiled.d.ts index f2a9951..ee5b5f7 100644 --- a/src/ntqqapi/proto/compiled.d.ts +++ b/src/ntqqapi/proto/compiled.d.ts @@ -363,11 +363,63 @@ export namespace SysMsg { public static getTypeUrl(typeUrlPrefix?: string): string; } + /** Properties of a ProfileLikeSubTip. */ + interface IProfileLikeSubTip { + + /** ProfileLikeSubTip msg */ + msg?: (SysMsg.ILikeMsg|null); + } + + /** Represents a ProfileLikeSubTip. */ + class ProfileLikeSubTip implements IProfileLikeSubTip { + + /** + * Constructs a new ProfileLikeSubTip. + * @param [properties] Properties to set + */ + constructor(properties?: SysMsg.IProfileLikeSubTip); + + /** ProfileLikeSubTip msg. */ + public msg?: (SysMsg.ILikeMsg|null); + + /** + * Decodes a ProfileLikeSubTip message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ProfileLikeSubTip + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): SysMsg.ProfileLikeSubTip; + + /** + * Decodes a ProfileLikeSubTip message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ProfileLikeSubTip + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): SysMsg.ProfileLikeSubTip; + + /** + * Gets the default type url for ProfileLikeSubTip + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + /** Properties of a ProfileLikeTip. */ interface IProfileLikeTip { - /** ProfileLikeTip msg */ - msg?: (SysMsg.ILikeMsg|null); + /** ProfileLikeTip msgType */ + msgType?: (number|null); + + /** ProfileLikeTip subType */ + subType?: (number|null); + + /** ProfileLikeTip content */ + content?: (SysMsg.IProfileLikeSubTip|null); } /** Represents a ProfileLikeTip. */ @@ -379,8 +431,14 @@ export namespace SysMsg { */ constructor(properties?: SysMsg.IProfileLikeTip); - /** ProfileLikeTip msg. */ - public msg?: (SysMsg.ILikeMsg|null); + /** ProfileLikeTip msgType. */ + public msgType: number; + + /** ProfileLikeTip subType. */ + public subType: number; + + /** ProfileLikeTip content. */ + public content?: (SysMsg.IProfileLikeSubTip|null); /** * Decodes a ProfileLikeTip message from the specified reader or buffer. diff --git a/src/ntqqapi/proto/compiled.js b/src/ntqqapi/proto/compiled.js index 13f53e8..6cbe19c 100644 --- a/src/ntqqapi/proto/compiled.js +++ b/src/ntqqapi/proto/compiled.js @@ -789,13 +789,111 @@ export const SysMsg = $root.SysMsg = (() => { return LikeMsg; })(); + SysMsg.ProfileLikeSubTip = (function() { + + /** + * Properties of a ProfileLikeSubTip. + * @memberof SysMsg + * @interface IProfileLikeSubTip + * @property {SysMsg.ILikeMsg|null} [msg] ProfileLikeSubTip msg + */ + + /** + * Constructs a new ProfileLikeSubTip. + * @memberof SysMsg + * @classdesc Represents a ProfileLikeSubTip. + * @implements IProfileLikeSubTip + * @constructor + * @param {SysMsg.IProfileLikeSubTip=} [properties] Properties to set + */ + function ProfileLikeSubTip(properties) { + if (properties) + for (let keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ProfileLikeSubTip msg. + * @member {SysMsg.ILikeMsg|null|undefined} msg + * @memberof SysMsg.ProfileLikeSubTip + * @instance + */ + ProfileLikeSubTip.prototype.msg = null; + + /** + * Decodes a ProfileLikeSubTip message from the specified reader or buffer. + * @function decode + * @memberof SysMsg.ProfileLikeSubTip + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {SysMsg.ProfileLikeSubTip} ProfileLikeSubTip + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ProfileLikeSubTip.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + let end = length === undefined ? reader.len : reader.pos + length, message = new $root.SysMsg.ProfileLikeSubTip(); + while (reader.pos < end) { + let tag = reader.uint32(); + switch (tag >>> 3) { + case 14: { + message.msg = $root.SysMsg.LikeMsg.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ProfileLikeSubTip message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof SysMsg.ProfileLikeSubTip + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {SysMsg.ProfileLikeSubTip} ProfileLikeSubTip + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ProfileLikeSubTip.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Gets the default type url for ProfileLikeSubTip + * @function getTypeUrl + * @memberof SysMsg.ProfileLikeSubTip + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ProfileLikeSubTip.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/SysMsg.ProfileLikeSubTip"; + }; + + return ProfileLikeSubTip; + })(); + SysMsg.ProfileLikeTip = (function() { /** * Properties of a ProfileLikeTip. * @memberof SysMsg * @interface IProfileLikeTip - * @property {SysMsg.ILikeMsg|null} [msg] ProfileLikeTip msg + * @property {number|null} [msgType] ProfileLikeTip msgType + * @property {number|null} [subType] ProfileLikeTip subType + * @property {SysMsg.IProfileLikeSubTip|null} [content] ProfileLikeTip content */ /** @@ -814,12 +912,28 @@ export const SysMsg = $root.SysMsg = (() => { } /** - * ProfileLikeTip msg. - * @member {SysMsg.ILikeMsg|null|undefined} msg + * ProfileLikeTip msgType. + * @member {number} msgType * @memberof SysMsg.ProfileLikeTip * @instance */ - ProfileLikeTip.prototype.msg = null; + ProfileLikeTip.prototype.msgType = 0; + + /** + * ProfileLikeTip subType. + * @member {number} subType + * @memberof SysMsg.ProfileLikeTip + * @instance + */ + ProfileLikeTip.prototype.subType = 0; + + /** + * ProfileLikeTip content. + * @member {SysMsg.IProfileLikeSubTip|null|undefined} content + * @memberof SysMsg.ProfileLikeTip + * @instance + */ + ProfileLikeTip.prototype.content = null; /** * Decodes a ProfileLikeTip message from the specified reader or buffer. @@ -839,8 +953,16 @@ export const SysMsg = $root.SysMsg = (() => { while (reader.pos < end) { let tag = reader.uint32(); switch (tag >>> 3) { - case 14: { - message.msg = $root.SysMsg.LikeMsg.decode(reader, reader.uint32()); + case 1: { + message.msgType = reader.uint32(); + break; + } + case 2: { + message.subType = reader.uint32(); + break; + } + case 203: { + message.content = $root.SysMsg.ProfileLikeSubTip.decode(reader, reader.uint32()); break; } default: diff --git a/src/ntqqapi/proto/profileLikeTip.proto b/src/ntqqapi/proto/profileLikeTip.proto index 7043c30..b478f6c 100644 --- a/src/ntqqapi/proto/profileLikeTip.proto +++ b/src/ntqqapi/proto/profileLikeTip.proto @@ -2,17 +2,23 @@ syntax = "proto3"; package SysMsg; message LikeDetail { - string txt = 1; - uint32 uin = 3; - string nickname = 5; + string txt = 1; + uint32 uin = 3; + string nickname = 5; } message LikeMsg { - uint32 count = 1; - uint32 time = 2; - LikeDetail detail = 3; + uint32 count = 1; + uint32 time = 2; + LikeDetail detail = 3; +} + +message ProfileLikeSubTip { + LikeMsg msg = 14; } message ProfileLikeTip { - LikeMsg msg = 14; -} \ No newline at end of file + uint32 msgType = 1; + uint32 subType = 2; + ProfileLikeSubTip content = 203; +} diff --git a/src/onebot11/adapter.ts b/src/onebot11/adapter.ts index d95ed0d..396a779 100644 --- a/src/onebot11/adapter.ts +++ b/src/onebot11/adapter.ts @@ -419,8 +419,9 @@ class OneBot11Adapter extends Service { const sysMsg = SysMsg.SystemMessage.decode(input) const { msgType, subType, subSubType } = sysMsg.msgSpec[0] ?? {} if (msgType === 528 && subType === 39 && subSubType === 39) { - const tip = SysMsg.ProfileLikeTip.decode(sysMsg.bodyWrapper!.body!.slice(12)) - const detail = tip.msg?.detail + const tip = SysMsg.ProfileLikeTip.decode(sysMsg.bodyWrapper!.body!) + if (tip.msgType !== 0 || tip.subType !== 203) return + const detail = tip.content?.msg?.detail if (!detail) return const [times] = detail.txt?.match(/\d+/) ?? ['0'] const profileLikeEvent = new OB11ProfileLikeEvent(detail.uin!, detail.nickname!, +times)