UNPKG

koishi-plugin-statistical-ranking

Version:

统计所有命令使用和成员发言记录,支持筛选展示列表,可以切换文本和图片两种展示形式

85 lines (84 loc) 3.13 kB
import { Context } from 'koishi'; import { StatRecord } from './index'; /** * 统计查询选项接口 * @interface QueryOptions */ interface QueryOptions { user?: string; guild?: string; platform?: string; command?: string; } /** * 统计数据处理选项接口 * @interface StatProcessOptions * @property {'key' | 'count' | 'time'} [sortBy] - 排序方式,按键名、计数或时间排序 * @property {number} [limit] - 限制返回的条目数量 * @property {boolean} [disableCommandMerge] - 是否禁用命令合并 * @property {boolean} [truncateId] - 是否缩短ID显示 * @property {string[]} [displayBlacklist] - 显示黑名单 * @property {string[]} [displayWhitelist] - 显示白名单 * @property {number} [page] - 当前页码 * @property {number} [pageSize] - 每页条目数 * @property {string} [title] - 标题文本 * @property {boolean} [skipPaging] - 是否跳过分页 */ export interface StatProcessOptions { sortBy?: 'key' | 'count' | 'time'; limit?: number; disableCommandMerge?: boolean; truncateId?: boolean; displayBlacklist?: string[]; displayWhitelist?: string[]; page?: number; pageSize?: number; title?: string; skipPaging?: boolean; } /** * 统计数据处理函数集合 */ export declare const statProcessor: { /** * 处理统计记录并格式化显示 * @param {StatRecord[]} records - 统计记录数组 * @param {keyof StatRecord} aggregateKey - 聚合键 * @param {StatProcessOptions} [options={}] - 处理选项 * @returns {Promise<{items: string[], page: number, totalPages: number, totalItems: number, title: string}>} * 处理后的结果,包含格式化项目、分页信息和标题 */ processStatRecords(records: StatRecord[], aggregateKey: keyof StatRecord, options?: StatProcessOptions): Promise<{ items: string[]; page: number; totalPages: number; totalItems: number; title: string; }>; /** * 处理统计查询并返回结果 * @param {Context} ctx - Koishi上下文 * @param {QueryOptions} options - 查询选项 * @param {'command' | 'user' | 'guild'} type - 查询类型 * @returns {Promise<string | {records: StatRecord[], title: string}>} 查询结果或错误信息 */ handleStatQuery(ctx: Context, options: QueryOptions, type: "command" | "user" | "guild"): Promise<"未找到记录" | { records: StatRecord[]; title: string; }>; /** * 格式化并返回指定类型的列表 * @param {StatRecord[]} records - 统计记录数组 * @param {keyof StatRecord} key - 要获取的键名 * @param {string} title - 列表标题 * @returns {string|null} 格式化后的列表字符串,无内容则返回null */ formatList: (records: StatRecord[], key: keyof StatRecord, title: string) => string | null; /** * 注册列表查看子命令 * @param {Context} ctx - Koishi上下文 * @param {any} parent - 父命令对象 */ registerListCommand(ctx: Context, parent: any): void; }; export {};