mioki 0.15.0 → 0.16.0

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.cts CHANGED
@@ -657,6 +657,7 @@ declare class Deduplicator {
657
657
  */
658
658
  private getEventTypeKey;
659
659
  private getGroupMessageKey;
660
+ private getPrivateMessageKey;
660
661
  private getNoticeGroupKey;
661
662
  private getRequestKey;
662
663
  /**
@@ -689,12 +690,21 @@ declare const deduplicator: Deduplicator;
689
690
  * Mioki 上下文对象,包含 Mioki 运行时的信息和方法
690
691
  */
691
692
  interface MiokiContext extends Services, Configs, Utils, RemoveBotParam<Actions> {
692
- /** 当前处理事件的机器人实例 */
693
+ /**
694
+ * 单实例模式下:机器人实例
695
+ * 多实例模式下:第一个机器人实例
696
+ *
697
+ * 如果要获取指定机器人实例,请使用 ctx.getBot(id) 方法,id 通常可以从 event.self_id 获取
698
+ */
693
699
  bot: NapCat;
694
- /** 所有已连接的机器人实例列表 */
695
- bots: ExtendedNapCat[];
696
700
  /** 当前机器人 QQ 号 */
697
701
  self_id: number;
702
+ /** 多实例模式下:所有已连接的机器人实例列表 */
703
+ bots: ExtendedNapCat[];
704
+ /** 多实例模式下:通过 QQ 号获取机器人实例 */
705
+ pickBot: (id: number) => ExtendedNapCat;
706
+ /** 多实例模式下:需要手动传入 bot 实例的操作方法集合*/
707
+ actions: Actions;
698
708
  /** 消息构造器 */
699
709
  segment: NapCat['segment'];
700
710
  /** 通过域名获取 Cookies */
package/dist/index.d.mts CHANGED
@@ -655,6 +655,7 @@ declare class Deduplicator {
655
655
  */
656
656
  private getEventTypeKey;
657
657
  private getGroupMessageKey;
658
+ private getPrivateMessageKey;
658
659
  private getNoticeGroupKey;
659
660
  private getRequestKey;
660
661
  /**
@@ -687,12 +688,21 @@ declare const deduplicator: Deduplicator;
687
688
  * Mioki 上下文对象,包含 Mioki 运行时的信息和方法
688
689
  */
689
690
  interface MiokiContext extends Services, Configs, Utils, RemoveBotParam<Actions> {
690
- /** 当前处理事件的机器人实例 */
691
+ /**
692
+ * 单实例模式下:机器人实例
693
+ * 多实例模式下:第一个机器人实例
694
+ *
695
+ * 如果要获取指定机器人实例,请使用 ctx.getBot(id) 方法,id 通常可以从 event.self_id 获取
696
+ */
691
697
  bot: NapCat;
692
- /** 所有已连接的机器人实例列表 */
693
- bots: ExtendedNapCat[];
694
698
  /** 当前机器人 QQ 号 */
695
699
  self_id: number;
700
+ /** 多实例模式下:所有已连接的机器人实例列表 */
701
+ bots: ExtendedNapCat[];
702
+ /** 多实例模式下:通过 QQ 号获取机器人实例 */
703
+ pickBot: (id: number) => ExtendedNapCat;
704
+ /** 多实例模式下:需要手动传入 bot 实例的操作方法集合*/
705
+ actions: Actions;
696
706
  /** 消息构造器 */
697
707
  segment: NapCat['segment'];
698
708
  /** 通过域名获取 Cookies */
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { t as __exportAll } from "./chunk-BiucMVzj.mjs";
2
- import { t as version } from "./package-B4h-fhCq.mjs";
2
+ import { t as version } from "./package-UYRX612w.mjs";
3
3
  import fs, { default as fs$1 } from "node:fs";
4
4
  import util from "node:util";
5
5
  import path, { default as path$1 } from "node:path";
@@ -1242,6 +1242,13 @@ var Deduplicator = class {
1242
1242
  const raw = e.raw_message ?? "_";
1243
1243
  return `msg:group:${groupId}:${userId}:${time}:${crypto.createHash("md5").update(raw).digest("hex")}`;
1244
1244
  }
1245
+ getPrivateMessageKey(e) {
1246
+ const userId = e.user_id ?? "_";
1247
+ const targetId = e.target_id ?? "_";
1248
+ const time = e.time ?? "_";
1249
+ const raw = e.raw_message ?? "_";
1250
+ return `msg:private:${userId}:${targetId}:${time}:${crypto.createHash("md5").update(raw).digest("hex")}`;
1251
+ }
1245
1252
  getNoticeGroupKey(e) {
1246
1253
  return `${this.getEventTypeKey(e)}:${e.group_id ?? "_"}:${e.user_id ?? "_"}:${"operator_id" in e ? e.operator_id ?? "_" : "_"}:${"target_id" in e ? e.target_id ?? "_" : "_"}:${e.sub_type ?? "_"}:${"action_type" in e ? e.action_type ?? "_" : "_"}:${"duration" in e ? e.duration ?? "_" : "_"}:${e.time ?? "_"}`;
1247
1254
  }
@@ -1259,6 +1266,7 @@ var Deduplicator = class {
1259
1266
  getKey(e) {
1260
1267
  const typeKey = this.getEventTypeKey(e);
1261
1268
  if (typeKey === "msg:group") return this.getGroupMessageKey(e);
1269
+ if (typeKey === "msg:private") return this.getPrivateMessageKey(e);
1262
1270
  if (typeKey.startsWith("notice:group:")) return this.getNoticeGroupKey(e);
1263
1271
  if (typeKey.startsWith("req:")) return this.getRequestKey(e);
1264
1272
  return "";
@@ -1372,13 +1380,15 @@ async function enablePlugin(bots, plugin, type = "external") {
1372
1380
  const createContext = (bot) => {
1373
1381
  return {
1374
1382
  bot,
1375
- bots,
1376
1383
  self_id: bot.bot_id,
1384
+ bots,
1385
+ pickBot: (id) => bots.find((b) => b.bot_id === id),
1377
1386
  segment: bot.segment,
1378
1387
  getCookie: bot.getCookie.bind(bot),
1379
1388
  ...utils_exports,
1380
1389
  ...config_exports,
1381
1390
  ...buildRemovedActions(bot),
1391
+ actions: actions_exports,
1382
1392
  logger: logger$1,
1383
1393
  services,
1384
1394
  clears: userClears,