plugin.ts 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. // 更新 Plugin 接口
  2. export interface Plugin {
  3. id: string;
  4. name: string;
  5. commands: Command[];
  6. class: any;
  7. version?: string;
  8. author?: string;
  9. describe?: string;
  10. config: PluginConfig
  11. }
  12. // 修改插件装饰器配置接口
  13. export interface PluginConfig {
  14. id: string;// 插件ID
  15. name: string;// 插件名称
  16. version?: string;// 插件版本
  17. describe?: string;// 插件描述
  18. author?: string;// 插件作者
  19. help?: {// 帮助命令配置,使用框架默认的帮助配置
  20. enabled?: boolean; // 是否启用帮助命令
  21. command?: string[]; // 帮助命令
  22. description?: string; // 帮助命令描述
  23. };
  24. defaultCommandId?: string; // 默认函数
  25. }
  26. // 在 decorators.ts 中定义统一的接口
  27. export interface Command {
  28. cmd: string; // 命令名称
  29. desc: string; // 命令描述
  30. fn: Function; // 命令函数
  31. aliases?: string[]; // 命令别名
  32. cmdPrefix: string; // 命令前缀
  33. pluginId: string; // 插件ID
  34. class: new () => any;
  35. template?: {
  36. enabled: boolean; // 是否启用模板
  37. sendText: boolean; // 是否发送文本
  38. [key: string]: any; // 其他模板配置
  39. };
  40. }
  41. // 参数元数据接口
  42. export interface ParamMetadata {
  43. name: string; // 参数名称
  44. type: ParamType; // 参数类型
  45. index: number; // 参数索引
  46. optional: boolean; // 是否可选
  47. }
  48. // 参数类型枚举
  49. export const ParamType = {
  50. String: "string" as const,
  51. Number: "number" as const,
  52. Boolean: "boolean" as const,
  53. Rest: "rest" as const
  54. } as const;
  55. // 从对象值中获取类型
  56. export type ParamType = typeof ParamType[keyof typeof ParamType];
  57. // 添加模板配置接口
  58. export interface TemplateConfig {
  59. enabled: boolean;
  60. sendText: boolean;
  61. [key: string]: any;
  62. }
  63. // 修改命令装饰器配置
  64. export interface CommandConfig {
  65. template?: TemplateConfig;
  66. [key: string]: any;
  67. }