UNPKG

koishi-plugin-best-cave

Version:

回声洞,可自由添加内容,可配置 MD5/pHash 查重,支持查阅投稿列表(可用但等待重构)

73 lines (72 loc) 2.62 kB
import { Context } from 'koishi'; import { Element, CaveObject } from '..'; /** * 构建并返回洞窟消息内容 * @param cave - 洞窟对象 * @param resourceDir - 资源目录路径 * @param session - 会话对象 * @returns 格式化后的消息字符串 */ export declare function buildMessage(cave: CaveObject, resourceDir: string, session?: any): Promise<string>; /** * 发送临时或永久消息 * @param session - 会话对象 * @param key - 消息key * @param params - 消息参数数组 * @param isTemp - 是否为临时消息 * @param timeout - 临时消息超时时间(ms) * @returns 空字符串 */ export declare function sendMessage(session: any, key: string, params?: any[], isTemp?: boolean, timeout?: number): Promise<string>; /** * 处理媒体文件,返回文件路径或base64编码 * @param filePath - 文件路径 * @param type - 媒体类型('image' | 'video') * @returns 图片路径或视频base64编码 */ export declare function processMediaFile(filePath: string, type: 'image' | 'video'): Promise<string | null>; /** * 从内容中提取媒体元素 * @param originalContent - 原始内容字符串 * @param config - 配置对象,包含图片和视频大小限制 * @param session - 会话对象 * @returns 包含图片、视频URL和元素的对象 */ export declare function extractMediaContent(originalContent: string, config: { imageMaxSize: number; videoMaxSize: number; }, session: any): Promise<{ imageUrls: string[]; imageElements: Array<{ type: 'img'; index: number; fileName?: string; fileSize?: string; }>; videoUrls: string[]; videoElements: Array<{ type: 'video'; index: number; fileName?: string; fileSize?: string; }>; textParts: Element[]; }>; /** * 保存媒体文件 * @param urls - 媒体URL数组 * @param fileNames - 文件名数组 * @param resourceDir - 资源目录路径 * @param caveId - 洞窟ID * @param mediaType - 媒体类型('img' | 'video') * @param config - 配置对象,包含重复检查相关设置 * @param ctx - Koishi上下文 * @param session - 会话对象 * @param buffers - 可选的buffer数组,用于收集图片buffer * @returns 保存后的文件名数组 */ export declare function saveMedia(urls: string[], fileNames: (string | undefined)[], resourceDir: string, caveId: number, mediaType: 'img' | 'video', config: { enableImageDuplicate: boolean; imageDuplicateThreshold: number; textDuplicateThreshold: number; }, ctx: Context, session: any, buffers?: Buffer[]): Promise<string[]>;