()
| 405 | } |
| 406 | |
| 407 | private async tickSchedule(): Promise<void> { |
| 408 | const config = readScheduleConfig(); |
| 409 | if (!config.enabled || !config.target || !config.times.length) return; |
| 410 | const now = new Date(); |
| 411 | const hh = String(now.getHours()).padStart(2, "0"); |
| 412 | const mm = String(now.getMinutes()).padStart(2, "0"); |
| 413 | const current = `${hh}:${mm}`; |
| 414 | if (!config.times.includes(current)) return; |
| 415 | const day = `${now.getFullYear()}-${now.getMonth() + 1}-${now.getDate()}`; |
| 416 | const key = `${day}:${current}`; |
| 417 | if (this.lastRuns.has(key) || this.runningRuns.has(key)) return; |
| 418 | this.runningRuns.add(key); |
| 419 | if (this.lastRuns.size > 200) this.lastRuns = new Set([...this.lastRuns].slice(-80)); |
| 420 | try { |
| 421 | const client = await getGlobalClient(); |
| 422 | if (!client) return; |
| 423 | await sendCloudToTarget(client, config.target, config.limit); |
| 424 | this.lastRuns.add(key); |
| 425 | } finally { |
| 426 | this.runningRuns.delete(key); |
| 427 | } |
| 428 | } |
| 429 | |
| 430 | cmdHandlers: Record<string, (msg: Api.Message, trigger?: Api.Message) => Promise<void>> = { |
| 431 | cy: async (msg) => { |
no test coverage detected