@napuketto/kernel 0.16.3 → 0.16.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -2089,6 +2089,12 @@ export declare class MsgApi {
2089
2089
  emojiType: string;
2090
2090
  like: boolean;
2091
2091
  }): Promise<void>;
2092
+ /** 按原生消息 ID 添加或移除 QQ 系统表情表态。 */
2093
+ setMsgEmojiLikeById(target: Peer, { msgId, emojiId, like }: {
2094
+ msgId: string;
2095
+ emojiId: string;
2096
+ like: boolean;
2097
+ }): Promise<void>;
2092
2098
  /**
2093
2099
  * 语音转文字(fetch_ptt_text)。
2094
2100
  * 流程:按 msgId 拉消息 → 找 PTT 元素 → translatePtt2Text(异步转写)
package/dist/index.mjs CHANGED
@@ -2345,6 +2345,8 @@ const SEND_STATUS = {
2345
2345
  };
2346
2346
  /** 发送确认超时(毫秒)。 */
2347
2347
  const SEND_CONFIRM_TIMEOUT_MS = 15e3;
2348
+ const QQ_EMOJI_ID_PATTERN = /^\d+$/;
2349
+ const MESSAGE_SEQ_PATTERN = /^[1-9]\d*$/;
2348
2350
  /**
2349
2351
  * PIC 元素发送契约值(NapCat 同款发送契约值,未逐字段校准)。
2350
2352
  * 下列固定值均为实测调通的 wrapper 发送契约(picType / picSubType /
@@ -2770,6 +2772,21 @@ var MsgApi = class {
2770
2772
  async setMsgEmojiLike(target, opts) {
2771
2773
  unwrapResult("setMsgEmojiLikes", await this.service.setMsgEmojiLikes(target, opts.msgSeq, opts.emojiId, opts.emojiType, opts.like));
2772
2774
  }
2775
+ /** 按原生消息 ID 添加或移除 QQ 系统表情表态。 */
2776
+ async setMsgEmojiLikeById(target, { msgId, emojiId, like }) {
2777
+ if (typeof msgId !== "string" || msgId.trim() === "") throw kernelError("缺少原生消息 ID", "INVALID_PARAM");
2778
+ if (typeof emojiId !== "string" || !QQ_EMOJI_ID_PATTERN.test(emojiId)) throw kernelError("表情 ID 必须是 QQ 系统表情索引的十进制字符串", "INVALID_PARAM");
2779
+ const message = (await this.fetchMsgsByMsgId(target, [msgId])).find((msg) => msg.msgId === msgId && msg.chatType === target.chatType && msg.peerUid === target.peerUid);
2780
+ if (message === void 0) throw kernelError("会话中找不到指定消息", "NOT_FOUND");
2781
+ const { msgSeq } = message;
2782
+ if (typeof msgSeq !== "string" || !MESSAGE_SEQ_PATTERN.test(msgSeq)) throw kernelError("消息缺少可用的序号", "INVALID_STATE");
2783
+ await this.setMsgEmojiLike(target, {
2784
+ msgSeq,
2785
+ emojiId,
2786
+ emojiType: "1",
2787
+ like
2788
+ });
2789
+ }
2773
2790
  /**
2774
2791
  * 语音转文字(fetch_ptt_text)。
2775
2792
  * 流程:按 msgId 拉消息 → 找 PTT 元素 → translatePtt2Text(异步转写)
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package.json",
3
3
  "name": "@napuketto/kernel",
4
- "version": "0.16.3",
4
+ "version": "0.16.4",
5
5
  "type": "module",
6
6
  "description": "Core runtime kernel of NapukettoQQ",
7
7
  "keywords": [