mioki 0.13.0 → 0.15.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
@@ -1,4 +1,4 @@
1
- import { EventMap, GroupMessageEvent, LogLevel, Logger, MessageEvent, NapCat, PrivateMessageEvent, RecvElement, RecvImageElement, Sendable } from "napcat-sdk";
1
+ import { EventMap, GroupMessageEvent, LogLevel, Logger, MessageEvent, NapCat, NoticeEvent, PrivateMessageEvent, RecvElement, RecvImageElement, RequestEvent, Sendable } from "napcat-sdk";
2
2
  import { Low } from "lowdb";
3
3
  import { Jiti } from "jiti";
4
4
  import prettyMs from "pretty-ms";
@@ -28,6 +28,13 @@ declare function getMiokiLogger(level: LogLevel): Logger;
28
28
  interface StartOptions {
29
29
  cwd?: string;
30
30
  }
31
+ interface ExtendedNapCat extends NapCat {
32
+ bot_id: number;
33
+ app_name: string;
34
+ app_version: string;
35
+ name?: string;
36
+ }
37
+ declare const connectedBots: Map<number, ExtendedNapCat>;
31
38
  declare function start(options?: StartOptions): Promise<void>;
32
39
  declare namespace utils_d_exports {
33
40
  export { AnyFunc, Arrayable, Awaitable, ChromeUA, CreateCmdOptions, Gettable, HasMessage, Noop, PureObject, START_TIME, base64Decode, base64Encode, box, clamp, colorize, colors, createCmd, createDB, createStore, dayjs, dedent, ensureBuffer, filesize, filter, find, formatDuration, formatQQLevel, fs, getAuthCodeViaTicket, getBfaceUrl, getGTk, getGroupAvatarLink, getImage, getImageUrl, getMentionedImage, getMentionedImageUrl, getMentionedUserId, getMinicoTokenViaAuthCode, getQQAvatarLink, getQuoteImage, getQuoteImageUrl, getQuoteMsg, getQuoteText, getTerminalInput, isBoolean, isDefined, isFunction, isGroupMsg, isNumber, isObject, isPrivateMsg, isString, jiti, localNum, localeDate, localeTime, match, md5, mri, noNullish, path, prettyMs, qs, queryDevToolsLoginStatus, randomId, randomInt, randomItem, randomItems, requestLoginViaDevTools, runWithReaction, string2argv, stringifyError, stripAnsi, systemInfo, text, toArray, toMsgId, unique, uuid, wait };
@@ -372,8 +379,20 @@ declare const START_TIME: Date;
372
379
  */
373
380
  declare function getGTk(pskey: string): number;
374
381
  declare namespace config_d_exports {
375
- export { BOT_CWD, MiokiConfig, botConfig, hasRight, isAdmin, isInPm2, isOwner, isOwnerOrAdmin, readMiokiConfig, readPackageJson, updateBotCWD, updateBotConfig, writePackageJson };
382
+ export { BOT_CWD, MiokiConfig, NapCatConfig, NapCatInstanceConfig, botConfig, hasRight, isAdmin, isInPm2, isOwner, isOwnerOrAdmin, normalizeNapCatConfig, readMiokiConfig, readPackageJson, updateBotCWD, updateBotConfig, writePackageJson };
383
+ }
384
+ /**
385
+ * NapCat 实例配置
386
+ */
387
+ interface NapCatInstanceConfig {
388
+ name?: string;
389
+ protocol?: 'ws' | 'wss';
390
+ port?: number;
391
+ host?: string;
392
+ token?: string;
376
393
  }
394
+ type NapCatConfig = NapCatInstanceConfig[];
395
+ declare function normalizeNapCatConfig(config: NapCatInstanceConfig | NapCatInstanceConfig[]): NapCatConfig;
377
396
  /**
378
397
  * mioki 配置
379
398
  */
@@ -387,12 +406,7 @@ interface MiokiConfig {
387
406
  log_level?: LogLevel;
388
407
  plugins_dir?: string;
389
408
  status_permission?: 'all' | 'admin-only';
390
- napcat: {
391
- protocol?: 'ws' | 'wss';
392
- port?: number;
393
- host?: string;
394
- token: string;
395
- };
409
+ napcat: NapCatConfig;
396
410
  }
397
411
  /**
398
412
  * 机器人根目录
@@ -534,13 +548,17 @@ declare function getViolationRecords(bot: NapCat, authCode: string, appid: numbe
534
548
  //#region src/builtins/core/status.d.ts
535
549
  declare const SystemMap: Record<string, string>;
536
550
  declare const ArchMap: Record<string, string>;
551
+ interface BotStatus {
552
+ uin: number;
553
+ nickname: string;
554
+ name?: string;
555
+ friends: number;
556
+ groups: number;
557
+ send: number;
558
+ receive: number;
559
+ }
537
560
  interface MiokiStatus {
538
- bot: {
539
- uin: number;
540
- nickname: string;
541
- friends: number;
542
- groups: number;
543
- };
561
+ bots: BotStatus[];
544
562
  plugins: {
545
563
  enabled: number;
546
564
  total: number;
@@ -582,7 +600,7 @@ interface MiokiStatus {
582
600
  percent: number;
583
601
  };
584
602
  }
585
- declare function getMiokiStatus(bot: NapCat): Promise<MiokiStatus>;
603
+ declare function getMiokiStatus(bots: ExtendedNapCat[]): Promise<MiokiStatus>;
586
604
  declare function formatMiokiStatus(status: MiokiStatus): Promise<string>;
587
605
  //#endregion
588
606
  //#region src/builtins/core/index.d.ts
@@ -623,24 +641,74 @@ type StrictEqual<T, U> = (<G>() => G extends T ? 1 : 2) extends (<G>() => G exte
623
641
  type RemoveBotParam<T> = { [K in keyof T]: T[K] extends ((...args: any[]) => any) ? StrictEqual<Parameters<T[K]>[0], NapCat> extends true ? OmitBotParamFromFunc<T[K]> : never : never };
624
642
  type OmitBotParamFromFunc<Func extends (bot: NapCat, ...args: any[]) => any> = Func extends ((bot: NapCat, ...args: infer A) => infer Return) ? (...args: A) => Return : never;
625
643
  declare function bindBot<Params extends Array<any> = any[], Return$1 = any>(bot: NapCat, func: (bot: NapCat, ...args: Params) => Return$1): OmitBotParamFromFunc<(bot: NapCat, ...args: Params) => Return$1>;
644
+ /**
645
+ * 需要去重的事件类型
646
+ */
647
+ type DeduplicableEvent = MessageEvent | RequestEvent | NoticeEvent;
648
+ /**
649
+ * 去重器
650
+ * 处理多个 bot 在相同场景下,同一事件只处理一次
651
+ */
652
+ declare class Deduplicator {
653
+ private processedEvents;
654
+ private maxSize;
655
+ /**
656
+ * 获取事件类型键
657
+ */
658
+ private getEventTypeKey;
659
+ private getGroupMessageKey;
660
+ private getNoticeGroupKey;
661
+ private getRequestKey;
662
+ /**
663
+ * 生成事件唯一键
664
+ */
665
+ private getKey;
666
+ /**
667
+ * 检查事件是否已处理过
668
+ * @param event
669
+ * @param scope
670
+ */
671
+ isProcessed(event: DeduplicableEvent, scope?: string): boolean;
672
+ /**
673
+ * 标记事件为已处理
674
+ * @param event
675
+ * @param scope 需与 isProcessed 一致
676
+ */
677
+ markProcessed(event: DeduplicableEvent, scope?: string): void;
678
+ }
679
+ /**
680
+ * 消息去重器
681
+ * @deprecated 请使用 Deduplicator,它支持更多事件类型
682
+ */
683
+ declare class MessageDeduplicator extends Deduplicator {
684
+ isProcessed(event: GroupMessageEvent | PrivateMessageEvent): boolean;
685
+ markProcessed(event: GroupMessageEvent | PrivateMessageEvent): void;
686
+ }
687
+ declare const deduplicator: Deduplicator;
626
688
  /**
627
689
  * Mioki 上下文对象,包含 Mioki 运行时的信息和方法
628
690
  */
629
691
  interface MiokiContext extends Services, Configs, Utils, RemoveBotParam<Actions> {
630
- /** 机器人实例 */
692
+ /** 当前处理事件的机器人实例 */
631
693
  bot: NapCat;
694
+ /** 所有已连接的机器人实例列表 */
695
+ bots: ExtendedNapCat[];
696
+ /** 当前机器人 QQ 号 */
697
+ self_id: number;
632
698
  /** 消息构造器 */
633
699
  segment: NapCat['segment'];
634
700
  /** 通过域名获取 Cookies */
635
701
  getCookie: NapCat['getCookie'];
636
702
  /** 注册事件处理器 */
637
- handle: <EventName extends keyof EventMap>(eventName: EventName, handler: (event: EventMap[EventName]) => any) => void;
703
+ handle: <EventName extends keyof EventMap>(eventName: EventName, handler: (event: EventMap[EventName]) => any, options?: HandleOptions) => () => void;
638
704
  /** 注册定时任务 */
639
705
  cron: (cronExpression: string, handler: (ctx: MiokiContext, task: TaskContext) => any) => ScheduledTask;
640
706
  /** 待清理的函数集合,在插件卸载时会被调用 */
641
707
  clears: Set<(() => any) | null | undefined>;
642
708
  /** 日志器 */
643
709
  logger: Logger;
710
+ /** 事件去重器 */
711
+ deduplicator: Deduplicator;
644
712
  }
645
713
  declare const runtimePlugins: Map<string, {
646
714
  name: string;
@@ -650,6 +718,16 @@ declare const runtimePlugins: Map<string, {
650
718
  plugin: MiokiPlugin;
651
719
  disable: () => any;
652
720
  }>;
721
+ /**
722
+ * 事件处理器选项
723
+ */
724
+ interface HandleOptions {
725
+ /**
726
+ * 是否启用自动去重
727
+ * @default true
728
+ */
729
+ deduplicate?: boolean;
730
+ }
653
731
  interface MiokiPlugin {
654
732
  /** 插件 ID,请保持唯一,一般为插件目录名称,框架内部通过这个识别不同的插件 */
655
733
  name: string;
@@ -678,7 +756,7 @@ declare function ensurePluginDir(): void;
678
756
  * 获取插件目录的绝对路径
679
757
  */
680
758
  declare function getAbsPluginDir(defaultDir?: string): string;
681
- declare function enablePlugin(bot: NapCat, plugin: MiokiPlugin, type?: 'builtin' | 'external'): Promise<MiokiPlugin>;
759
+ declare function enablePlugin(bots: ExtendedNapCat[], plugin: MiokiPlugin, type?: 'builtin' | 'external'): Promise<MiokiPlugin>;
682
760
  declare function findLocalPlugins(): Promise<{
683
761
  name: string;
684
762
  absPath: string;
@@ -687,5 +765,5 @@ declare function findLocalPlugins(): Promise<{
687
765
  //#region src/builtins/index.d.ts
688
766
  declare const BUILTIN_PLUGINS: MiokiPlugin[];
689
767
  //#endregion
690
- export { AnyFunc, ArchMap, Arrayable, Awaitable, BOT_CWD, BUILTIN_PLUGINS, CORE_PLUGINS, ChromeUA, CreateCmdOptions, Gettable, HasMessage, MiokiConfig, MiokiContext, MiokiCoreServiceContrib, MiokiPlugin, MiokiServices, MiokiStatus, Noop, OmitBotParamFromFunc, PureObject, START_TIME, StartOptions, StatusFormatter, SystemMap, addService, base64Decode, base64Encode, bindBot, botConfig, box, clamp, colorize, colors, createCmd, createDB, createForwardMsg, createStore, dayjs, dedent, definePlugin, enablePlugin, ensureBuffer, ensurePluginDir, filesize, filter, find, findLocalPlugins, formatDuration, formatMiokiStatus, formatQQLevel, fs, getAbsPluginDir, getAuthCodeViaTicket, getBfaceUrl, getGTk, getGroupAvatarLink, getImage, getImageUrl, getLogFilePath, getMentionedImage, getMentionedImageUrl, getMentionedUserId, getMinicoTokenViaAuthCode, getMiokiLogger, getMiokiStatus, getQQAvatarLink, getQuoteImage, getQuoteImageUrl, getQuoteMsg, getQuoteText, getTerminalInput, getViolationRecords, hasRight, isAdmin, isBoolean, isDefined, isFunction, isGroupMsg, isInPm2, isNumber, isObject, isOwner, isOwnerOrAdmin, isPrivateMsg, isString, jiti, localNum, localeDate, localeTime, logger, match, md5, mri, noNullish, noticeAdmins, noticeFriends, noticeGroups, noticeMainOwner, noticeOwners, path, prettyMs, qs, queryDevToolsLoginStatus, randomId, randomInt, randomItem, randomItems, readMiokiConfig, readPackageJson, requestLoginViaDevTools, runWithErrorHandler, runWithReaction, runtimePlugins, services, signArk, start, string2argv, stringifyError, stripAnsi, systemInfo, text, toArray, toMsgId, unique, updateBotCWD, updateBotConfig, uploadImageToCollection, uploadImageToGroupHomework, uploadImageToGroupNotice, uuid, wait, writePackageJson };
768
+ export { AnyFunc, ArchMap, Arrayable, Awaitable, BOT_CWD, BUILTIN_PLUGINS, BotStatus, CORE_PLUGINS, ChromeUA, CreateCmdOptions, DeduplicableEvent, Deduplicator, ExtendedNapCat, Gettable, HandleOptions, HasMessage, MessageDeduplicator, MiokiConfig, MiokiContext, MiokiCoreServiceContrib, MiokiPlugin, MiokiServices, MiokiStatus, NapCatConfig, NapCatInstanceConfig, Noop, OmitBotParamFromFunc, PureObject, START_TIME, StartOptions, StatusFormatter, SystemMap, addService, base64Decode, base64Encode, bindBot, botConfig, box, clamp, colorize, colors, connectedBots, createCmd, createDB, createForwardMsg, createStore, dayjs, dedent, deduplicator, definePlugin, enablePlugin, ensureBuffer, ensurePluginDir, filesize, filter, find, findLocalPlugins, formatDuration, formatMiokiStatus, formatQQLevel, fs, getAbsPluginDir, getAuthCodeViaTicket, getBfaceUrl, getGTk, getGroupAvatarLink, getImage, getImageUrl, getLogFilePath, getMentionedImage, getMentionedImageUrl, getMentionedUserId, getMinicoTokenViaAuthCode, getMiokiLogger, getMiokiStatus, getQQAvatarLink, getQuoteImage, getQuoteImageUrl, getQuoteMsg, getQuoteText, getTerminalInput, getViolationRecords, hasRight, isAdmin, isBoolean, isDefined, isFunction, isGroupMsg, isInPm2, isNumber, isObject, isOwner, isOwnerOrAdmin, isPrivateMsg, isString, jiti, localNum, localeDate, localeTime, logger, match, md5, mri, noNullish, normalizeNapCatConfig, noticeAdmins, noticeFriends, noticeGroups, noticeMainOwner, noticeOwners, path, prettyMs, qs, queryDevToolsLoginStatus, randomId, randomInt, randomItem, randomItems, readMiokiConfig, readPackageJson, requestLoginViaDevTools, runWithErrorHandler, runWithReaction, runtimePlugins, services, signArk, start, string2argv, stringifyError, stripAnsi, systemInfo, text, toArray, toMsgId, unique, updateBotCWD, updateBotConfig, uploadImageToCollection, uploadImageToGroupHomework, uploadImageToGroupNotice, uuid, wait, writePackageJson };
691
769
  //# sourceMappingURL=index.d.cts.map
package/dist/index.d.mts CHANGED
@@ -3,7 +3,7 @@ import path from "node:path";
3
3
  import mri from "mri";
4
4
  import { BinaryLike, BinaryToTextEncoding } from "node:crypto";
5
5
  import { Low } from "lowdb";
6
- import { EventMap, GroupMessageEvent, LogLevel, Logger, MessageEvent, NapCat, PrivateMessageEvent, RecvElement, RecvImageElement, Sendable } from "napcat-sdk";
6
+ import { EventMap, GroupMessageEvent, LogLevel, Logger, MessageEvent, NapCat, NoticeEvent, PrivateMessageEvent, RecvElement, RecvImageElement, RequestEvent, Sendable } from "napcat-sdk";
7
7
  import { Jiti } from "jiti";
8
8
  import { string2argv } from "string2argv";
9
9
  import prettyMs from "pretty-ms";
@@ -26,6 +26,13 @@ declare function getMiokiLogger(level: LogLevel): Logger;
26
26
  interface StartOptions {
27
27
  cwd?: string;
28
28
  }
29
+ interface ExtendedNapCat extends NapCat {
30
+ bot_id: number;
31
+ app_name: string;
32
+ app_version: string;
33
+ name?: string;
34
+ }
35
+ declare const connectedBots: Map<number, ExtendedNapCat>;
29
36
  declare function start(options?: StartOptions): Promise<void>;
30
37
  declare namespace utils_d_exports {
31
38
  export { AnyFunc, Arrayable, Awaitable, ChromeUA, CreateCmdOptions, Gettable, HasMessage, Noop, PureObject, START_TIME, base64Decode, base64Encode, box, clamp, colorize, colors, createCmd, createDB, createStore, dayjs, dedent, ensureBuffer, filesize, filter, find, formatDuration, formatQQLevel, fs, getAuthCodeViaTicket, getBfaceUrl, getGTk, getGroupAvatarLink, getImage, getImageUrl, getMentionedImage, getMentionedImageUrl, getMentionedUserId, getMinicoTokenViaAuthCode, getQQAvatarLink, getQuoteImage, getQuoteImageUrl, getQuoteMsg, getQuoteText, getTerminalInput, isBoolean, isDefined, isFunction, isGroupMsg, isNumber, isObject, isPrivateMsg, isString, jiti, localNum, localeDate, localeTime, match, md5, mri, noNullish, path, prettyMs, qs, queryDevToolsLoginStatus, randomId, randomInt, randomItem, randomItems, requestLoginViaDevTools, runWithReaction, string2argv, stringifyError, stripAnsi, systemInfo, text, toArray, toMsgId, unique, uuid, wait };
@@ -370,8 +377,20 @@ declare const START_TIME: Date;
370
377
  */
371
378
  declare function getGTk(pskey: string): number;
372
379
  declare namespace config_d_exports {
373
- export { BOT_CWD, MiokiConfig, botConfig, hasRight, isAdmin, isInPm2, isOwner, isOwnerOrAdmin, readMiokiConfig, readPackageJson, updateBotCWD, updateBotConfig, writePackageJson };
380
+ export { BOT_CWD, MiokiConfig, NapCatConfig, NapCatInstanceConfig, botConfig, hasRight, isAdmin, isInPm2, isOwner, isOwnerOrAdmin, normalizeNapCatConfig, readMiokiConfig, readPackageJson, updateBotCWD, updateBotConfig, writePackageJson };
381
+ }
382
+ /**
383
+ * NapCat 实例配置
384
+ */
385
+ interface NapCatInstanceConfig {
386
+ name?: string;
387
+ protocol?: 'ws' | 'wss';
388
+ port?: number;
389
+ host?: string;
390
+ token?: string;
374
391
  }
392
+ type NapCatConfig = NapCatInstanceConfig[];
393
+ declare function normalizeNapCatConfig(config: NapCatInstanceConfig | NapCatInstanceConfig[]): NapCatConfig;
375
394
  /**
376
395
  * mioki 配置
377
396
  */
@@ -385,12 +404,7 @@ interface MiokiConfig {
385
404
  log_level?: LogLevel;
386
405
  plugins_dir?: string;
387
406
  status_permission?: 'all' | 'admin-only';
388
- napcat: {
389
- protocol?: 'ws' | 'wss';
390
- port?: number;
391
- host?: string;
392
- token: string;
393
- };
407
+ napcat: NapCatConfig;
394
408
  }
395
409
  /**
396
410
  * 机器人根目录
@@ -532,13 +546,17 @@ declare function getViolationRecords(bot: NapCat, authCode: string, appid: numbe
532
546
  //#region src/builtins/core/status.d.ts
533
547
  declare const SystemMap: Record<string, string>;
534
548
  declare const ArchMap: Record<string, string>;
549
+ interface BotStatus {
550
+ uin: number;
551
+ nickname: string;
552
+ name?: string;
553
+ friends: number;
554
+ groups: number;
555
+ send: number;
556
+ receive: number;
557
+ }
535
558
  interface MiokiStatus {
536
- bot: {
537
- uin: number;
538
- nickname: string;
539
- friends: number;
540
- groups: number;
541
- };
559
+ bots: BotStatus[];
542
560
  plugins: {
543
561
  enabled: number;
544
562
  total: number;
@@ -580,7 +598,7 @@ interface MiokiStatus {
580
598
  percent: number;
581
599
  };
582
600
  }
583
- declare function getMiokiStatus(bot: NapCat): Promise<MiokiStatus>;
601
+ declare function getMiokiStatus(bots: ExtendedNapCat[]): Promise<MiokiStatus>;
584
602
  declare function formatMiokiStatus(status: MiokiStatus): Promise<string>;
585
603
  //#endregion
586
604
  //#region src/builtins/core/index.d.ts
@@ -621,24 +639,74 @@ type StrictEqual<T, U> = (<G>() => G extends T ? 1 : 2) extends (<G>() => G exte
621
639
  type RemoveBotParam<T> = { [K in keyof T]: T[K] extends ((...args: any[]) => any) ? StrictEqual<Parameters<T[K]>[0], NapCat> extends true ? OmitBotParamFromFunc<T[K]> : never : never };
622
640
  type OmitBotParamFromFunc<Func extends (bot: NapCat, ...args: any[]) => any> = Func extends ((bot: NapCat, ...args: infer A) => infer Return) ? (...args: A) => Return : never;
623
641
  declare function bindBot<Params extends Array<any> = any[], Return$1 = any>(bot: NapCat, func: (bot: NapCat, ...args: Params) => Return$1): OmitBotParamFromFunc<(bot: NapCat, ...args: Params) => Return$1>;
642
+ /**
643
+ * 需要去重的事件类型
644
+ */
645
+ type DeduplicableEvent = MessageEvent | RequestEvent | NoticeEvent;
646
+ /**
647
+ * 去重器
648
+ * 处理多个 bot 在相同场景下,同一事件只处理一次
649
+ */
650
+ declare class Deduplicator {
651
+ private processedEvents;
652
+ private maxSize;
653
+ /**
654
+ * 获取事件类型键
655
+ */
656
+ private getEventTypeKey;
657
+ private getGroupMessageKey;
658
+ private getNoticeGroupKey;
659
+ private getRequestKey;
660
+ /**
661
+ * 生成事件唯一键
662
+ */
663
+ private getKey;
664
+ /**
665
+ * 检查事件是否已处理过
666
+ * @param event
667
+ * @param scope
668
+ */
669
+ isProcessed(event: DeduplicableEvent, scope?: string): boolean;
670
+ /**
671
+ * 标记事件为已处理
672
+ * @param event
673
+ * @param scope 需与 isProcessed 一致
674
+ */
675
+ markProcessed(event: DeduplicableEvent, scope?: string): void;
676
+ }
677
+ /**
678
+ * 消息去重器
679
+ * @deprecated 请使用 Deduplicator,它支持更多事件类型
680
+ */
681
+ declare class MessageDeduplicator extends Deduplicator {
682
+ isProcessed(event: GroupMessageEvent | PrivateMessageEvent): boolean;
683
+ markProcessed(event: GroupMessageEvent | PrivateMessageEvent): void;
684
+ }
685
+ declare const deduplicator: Deduplicator;
624
686
  /**
625
687
  * Mioki 上下文对象,包含 Mioki 运行时的信息和方法
626
688
  */
627
689
  interface MiokiContext extends Services, Configs, Utils, RemoveBotParam<Actions> {
628
- /** 机器人实例 */
690
+ /** 当前处理事件的机器人实例 */
629
691
  bot: NapCat;
692
+ /** 所有已连接的机器人实例列表 */
693
+ bots: ExtendedNapCat[];
694
+ /** 当前机器人 QQ 号 */
695
+ self_id: number;
630
696
  /** 消息构造器 */
631
697
  segment: NapCat['segment'];
632
698
  /** 通过域名获取 Cookies */
633
699
  getCookie: NapCat['getCookie'];
634
700
  /** 注册事件处理器 */
635
- handle: <EventName extends keyof EventMap>(eventName: EventName, handler: (event: EventMap[EventName]) => any) => void;
701
+ handle: <EventName extends keyof EventMap>(eventName: EventName, handler: (event: EventMap[EventName]) => any, options?: HandleOptions) => () => void;
636
702
  /** 注册定时任务 */
637
703
  cron: (cronExpression: string, handler: (ctx: MiokiContext, task: TaskContext) => any) => ScheduledTask;
638
704
  /** 待清理的函数集合,在插件卸载时会被调用 */
639
705
  clears: Set<(() => any) | null | undefined>;
640
706
  /** 日志器 */
641
707
  logger: Logger;
708
+ /** 事件去重器 */
709
+ deduplicator: Deduplicator;
642
710
  }
643
711
  declare const runtimePlugins: Map<string, {
644
712
  name: string;
@@ -648,6 +716,16 @@ declare const runtimePlugins: Map<string, {
648
716
  plugin: MiokiPlugin;
649
717
  disable: () => any;
650
718
  }>;
719
+ /**
720
+ * 事件处理器选项
721
+ */
722
+ interface HandleOptions {
723
+ /**
724
+ * 是否启用自动去重
725
+ * @default true
726
+ */
727
+ deduplicate?: boolean;
728
+ }
651
729
  interface MiokiPlugin {
652
730
  /** 插件 ID,请保持唯一,一般为插件目录名称,框架内部通过这个识别不同的插件 */
653
731
  name: string;
@@ -676,7 +754,7 @@ declare function ensurePluginDir(): void;
676
754
  * 获取插件目录的绝对路径
677
755
  */
678
756
  declare function getAbsPluginDir(defaultDir?: string): string;
679
- declare function enablePlugin(bot: NapCat, plugin: MiokiPlugin, type?: 'builtin' | 'external'): Promise<MiokiPlugin>;
757
+ declare function enablePlugin(bots: ExtendedNapCat[], plugin: MiokiPlugin, type?: 'builtin' | 'external'): Promise<MiokiPlugin>;
680
758
  declare function findLocalPlugins(): Promise<{
681
759
  name: string;
682
760
  absPath: string;
@@ -685,5 +763,5 @@ declare function findLocalPlugins(): Promise<{
685
763
  //#region src/builtins/index.d.ts
686
764
  declare const BUILTIN_PLUGINS: MiokiPlugin[];
687
765
  //#endregion
688
- export { AnyFunc, ArchMap, Arrayable, Awaitable, BOT_CWD, BUILTIN_PLUGINS, CORE_PLUGINS, ChromeUA, CreateCmdOptions, Gettable, HasMessage, MiokiConfig, MiokiContext, MiokiCoreServiceContrib, MiokiPlugin, MiokiServices, MiokiStatus, Noop, OmitBotParamFromFunc, PureObject, START_TIME, StartOptions, StatusFormatter, SystemMap, addService, base64Decode, base64Encode, bindBot, botConfig, box, clamp, colorize, colors, createCmd, createDB, createForwardMsg, createStore, dayjs, dedent, definePlugin, enablePlugin, ensureBuffer, ensurePluginDir, filesize, filter, find, findLocalPlugins, formatDuration, formatMiokiStatus, formatQQLevel, fs, getAbsPluginDir, getAuthCodeViaTicket, getBfaceUrl, getGTk, getGroupAvatarLink, getImage, getImageUrl, getLogFilePath, getMentionedImage, getMentionedImageUrl, getMentionedUserId, getMinicoTokenViaAuthCode, getMiokiLogger, getMiokiStatus, getQQAvatarLink, getQuoteImage, getQuoteImageUrl, getQuoteMsg, getQuoteText, getTerminalInput, getViolationRecords, hasRight, isAdmin, isBoolean, isDefined, isFunction, isGroupMsg, isInPm2, isNumber, isObject, isOwner, isOwnerOrAdmin, isPrivateMsg, isString, jiti, localNum, localeDate, localeTime, logger, match, md5, mri, noNullish, noticeAdmins, noticeFriends, noticeGroups, noticeMainOwner, noticeOwners, path, prettyMs, qs, queryDevToolsLoginStatus, randomId, randomInt, randomItem, randomItems, readMiokiConfig, readPackageJson, requestLoginViaDevTools, runWithErrorHandler, runWithReaction, runtimePlugins, services, signArk, start, string2argv, stringifyError, stripAnsi, systemInfo, text, toArray, toMsgId, unique, updateBotCWD, updateBotConfig, uploadImageToCollection, uploadImageToGroupHomework, uploadImageToGroupNotice, uuid, wait, writePackageJson };
766
+ export { AnyFunc, ArchMap, Arrayable, Awaitable, BOT_CWD, BUILTIN_PLUGINS, BotStatus, CORE_PLUGINS, ChromeUA, CreateCmdOptions, DeduplicableEvent, Deduplicator, ExtendedNapCat, Gettable, HandleOptions, HasMessage, MessageDeduplicator, MiokiConfig, MiokiContext, MiokiCoreServiceContrib, MiokiPlugin, MiokiServices, MiokiStatus, NapCatConfig, NapCatInstanceConfig, Noop, OmitBotParamFromFunc, PureObject, START_TIME, StartOptions, StatusFormatter, SystemMap, addService, base64Decode, base64Encode, bindBot, botConfig, box, clamp, colorize, colors, connectedBots, createCmd, createDB, createForwardMsg, createStore, dayjs, dedent, deduplicator, definePlugin, enablePlugin, ensureBuffer, ensurePluginDir, filesize, filter, find, findLocalPlugins, formatDuration, formatMiokiStatus, formatQQLevel, fs, getAbsPluginDir, getAuthCodeViaTicket, getBfaceUrl, getGTk, getGroupAvatarLink, getImage, getImageUrl, getLogFilePath, getMentionedImage, getMentionedImageUrl, getMentionedUserId, getMinicoTokenViaAuthCode, getMiokiLogger, getMiokiStatus, getQQAvatarLink, getQuoteImage, getQuoteImageUrl, getQuoteMsg, getQuoteText, getTerminalInput, getViolationRecords, hasRight, isAdmin, isBoolean, isDefined, isFunction, isGroupMsg, isInPm2, isNumber, isObject, isOwner, isOwnerOrAdmin, isPrivateMsg, isString, jiti, localNum, localeDate, localeTime, logger, match, md5, mri, noNullish, normalizeNapCatConfig, noticeAdmins, noticeFriends, noticeGroups, noticeMainOwner, noticeOwners, path, prettyMs, qs, queryDevToolsLoginStatus, randomId, randomInt, randomItem, randomItems, readMiokiConfig, readPackageJson, requestLoginViaDevTools, runWithErrorHandler, runWithReaction, runtimePlugins, services, signArk, start, string2argv, stringifyError, stripAnsi, systemInfo, text, toArray, toMsgId, unique, updateBotCWD, updateBotConfig, uploadImageToCollection, uploadImageToGroupHomework, uploadImageToGroupNotice, uuid, wait, writePackageJson };
689
767
  //# sourceMappingURL=index.d.mts.map