!16 使用形参解构以减少继承类非必要传参

Merge pull request !16 from 柠檬冲水/N/A
This commit is contained in:
Yoimiya 2023-04-10 15:18:07 +00:00 committed by Gitee
commit 9f0b74ab8a
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
1 changed files with 8 additions and 9 deletions

View File

@ -17,27 +17,26 @@ export default class plugin {
* @param task.fnc 定时任务方法名 * @param task.fnc 定时任务方法名
* @param task.log false时不显示执行日志 * @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 */ /** 监听事件默认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 = { this.task = {
/** 任务名 */ /** 任务名 */
name: '', name: '',
/** 任务方法名 */ /** 任务方法名 */
fnc: data.task?.fnc || '', fnc: task.fnc || '',
/** 任务cron表达式 */ /** 任务cron表达式 */
cron: data.task?.cron || '' cron: task.cron || ''
} }
/** 命令规则 */ /** 命令规则 */
this.rule = data.rule || [] this.rule = rule
} }
/** /**