koishi-plugin-best-cave 1.7.1 → 1.7.3

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/lib/index.d.ts ADDED
@@ -0,0 +1,86 @@
1
+ import { Context, Schema } from 'koishi';
2
+ export declare const name = "best-cave";
3
+ export declare const inject: string[];
4
+ export declare const usage = "\n<div style=\"border-radius: 10px; border: 1px solid #ddd; padding: 16px; margin-bottom: 20px; box-shadow: 0 2px 5px rgba(0,0,0,0.1);\">\n <h2 style=\"margin-top: 0; color: #4a6ee0;\">\uD83D\uDCCC \u63D2\u4EF6\u8BF4\u660E</h2>\n <p>\uD83D\uDCD6 <strong>\u4F7F\u7528\u6587\u6863</strong>\uFF1A\u8BF7\u70B9\u51FB\u5DE6\u4E0A\u89D2\u7684 <strong>\u63D2\u4EF6\u4E3B\u9875</strong> \u67E5\u770B\u63D2\u4EF6\u4F7F\u7528\u6587\u6863</p>\n <p>\uD83D\uDD0D <strong>\u66F4\u591A\u63D2\u4EF6</strong>\uFF1A\u53EF\u8BBF\u95EE <a href=\"https://github.com/YisRime\" style=\"color:#4a6ee0;text-decoration:none;\">\u82E1\u6DDE\u7684 GitHub</a> \u67E5\u770B\u672C\u4EBA\u7684\u6240\u6709\u63D2\u4EF6</p>\n</div>\n\n<div style=\"border-radius: 10px; border: 1px solid #ddd; padding: 16px; margin-bottom: 20px; box-shadow: 0 2px 5px rgba(0,0,0,0.1);\">\n <h2 style=\"margin-top: 0; color: #e0574a;\">\u2764\uFE0F \u652F\u6301\u4E0E\u53CD\u9988</h2>\n <p>\uD83C\uDF1F \u559C\u6B22\u8FD9\u4E2A\u63D2\u4EF6\uFF1F\u8BF7\u5728 <a href=\"https://github.com/YisRime\" style=\"color:#e0574a;text-decoration:none;\">GitHub</a> \u4E0A\u7ED9\u6211\u4E00\u4E2A Star\uFF01</p>\n <p>\uD83D\uDC1B \u9047\u5230\u95EE\u9898\uFF1F\u8BF7\u901A\u8FC7 <strong>Issues</strong> \u63D0\u4EA4\u53CD\u9988\uFF0C\u6216\u52A0\u5165 QQ \u7FA4 <a href=\"https://qm.qq.com/q/PdLMx9Jowq\" style=\"color:#e0574a;text-decoration:none;\"><strong>855571375</strong></a> \u8FDB\u884C\u4EA4\u6D41</p>\n</div>\n";
5
+ /**
6
+ * 基础元素类型
7
+ * @interface BaseElement
8
+ * @property {('text'|'img'|'video')} type - 元素类型
9
+ * @property {number} index - 排序索引
10
+ */
11
+ export interface BaseElement {
12
+ type: 'text' | 'img' | 'video';
13
+ index: number;
14
+ }
15
+ /**
16
+ * 文本元素类型
17
+ * @interface TextElement
18
+ * @extends {BaseElement}
19
+ * @property {'text'} type - 文本类型
20
+ * @property {string} content - 文本内容
21
+ */
22
+ export interface TextElement extends BaseElement {
23
+ type: 'text';
24
+ content: string;
25
+ }
26
+ /**
27
+ * 媒体元素类型
28
+ * @interface MediaElement
29
+ * @extends {BaseElement}
30
+ * @property {('img'|'video')} type - 媒体类型
31
+ * @property {string} [file] - 文件名
32
+ * @property {string} [fileName] - 原始文件名
33
+ * @property {string} [fileSize] - 文件大小
34
+ * @property {string} [filePath] - 文件路径
35
+ */
36
+ export interface MediaElement extends BaseElement {
37
+ type: 'img' | 'video';
38
+ file?: string;
39
+ fileName?: string;
40
+ fileSize?: string;
41
+ filePath?: string;
42
+ }
43
+ export type Element = TextElement | MediaElement;
44
+ /**
45
+ * 回声洞对象
46
+ * @interface CaveObject
47
+ * @property {number} cave_id - 回声洞ID
48
+ * @property {Element[]} elements - 元素列表
49
+ * @property {string} contributor_number - 投稿者ID
50
+ * @property {string} contributor_name - 投稿者名称
51
+ */
52
+ export interface CaveObject {
53
+ cave_id: number;
54
+ elements: Element[];
55
+ contributor_number: string;
56
+ contributor_name: string;
57
+ }
58
+ export interface PendingCave extends CaveObject {
59
+ }
60
+ export interface Config {
61
+ manager: string[];
62
+ number: number;
63
+ enableAudit: boolean;
64
+ allowVideo: boolean;
65
+ videoMaxSize: number;
66
+ imageMaxSize: number;
67
+ blacklist: string[];
68
+ whitelist: string[];
69
+ enablePagination: boolean;
70
+ itemsPerPage: number;
71
+ enableImageDuplicate: boolean;
72
+ imageDuplicateThreshold: number;
73
+ textDuplicateThreshold: number;
74
+ enableTextDuplicate: boolean;
75
+ }
76
+ /**
77
+ * 插件配置项
78
+ * @type {Schema}
79
+ */
80
+ export declare const Config: Schema<Config>;
81
+ /**
82
+ * 插件主入口
83
+ * @param {Context} ctx - Koishi上下文
84
+ * @param {Config} config - 插件配置
85
+ */
86
+ export declare function apply(ctx: Context, config: Config): Promise<void>;
package/lib/index.js CHANGED
@@ -50,7 +50,8 @@ __export(src_exports, {
50
50
  Config: () => Config,
51
51
  apply: () => apply,
52
52
  inject: () => inject,
53
- name: () => name
53
+ name: () => name,
54
+ usage: () => usage
54
55
  });
55
56
  module.exports = __toCommonJS(src_exports);
56
57
  var import_koishi6 = require("koishi");
@@ -1526,6 +1527,19 @@ __name(processDelete, "processDelete");
1526
1527
  // src/index.ts
1527
1528
  var name = "best-cave";
1528
1529
  var inject = ["database"];
1530
+ var usage = `
1531
+ <div style="border-radius: 10px; border: 1px solid #ddd; padding: 16px; margin-bottom: 20px; box-shadow: 0 2px 5px rgba(0,0,0,0.1);">
1532
+ <h2 style="margin-top: 0; color: #4a6ee0;">📌 插件说明</h2>
1533
+ <p>📖 <strong>使用文档</strong>:请点击左上角的 <strong>插件主页</strong> 查看插件使用文档</p>
1534
+ <p>🔍 <strong>更多插件</strong>:可访问 <a href="https://github.com/YisRime" style="color:#4a6ee0;text-decoration:none;">苡淞的 GitHub</a> 查看本人的所有插件</p>
1535
+ </div>
1536
+
1537
+ <div style="border-radius: 10px; border: 1px solid #ddd; padding: 16px; margin-bottom: 20px; box-shadow: 0 2px 5px rgba(0,0,0,0.1);">
1538
+ <h2 style="margin-top: 0; color: #e0574a;">❤️ 支持与反馈</h2>
1539
+ <p>🌟 喜欢这个插件?请在 <a href="https://github.com/YisRime" style="color:#e0574a;text-decoration:none;">GitHub</a> 上给我一个 Star!</p>
1540
+ <p>🐛 遇到问题?请通过 <strong>Issues</strong> 提交反馈,或加入 QQ 群 <a href="https://qm.qq.com/q/PdLMx9Jowq" style="color:#e0574a;text-decoration:none;"><strong>855571375</strong></a> 进行交流</p>
1541
+ </div>
1542
+ `;
1529
1543
  var logger5 = new import_koishi6.Logger("cave");
1530
1544
  var Config = import_koishi6.Schema.object({
1531
1545
  manager: import_koishi6.Schema.array(import_koishi6.Schema.string()).required(),
@@ -1825,5 +1839,6 @@ __name(cleanElementsForSave, "cleanElementsForSave");
1825
1839
  Config,
1826
1840
  apply,
1827
1841
  inject,
1828
- name
1842
+ name,
1843
+ usage
1829
1844
  });
@@ -0,0 +1,89 @@
1
+ import { Context } from 'koishi';
2
+ import { Config, PendingCave } from '..';
3
+ import { IdManager } from './IdManager';
4
+ /**
5
+ * 管理洞审核相关操作的类
6
+ */
7
+ export declare class AuditManager {
8
+ private ctx;
9
+ private config;
10
+ private idManager;
11
+ private logger;
12
+ /**
13
+ * 创建审核管理器实例
14
+ * @param ctx - Koishi 上下文
15
+ * @param config - 配置对象
16
+ * @param idManager - ID 管理器实例
17
+ */
18
+ constructor(ctx: Context, config: Config, idManager: IdManager);
19
+ /**
20
+ * 处理审核操作
21
+ * @param pendingData - 待审核的洞数据数组
22
+ * @param isApprove - 是否通过审核
23
+ * @param caveFilePath - 洞数据文件路径
24
+ * @param resourceDir - 资源目录路径
25
+ * @param pendingFilePath - 待审核数据文件路径
26
+ * @param session - 会话对象
27
+ * @param targetId - 目标洞ID(可选)
28
+ * @returns 处理结果消息
29
+ */
30
+ processAudit(pendingData: PendingCave[], isApprove: boolean, caveFilePath: string, resourceDir: string, pendingFilePath: string, session: any, targetId?: number): Promise<string>;
31
+ /**
32
+ * 处理单条审核
33
+ * @param pendingData - 待审核的洞数据数组
34
+ * @param isApprove - 是否通过审核
35
+ * @param caveFilePath - 洞数据文件路径
36
+ * @param resourceDir - 资源目录路径
37
+ * @param pendingFilePath - 待审核数据文件路径
38
+ * @param targetId - 目标洞ID
39
+ * @param session - 会话对象
40
+ * @returns 处理结果消息
41
+ * @private
42
+ */
43
+ private handleSingleAudit;
44
+ /**
45
+ * 处理批量审核
46
+ * @param pendingData - 待审核的洞数据数组
47
+ * @param isApprove - 是否通过审核
48
+ * @param caveFilePath - 洞数据文件路径
49
+ * @param resourceDir - 资源目录路径
50
+ * @param pendingFilePath - 待审核数据文件路径
51
+ * @param session - 会话对象
52
+ * @returns 处理结果消息
53
+ * @private
54
+ */
55
+ private handleBatchAudit;
56
+ /**
57
+ * 发送审核消息给管理员
58
+ * @param cave - 待审核的洞数据
59
+ * @param content - 消息内容
60
+ * @param session - 会话对象
61
+ */
62
+ sendAuditMessage(cave: PendingCave, content: string, session: any): Promise<void>;
63
+ /**
64
+ * 删除媒体文件
65
+ * @param cave - 洞数据
66
+ * @param resourceDir - 资源目录路径
67
+ * @private
68
+ */
69
+ private deleteMediaFiles;
70
+ /**
71
+ * 清理元素数据用于保存
72
+ * @param elements - 元素数组
73
+ * @param keepIndex - 是否保留索引
74
+ * @returns 清理后的元素数组
75
+ * @private
76
+ */
77
+ private cleanElementsForSave;
78
+ /**
79
+ * 发送消息
80
+ * @param session - 会话对象
81
+ * @param key - 消息key
82
+ * @param params - 消息参数
83
+ * @param isTemp - 是否为临时消息
84
+ * @param timeout - 临时消息超时时间
85
+ * @returns 空字符串
86
+ * @private
87
+ */
88
+ private sendMessage;
89
+ }
@@ -0,0 +1,80 @@
1
+ import { Buffer } from 'buffer';
2
+ /**
3
+ * 图片哈希计算工具类
4
+ * 使用 DCT(离散余弦变换)方法计算图片的感知哈希值,可用于图片相似度比较
5
+ */
6
+ export declare class ContentHasher {
7
+ /**
8
+ * 计算图片的感知哈希值
9
+ * @param imageBuffer - 图片的二进制数据
10
+ * @returns 返回64位的十六进制哈希字符串
11
+ * @throws 当图片处理失败时可能抛出错误
12
+ */
13
+ static calculateHash(imageBuffer: Buffer): Promise<string>;
14
+ /**
15
+ * 将二进制字符串转换为十六进制
16
+ * @param binary - 二进制字符串
17
+ * @returns 十六进制字符串
18
+ * @private
19
+ */
20
+ private static binaryToHex;
21
+ /**
22
+ * 将十六进制字符串转换为二进制
23
+ * @param hex - 十六进制字符串
24
+ * @returns 二进制字符串
25
+ * @private
26
+ */
27
+ private static hexToBinary;
28
+ /**
29
+ * 计算图像的DCT(离散余弦变换)
30
+ * @param data - 图像数据
31
+ * @param size - 图像尺寸
32
+ * @returns DCT变换后的矩阵
33
+ * @private
34
+ */
35
+ private static computeDCT;
36
+ /**
37
+ * 获取DCT系数
38
+ * @param index - 索引值
39
+ * @param size - 矩阵大小
40
+ * @returns DCT系数
41
+ * @private
42
+ */
43
+ private static getDCTCoefficient;
44
+ /**
45
+ * 计算数组的中位数
46
+ * @param arr - 输入数组
47
+ * @returns 中位数
48
+ * @private
49
+ */
50
+ private static calculateMedian;
51
+ /**
52
+ * 从DCT矩阵中提取特征值
53
+ * @param matrix - DCT矩阵
54
+ * @param size - 矩阵大小
55
+ * @returns 特征值数组
56
+ * @private
57
+ */
58
+ private static extractFeatures;
59
+ /**
60
+ * 计算两个哈希值之间的汉明距离
61
+ * @param hash1 - 第一个哈希值
62
+ * @param hash2 - 第二个哈希值
63
+ * @returns 汉明距离
64
+ * @throws 当两个哈希值长度不等时抛出错误
65
+ */
66
+ static calculateDistance(hash1: string, hash2: string): number;
67
+ /**
68
+ * 计算两个图片哈希值的相似度
69
+ * @param hash1 - 第一个哈希值
70
+ * @param hash2 - 第二个哈希值
71
+ * @returns 返回0-1之间的相似度值,1表示完全相同,0表示完全不同
72
+ */
73
+ static calculateSimilarity(hash1: string, hash2: string): number;
74
+ /**
75
+ * 计算文本的哈希值
76
+ * @param text - 输入文本
77
+ * @returns 文本的哈希值(36进制字符串)
78
+ */
79
+ static calculateTextHash(text: string): string;
80
+ }
@@ -0,0 +1,63 @@
1
+ export declare class FileHandler {
2
+ private static locks;
3
+ private static readonly RETRY_COUNT;
4
+ private static readonly RETRY_DELAY;
5
+ private static readonly CONCURRENCY_LIMIT;
6
+ /**
7
+ * 并发控制
8
+ * @param operation 要执行的操作
9
+ * @param limit 并发限制
10
+ * @returns 操作结果
11
+ */
12
+ private static withConcurrencyLimit;
13
+ /**
14
+ * 文件操作包装器
15
+ * @param filePath 文件路径
16
+ * @param operation 要执行的操作
17
+ * @returns 操作结果
18
+ */
19
+ private static withFileOp;
20
+ /**
21
+ * 事务处理
22
+ * @param operations 要执行的操作数组
23
+ * @returns 操作结果数组
24
+ */
25
+ static withTransaction<T>(operations: Array<{
26
+ filePath: string;
27
+ operation: () => Promise<T>;
28
+ rollback?: () => Promise<void>;
29
+ }>): Promise<T[]>;
30
+ /**
31
+ * 读取 JSON 数据
32
+ * @param filePath 文件路径
33
+ * @returns JSON 数据
34
+ */
35
+ static readJsonData<T>(filePath: string): Promise<T[]>;
36
+ /**
37
+ * 写入 JSON 数据
38
+ * @param filePath 文件路径
39
+ * @param data 要写入的数据
40
+ */
41
+ static writeJsonData<T>(filePath: string, data: T[]): Promise<void>;
42
+ /**
43
+ * 确保目录存在
44
+ * @param dir 目录路径
45
+ */
46
+ static ensureDirectory(dir: string): Promise<void>;
47
+ /**
48
+ * 确保 JSON 文件存在
49
+ * @param filePath 文件路径
50
+ */
51
+ static ensureJsonFile(filePath: string): Promise<void>;
52
+ /**
53
+ * 保存媒体文件
54
+ * @param filePath 文件路径
55
+ * @param data 文件数据
56
+ */
57
+ static saveMediaFile(filePath: string, data: Buffer | string): Promise<void>;
58
+ /**
59
+ * 删除媒体文件
60
+ * @param filePath 文件路径
61
+ */
62
+ static deleteMediaFile(filePath: string): Promise<void>;
63
+ }
@@ -0,0 +1,108 @@
1
+ /**
2
+ * 哈希存储状态类型
3
+ */
4
+ interface HashStorageStatus {
5
+ lastUpdated: string;
6
+ entries: Array<{
7
+ caveId: number;
8
+ imageHashes: string[];
9
+ textHashes: string[];
10
+ }>;
11
+ }
12
+ /**
13
+ * 图片哈希值存储管理类
14
+ * 负责管理和维护回声洞图片的哈希值
15
+ */
16
+ export declare class HashManager {
17
+ private readonly caveDir;
18
+ private static readonly HASH_FILE;
19
+ private static readonly CAVE_FILE;
20
+ private static readonly BATCH_SIZE;
21
+ private imageHashes;
22
+ private textHashes;
23
+ private initialized;
24
+ /**
25
+ * 初始化HashManager实例
26
+ * @param caveDir 回声洞数据目录路径
27
+ */
28
+ constructor(caveDir: string);
29
+ private get filePath();
30
+ private get resourceDir();
31
+ private get caveFilePath();
32
+ /**
33
+ * 初始化哈希存储
34
+ * 读取现有哈希数据或重新构建哈希值
35
+ * @throws 初始化失败时抛出错误
36
+ */
37
+ initialize(): Promise<void>;
38
+ /**
39
+ * 获取当前哈希存储状态
40
+ * @returns 包含最后更新时间和所有条目的状态对象
41
+ */
42
+ getStatus(): Promise<HashStorageStatus>;
43
+ /**
44
+ * 更新指定回声洞的图片哈希值
45
+ * @param caveId 回声洞ID
46
+ * @param content 图片buffer数组
47
+ */
48
+ updateCaveContent(caveId: number, content: {
49
+ images?: Buffer[];
50
+ texts?: string[];
51
+ }): Promise<void>;
52
+ /**
53
+ * 更新所有回声洞的哈希值
54
+ * @param isInitialBuild 是否为初始构建
55
+ */
56
+ updateAllCaves(isInitialBuild?: boolean): Promise<void>;
57
+ /**
58
+ * 查找重复的图片
59
+ * @param content 待查找的图片buffer数组
60
+ * @param thresholds 相似度阈值
61
+ * @returns 匹配结果数组,包含索引、回声洞ID和相似度
62
+ */
63
+ findDuplicates(content: {
64
+ images?: Buffer[];
65
+ texts?: string[];
66
+ }, thresholds: {
67
+ image: number;
68
+ text: number;
69
+ }): Promise<Array<{
70
+ type: 'image' | 'text';
71
+ index: number;
72
+ caveId: number;
73
+ similarity: number;
74
+ } | null>>;
75
+ private findTextDuplicates;
76
+ private calculateTextSimilarity;
77
+ private findImageDuplicates;
78
+ /**
79
+ * 加载回声洞数据
80
+ * @returns 回声洞数据数组
81
+ * @private
82
+ */
83
+ private loadCaveData;
84
+ /**
85
+ * 保存哈希数据到文件
86
+ * @private
87
+ */
88
+ private saveContentHashes;
89
+ /**
90
+ * 构建初始哈希数据
91
+ * @private
92
+ */
93
+ private buildInitialHashes;
94
+ /**
95
+ * 更新缺失的哈希值
96
+ * @private
97
+ */
98
+ private updateMissingHashes;
99
+ /**
100
+ * 批量处理数组项
101
+ * @param items 待处理项数组
102
+ * @param processor 处理函数
103
+ * @param batchSize 批处理大小
104
+ * @private
105
+ */
106
+ private processBatch;
107
+ }
108
+ export {};
@@ -0,0 +1,69 @@
1
+ /**
2
+ * ID管理器类
3
+ * 负责管理回声洞ID的分配、删除和统计信息
4
+ */
5
+ export declare class IdManager {
6
+ private deletedIds;
7
+ private maxId;
8
+ private initialized;
9
+ private readonly statusFilePath;
10
+ private stats;
11
+ private usedIds;
12
+ /**
13
+ * 初始化ID管理器
14
+ * @param baseDir - 基础目录路径
15
+ */
16
+ constructor(baseDir: string);
17
+ /**
18
+ * 初始化ID管理系统
19
+ * @param caveFilePath - 正式回声洞数据文件路径
20
+ * @param pendingFilePath - 待处理回声洞数据文件路径
21
+ * @throws 当初始化失败时抛出错误
22
+ */
23
+ initialize(caveFilePath: string, pendingFilePath: string): Promise<void>;
24
+ /**
25
+ * 处理ID冲突
26
+ * @param conflicts - ID冲突映射表
27
+ * @param caveFilePath - 正式回声洞数据文件路径
28
+ * @param pendingFilePath - 待处理回声洞数据文件路径
29
+ * @param caveData - 正式回声洞数据
30
+ * @param pendingData - 待处理回声洞数据
31
+ * @private
32
+ */
33
+ private handleConflicts;
34
+ /**
35
+ * 获取下一个可用的ID
36
+ * @returns 下一个可用的ID
37
+ * @throws 当ID管理器未初始化时抛出错误
38
+ */
39
+ getNextId(): number;
40
+ /**
41
+ * 标记ID为已删除状态
42
+ * @param id - 要标记为删除的ID
43
+ * @throws 当ID管理器未初始化时抛出错误
44
+ */
45
+ markDeleted(id: number): Promise<void>;
46
+ /**
47
+ * 添加贡献统计
48
+ * @param contributorNumber - 贡献者编号
49
+ * @param caveId - 回声洞ID
50
+ */
51
+ addStat(contributorNumber: string, caveId: number): Promise<void>;
52
+ /**
53
+ * 移除贡献统计
54
+ * @param contributorNumber - 贡献者编号
55
+ * @param caveId - 回声洞ID
56
+ */
57
+ removeStat(contributorNumber: string, caveId: number): Promise<void>;
58
+ /**
59
+ * 获取所有贡献统计信息
60
+ * @returns 贡献者编号到回声洞ID列表的映射
61
+ */
62
+ getStats(): Record<string, number[]>;
63
+ /**
64
+ * 保存当前状态到文件
65
+ * @private
66
+ * @throws 当保存失败时抛出错误
67
+ */
68
+ private saveStatus;
69
+ }
@@ -0,0 +1,72 @@
1
+ import { Context } from 'koishi';
2
+ import { Element, CaveObject } from '..';
3
+ /**
4
+ * 构建并返回洞窟消息内容
5
+ * @param cave - 洞窟对象
6
+ * @param resourceDir - 资源目录路径
7
+ * @param session - 会话对象
8
+ * @returns 格式化后的消息字符串
9
+ */
10
+ export declare function buildMessage(cave: CaveObject, resourceDir: string, session?: any): Promise<string>;
11
+ /**
12
+ * 发送临时或永久消息
13
+ * @param session - 会话对象
14
+ * @param key - 消息key
15
+ * @param params - 消息参数数组
16
+ * @param isTemp - 是否为临时消息
17
+ * @param timeout - 临时消息超时时间(ms)
18
+ * @returns 空字符串
19
+ */
20
+ export declare function sendMessage(session: any, key: string, params?: any[], isTemp?: boolean, timeout?: number): Promise<string>;
21
+ /**
22
+ * 处理媒体文件,返回文件路径或base64编码
23
+ * @param filePath - 文件路径
24
+ * @param type - 媒体类型('image' | 'video')
25
+ * @returns 图片路径或视频base64编码
26
+ */
27
+ export declare function processMediaFile(filePath: string, type: 'image' | 'video'): Promise<string | null>;
28
+ /**
29
+ * 从内容中提取媒体元素
30
+ * @param originalContent - 原始内容字符串
31
+ * @param config - 配置对象,包含图片和视频大小限制
32
+ * @param session - 会话对象
33
+ * @returns 包含图片、视频URL和元素的对象
34
+ */
35
+ export declare function extractMediaContent(originalContent: string, config: {
36
+ imageMaxSize: number;
37
+ videoMaxSize: number;
38
+ }, session: any): Promise<{
39
+ imageUrls: string[];
40
+ imageElements: Array<{
41
+ type: 'img';
42
+ index: number;
43
+ fileName?: string;
44
+ fileSize?: string;
45
+ }>;
46
+ videoUrls: string[];
47
+ videoElements: Array<{
48
+ type: 'video';
49
+ index: number;
50
+ fileName?: string;
51
+ fileSize?: string;
52
+ }>;
53
+ textParts: Element[];
54
+ }>;
55
+ /**
56
+ * 保存媒体文件
57
+ * @param urls - 媒体URL数组
58
+ * @param fileNames - 文件名数组
59
+ * @param resourceDir - 资源目录路径
60
+ * @param caveId - 洞窟ID
61
+ * @param mediaType - 媒体类型('img' | 'video')
62
+ * @param config - 配置对象,包含重复检查相关设置
63
+ * @param ctx - Koishi上下文
64
+ * @param session - 会话对象
65
+ * @param buffers - 可选的buffer数组,用于收集图片buffer
66
+ * @returns 保存后的文件名数组
67
+ */
68
+ export declare function saveMedia(urls: string[], fileNames: (string | undefined)[], resourceDir: string, caveId: number, mediaType: 'img' | 'video', config: {
69
+ enableImageDuplicate: boolean;
70
+ imageDuplicateThreshold: number;
71
+ textDuplicateThreshold: number;
72
+ }, ctx: Context, session: any, buffers?: Buffer[]): Promise<string[]>;
@@ -0,0 +1,45 @@
1
+ import { Config } from '..';
2
+ import { IdManager } from './IdManager';
3
+ import { HashManager } from './HashManager';
4
+ /**
5
+ * 处理回声洞列表查询
6
+ * @param session - 会话对象
7
+ * @param config - 配置对象
8
+ * @param idManager - ID管理器实例
9
+ * @param userId - 可选的用户ID,用于筛选特定用户的回声洞
10
+ * @param pageNum - 页码,默认为1
11
+ * @returns 格式化后的回声洞列表字符串
12
+ */
13
+ export declare function processList(session: any, config: Config, idManager: IdManager, userId?: string, pageNum?: number): Promise<string>;
14
+ /**
15
+ * 查看指定ID的回声洞内容
16
+ * @param caveFilePath - 回声洞数据文件路径
17
+ * @param resourceDir - 资源文件目录路径
18
+ * @param session - 会话对象
19
+ * @param options - 命令选项
20
+ * @param content - 命令内容数组
21
+ * @returns 回声洞内容的格式化字符串
22
+ */
23
+ export declare function processView(caveFilePath: string, resourceDir: string, session: any, options: any, content: string[]): Promise<string>;
24
+ /**
25
+ * 随机获取一个回声洞
26
+ * @param caveFilePath - 回声洞数据文件路径
27
+ * @param resourceDir - 资源文件目录路径
28
+ * @param session - 会话对象
29
+ * @returns 随机回声洞的格式化字符串,如果没有可用的回声洞则返回错误消息
30
+ */
31
+ export declare function processRandom(caveFilePath: string, resourceDir: string, session: any): Promise<string | void>;
32
+ /**
33
+ * 删除指定ID的回声洞
34
+ * @param caveFilePath - 回声洞数据文件路径
35
+ * @param resourceDir - 资源文件目录路径
36
+ * @param pendingFilePath - 待审核回声洞数据文件路径
37
+ * @param session - 会话对象
38
+ * @param config - 配置对象
39
+ * @param options - 命令选项
40
+ * @param content - 命令内容数组
41
+ * @param idManager - ID管理器实例
42
+ * @param HashManager - 哈希管理器实例
43
+ * @returns 删除操作的结果消息
44
+ */
45
+ export declare function processDelete(caveFilePath: string, resourceDir: string, pendingFilePath: string, session: any, config: Config, options: any, content: string[], idManager: IdManager, HashManager: HashManager): Promise<string>;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koishi-plugin-best-cave",
3
- "description": "回声洞,可自由添加内容(包括视频),具有可配置的 MD5/pHash 查重机制和可开关的审核系统,支持查阅投稿列表",
4
- "version": "1.7.1",
3
+ "description": "回声洞,可自由添加内容,可配置 MD5/pHash 查重,支持查阅投稿列表(可用但等待重构)",
4
+ "version": "1.7.3",
5
5
  "contributors": [
6
6
  "Yis_Rime <yis_rime@outlook.com>"
7
7
  ],
@@ -24,9 +24,10 @@
24
24
  "cave",
25
25
  "回声洞"
26
26
  ],
27
- "devDependencies": {},
28
27
  "peerDependencies": {
29
- "koishi": "^4.18.3",
28
+ "koishi": "^4.18.3"
29
+ },
30
+ "dependencies": {
30
31
  "sharp": "^0.33.5"
31
32
  }
32
33
  }