koishi-plugin-noah 2.3.8 → 2.4.1

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.
@@ -0,0 +1,6 @@
1
+ import { Context } from 'koishi';
2
+ /**
3
+ * 注册 poke 命令:主动戳一戳目标用户
4
+ * @param ctx - koishi 上下文
5
+ */
6
+ export declare function registerPokeCommand(ctx: Context): void;
@@ -0,0 +1,6 @@
1
+ import { Context } from 'koishi';
2
+ /**
3
+ * 注册 stamp 命令:手动发送随机贴纸
4
+ * @param ctx - koishi 上下文
5
+ */
6
+ export declare function registerStampCommand(ctx: Context): void;
@@ -0,0 +1,10 @@
1
+ /** 支持的图片扩展名 */
2
+ export declare const IMAGE_EXTENSIONS: readonly [".png", ".jpg", ".jpeg", ".gif", ".webp"];
3
+ /** 扩展名到 MIME 类型的映射 */
4
+ export declare const MIME_MAP: Record<string, string>;
5
+ /** MIME 类型兜底值 */
6
+ export declare const DEFAULT_MIME = "image/png";
7
+ /** tip 缺省语言(用户无匹配偏好时使用) */
8
+ export declare const DEFAULT_LOCALE = "zh-CN";
9
+ /** 被戳时 text 类型随机抽取的提示池(按语言区分) */
10
+ export declare const TIP_POOL: Record<string, string[]>;
@@ -0,0 +1,9 @@
1
+ import { Context } from 'koishi';
2
+ import { PokeConfig } from '../../../types/config';
3
+ /**
4
+ * 注册被戳事件处理:命中冷却发警告,否则按权重分发文本/贴纸
5
+ * @param ctx - koishi 上下文
6
+ * @param config - 戳一戳配置
7
+ * @param cache - 用户 -> 上次触发时间戳的冷却缓存
8
+ */
9
+ export declare function registerPokeNotice(ctx: Context, config: PokeConfig, cache: Map<string, number>): void;
@@ -1,4 +1,5 @@
1
- import { Context } from 'koishi';
1
+ import { Context, Logger } from 'koishi';
2
2
  import { AppConfig } from '../../types/config';
3
3
  export declare const name = "Noah-Poke";
4
+ export declare const logger: Logger;
4
5
  export declare function apply(ctx: Context, config: AppConfig): void;
@@ -6,7 +6,12 @@ declare module 'koishi' {
6
6
  targetId: string;
7
7
  }
8
8
  }
9
+ export type MessageReplyType = 'text' | 'noah' | 'chat';
9
10
  export interface MessageReply {
11
+ type: MessageReplyType;
12
+ weight: number;
13
+ }
14
+ export interface PromptReply {
10
15
  content: string;
11
16
  weight: number;
12
17
  }
@@ -0,0 +1,18 @@
1
+ /**
2
+ * 判断文件是否为图片
3
+ * @param filename - 文件名
4
+ * @returns 是否为支持的图片格式
5
+ */
6
+ export declare function isImageFile(filename: string): boolean;
7
+ /**
8
+ * 根据文件名获取 MIME 类型
9
+ * @param filename - 文件名
10
+ * @returns MIME 类型,未匹配时返回兜底值
11
+ */
12
+ export declare function getMimeType(filename: string): string;
13
+ /**
14
+ * 查找贴纸图片对应的语音文件
15
+ * @param imagePath - 贴纸图片完整路径(如 .../stamp_0384_01.png)
16
+ * @returns 匹配的音频文件路径(如 .../xxx-1.mp3),未找到返回 null
17
+ */
18
+ export declare function findMatchingAudio(imagePath: string): string | null;
@@ -0,0 +1,14 @@
1
+ /**
2
+ * 按权重随机选取一项
3
+ * @param items - 带 weight 字段的数组
4
+ * @returns 命中的元素,空数组时返回 undefined
5
+ */
6
+ export declare function randomMessage<T extends {
7
+ weight: number;
8
+ }>(items: T[]): T | undefined;
9
+ /**
10
+ * 从数组中等概率随机取一项
11
+ * @param items - 任意数组
12
+ * @returns 随机元素,空数组时返回 undefined
13
+ */
14
+ export declare function pickRandom<T>(items: T[]): T | undefined;
@@ -0,0 +1,14 @@
1
+ import { Context, h, Session } from 'koishi';
2
+ /**
3
+ * 随机发送一个 noah 贴纸(文件夹形式,可附带语音)
4
+ * @param ctx - koishi 上下文
5
+ * @param session - 当前会话
6
+ * @param voiceOnly - 是否仅选取带语音的贴纸
7
+ */
8
+ export declare function sendRandomNoahStamp(ctx: Context, session: Session, voiceOnly?: boolean): Promise<void>;
9
+ /**
10
+ * 随机选取一个 chat 贴纸(直接图片形式)
11
+ * @param ctx - koishi 上下文
12
+ * @returns 图片消息元素,失败时返回错误文本
13
+ */
14
+ export declare function getRandomChatStamp(ctx: Context): h | string;
@@ -0,0 +1,10 @@
1
+ import { Session } from 'koishi';
2
+ /**
3
+ * 根据用户偏好语言随机选取一条 tip
4
+ *
5
+ * 按用户的 locales(偏好语言顺序)依次匹配 TIP_POOL,
6
+ * 命中首个有内容的语言;都不匹配时回退到默认语言。
7
+ * @param session - 当前会话
8
+ * @returns 随机 tip 文本,无可用 tip 时返回 undefined
9
+ */
10
+ export declare function pickTip(session: Session): Promise<string | undefined>;