Procházet zdrojové kódy

feat(插件): 为命令接口添加参数元数据字段

为Command接口添加了paramMetadata字段,以便在插件中更好地管理和使用参数元数据。同时,在相关装饰器和插件初始化代码中初始化该字段为空数组,确保一致性。
枫林 před 3 měsíci
rodič
revize
3a37acf437
4 změnil soubory, kde provedl 8 přidání a 4 odebrání
  1. 1 0
      src/interface/plugin.ts
  2. 2 1
      src/lib/Plugins.ts
  3. 4 2
      src/lib/decorators.ts
  4. 1 1
      src/plugins/upload.ts

+ 1 - 0
src/interface/plugin.ts

@@ -39,6 +39,7 @@ export interface Command {
         sendText: boolean;  // 是否发送文本
         [key: string]: any; // 其他模板配置
     };
+    paramMetadata: ParamMetadata[]; // 参数元数据
 }
 // 参数元数据接口
 export interface ParamMetadata {

+ 2 - 1
src/lib/Plugins.ts

@@ -603,7 +603,8 @@ export function runcod(cmd: string | string[], desc: string): MethodDecorator {
             template: {
                 enabled: false,
                 sendText: true
-            }
+            },
+            paramMetadata: []
         };
 
         plugin.commands.push(command);

+ 4 - 2
src/lib/decorators.ts

@@ -151,7 +151,8 @@ export function plugins(config: PluginConfig): ClassDecorator {
                             ].filter(Boolean).join('\n');
                         }
                     };
-                }
+                },
+                paramMetadata: []
             };
 
             plugin.commands.push(helpCommand);
@@ -224,7 +225,8 @@ export function runcod(cmd: string | string[], desc: string, config: CommandConf
                         enabled: !IsTest,
                         sendText: IsTest, // 默认不发送文本,
                         ...(config.template || {})
-                    }
+                    },
+                    paramMetadata: []
                 };
 
                 plugin.commands.push(command);

+ 1 - 1
src/plugins/upload.ts

@@ -6,7 +6,7 @@ import { GroupMessage, PrivateFriendMessage, PrivateGroupMessage } from 'node-na
 import botlogger from '../lib/logger.js';
 import fs from 'fs/promises';
 import { qqBot } from '../app.js';
-import { ParamType } from '@/interface/plugin.js';
+import { ParamType } from '../interface/plugin.js';
 
 @plugins({
     id: "downloadPlugins", //插件ID,必须唯一,不能重复