浏览代码

feat(plugins): 在Test类中添加定时任务方法

添加了`testschedule`方法,使用`@schedule`装饰器每30分钟执行一次,用于测试定时任务功能
枫林 3 月之前
父节点
当前提交
b6abaa1740
共有 1 个文件被更改,包括 8 次插入1 次删除
  1. 8 1
      src/plugins/test.ts

+ 8 - 1
src/plugins/test.ts

@@ -1,7 +1,9 @@
-import { param, ParamType, plugins, runcod } from '../lib/decorators.js';
+import { param, ParamType, plugins, runcod, schedule } from '../lib/decorators.js';
 import path from 'path';
 import 'reflect-metadata';
 import { fileURLToPath } from 'node:url';
+import { qqBot } from '../app.js';
+import botlogger from '@/lib/logger.js';
 
 @plugins({
     id: "test", //插件ID,必须唯一,不能重复
@@ -47,4 +49,9 @@ export class Test {
         };
     }
 
+    @schedule('* */30 * * * *') // 每30分钟执行一次
+    async testschedule() {
+        botlogger.info("定时任务测试")
+    }
+
 }