From 73531b39b36b0515f7239fbed8747c8be6e9a792 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9F=A0=E6=AA=AC=E5=86=B2=E6=B0=B4?= <10424920+ningmengchongshui@user.noreply.gitee.com> Date: Wed, 5 Apr 2023 14:11:54 +0000 Subject: [PATCH] =?UTF-8?q?=E4=BD=BF=E7=94=A8=E5=BD=A2=E5=8F=82=E8=A7=A3?= =?UTF-8?q?=E6=9E=84=E4=BB=A5=E5=87=8F=E5=B0=91=E7=BB=A7=E6=89=BF=E7=B1=BB?= =?UTF-8?q?=E9=9D=9E=E5=BF=85=E8=A6=81=E4=BC=A0=E5=8F=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 柠檬冲水 <10424920+ningmengchongshui@user.noreply.gitee.com> --- lib/plugins/plugin.js | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/lib/plugins/plugin.js b/lib/plugins/plugin.js index 35619e2..1a7616e 100644 --- a/lib/plugins/plugin.js +++ b/lib/plugins/plugin.js @@ -17,27 +17,26 @@ export default class plugin { * @param task.fnc 定时任务方法名 * @param task.log false时不显示执行日志 */ - constructor (data) { + constructor({ name = 'your-plugin', dsc = '无', event = 'message', priority = 5000, task = { fnc: '', cron: '' }, rule = [] }) { /** 插件名称 */ - this.name = data.name + this.name = name /** 插件描述 */ - this.dsc = data.dsc + this.dsc = dsc /** 监听事件,默认message https://oicqjs.github.io/oicq/#events */ - this.event = data.event || 'message' + this.event = event /** 优先级 */ - this.priority = data.priority || 5000 + this.priority = priority /** 定时任务,可以是数组 */ this.task = { /** 任务名 */ name: '', /** 任务方法名 */ - fnc: data.task?.fnc || '', + fnc: task.fnc || '', /** 任务cron表达式 */ - cron: data.task?.cron || '' + cron: task.cron || '' } - /** 命令规则 */ - this.rule = data.rule || [] + this.rule = rule } /**