Skip to content

Commit

Permalink
优化 定时任务
Browse files Browse the repository at this point in the history
  • Loading branch information
TimeRainStarSky committed May 31, 2024
1 parent 0dcc13b commit cb2b121
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/plugins/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -531,8 +531,15 @@ class PluginsLoader {

/** 创建定时任务 */
createTask() {
const created = []
for (const i of this.task) {
if (i.job?.cancel) i.job.cancel()
const name = `${logger.blue(`[${i.name}(${i.cron})]`)}`
if (created.includes(name)) {
Bot.makeLog("warn", `重复定时任务 ${name} 已跳过`, "Task")
continue
}
created.push(name)
Bot.makeLog("debug", `加载定时任务 ${name}`, "Task")
i.job = schedule.scheduleJob(i.cron, async () => { try {
const start_time = Date.now()
Expand Down

0 comments on commit cb2b121

Please sign in to comment.