koishi-plugin-statistical-ranking
Version:
统计所有命令使用和成员发言记录,支持筛选展示列表,可以切换文本和图片两种展示形式
115 lines (114 loc) • 3.59 kB
TypeScript
import { Context, Schema } from 'koishi';
export declare const name = "statistical-ranking";
export declare const inject: {
required: string[];
optional: string[];
};
/**
* 插件配置接口
* @interface Config
* @property {boolean} [enableDataTransfer] - 是否启用数据导入导出功能
* @property {string[]} [displayBlacklist] - 显示过滤黑名单
* @property {string[]} [displayWhitelist] - 显示过滤白名单
* @property {boolean} [defaultImageMode] - 是否默认使用图片模式展示
* @property {boolean} [silentMode] - 是否启用静默模式
* @property {string[]} [allowedGuilds] - 静默模式下允许响应的群组列表
*/
export interface Config {
enableDataTransfer?: boolean;
displayBlacklist?: string[];
displayWhitelist?: string[];
defaultImageMode?: boolean;
silentMode?: boolean;
allowedGuilds?: string[];
}
/**
* 插件配置模式
*/
export declare const Config: Schema<Schemastery.ObjectS<{
enableDataTransfer: Schema<boolean, boolean>;
defaultImageMode: Schema<boolean, boolean>;
silentMode: Schema<boolean, boolean>;
displayWhitelist: Schema<string[], string[]>;
displayBlacklist: Schema<string[], string[]>;
allowedGuilds: Schema<string[], string[]>;
}>, {
enableDataTransfer: boolean;
defaultImageMode: boolean;
silentMode: boolean;
displayWhitelist: string[];
displayBlacklist: string[];
allowedGuilds: string[];
} & import("cosmokit").Dict>;
/**
* 数据表声明
*/
declare module 'koishi' {
interface Tables {
'analytics.stat': StatRecord;
'analytics.command': LegacyCommandRecord;
binding: BindingRecord;
}
}
/**
* 统计记录数据结构
* @interface StatRecord
* @description 记录用户在不同平台、群组中的命令使用和消息发送情况
* @property {number} id - 记录的唯一ID(自增主键,导入导出时会自动忽略)
* @property {string} platform - 平台标识(如 onebot、telegram 等)
* @property {string} guildId - 群组/频道 ID,私聊时为 'private'
* @property {string} userId - 用户在该平台的唯一标识
* @property {string} [userName] - 用户昵称,可选
* @property {string} command - 命令名称,普通消息时为 '_message'
* @property {number} count - 记录次数,用于统计使用频率
* @property {Date} lastTime - 最后一次记录的时间
* @property {string} [guildName] - 群组/频道名称,可选
*/
export interface StatRecord {
id?: number;
platform: string;
guildId: string;
userId: string;
userName?: string;
command: string;
count: number;
lastTime: Date;
guildName?: string;
}
/**
* 历史命令记录结构
* @interface LegacyCommandRecord
* @description 用于兼容旧版统计数据的结构
*/
interface LegacyCommandRecord {
name: string;
userId: string;
channelId: string;
platform?: string;
date: number;
hour: number;
count: number;
}
/**
* 用户绑定记录结构
* @interface BindingRecord
* @description 存储用户跨平台账号绑定关系
* @property {string} pid - 平台用户 ID
* @property {string} platform - 平台标识
* @property {number} aid - 关联账号 ID
* @property {number} bid - 绑定记录 ID
*/
interface BindingRecord {
pid: string;
platform: string;
aid: number;
bid: number;
}
/**
* 插件主函数
* @public
* @param ctx - Koishi应用上下文
* @param config - 插件配置对象
*/
export declare function apply(ctx: Context, config?: Config): Promise<void>;
export {};