UNPKG

koishi-plugin-statistical-ranking

Version:

统计命令使用和成员发言记录,支持分命令/群组/用户统计,支持统计发言排行,支持输出图片

84 lines (83 loc) 3.37 kB
import { Context } from 'koishi'; import { StatRecord } from './index'; import { Rank } from './rank'; export declare const io: { rankInstance: Rank | null; /** * 导出统计数据到文件 * @param {Context} ctx Koishi 上下文 * @param {string} filename 文件名(不含扩展名) * @param {Object} options 导出选项 * @param {string} [options.userId] 筛选特定用户ID * @param {string} [options.platform] 筛选特定平台 * @param {string} [options.guildId] 筛选特定群组ID * @param {string} [options.command] 筛选特定命令 * @param {number} [options.batchSize] 批处理大小,默认为200条/批 * @returns {Promise<{count: number, batches: number, files: Array<{count: number, path: string, filename: string, batch: number, totalBatches: number}>}>} 导出结果 * @throws {Error} 导出失败时抛出错误 */ exportToFile(ctx: Context, filename: string, options: { userId?: string; platform?: string; guildId?: string; command?: string; batchSize?: number; }): Promise<{ count: number; batches: number; files: any[]; }>; /** * 列出可导入的统计数据文件 * @returns {Promise<{files: string[], fileInfo: Record<string, any>}>} 文件列表和详细信息 */ listImportFiles(): Promise<{ files: any[]; fileInfo: {}; }>; /** * 从文件导入统计数据 * @param {Context} ctx Koishi 上下文 * @param {string} filename 文件名或文件组标识 * @param {boolean} [overwrite=false] 是否覆盖现有数据 * @returns {Promise<string>} 导入结果消息 * @throws {Error} 导入失败时抛出错误 */ importFromFile(ctx: Context, filename: string, overwrite?: boolean): Promise<string>; /** * 从 analytics 插件导入历史数据 * @param {Context} ctx Koishi 上下文 * @param {boolean} [overwrite=false] 是否覆盖现有数据 * @returns {Promise<string>} 导入结果消息 * @throws {Error} 导入失败时抛出错误 */ importLegacyData(ctx: Context, overwrite?: boolean): Promise<string>; /** * 解析JSON格式的统计数据 * @param {string} content JSON格式的字符串内容 * @returns {{validRecords: Array<StatRecord>, totalRecords: number, invalidRecords: number}} 解析结果,包括有效记录、总记录数和无效记录数 * @throws {Error} 解析失败时抛出错误 */ parseJSON(content: string): { validRecords: any[]; totalRecords: any; invalidRecords: number; }; /** * 将统计记录导入到数据库 * @param {Context} ctx Koishi 上下文 * @param {Array<StatRecord>} records 要导入的统计记录数组 * @returns {Promise<{imported: number, errors: number}>} 导入结果,包括成功导入数和错误数 */ importRecords(ctx: Context, records: StatRecord[]): Promise<{ imported: number; errors: number; }>; /** * 注册导入导出命令 * @param {Context} ctx Koishi 上下文 * @param {any} parent 父命令对象 * @param {Rank} [rank] 排行榜实例,用于导入后更新排行 */ registerCommands(ctx: Context, parent: any, rank?: Rank): void; };