Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NewPlugin: Crontab #22

Open
huan opened this issue Aug 1, 2020 · 0 comments
Open

NewPlugin: Crontab #22

huan opened this issue Aug 1, 2020 · 0 comments
Labels
enhancement New feature or request

Comments

@huan
Copy link
Member

huan commented Aug 1, 2020

Like the following code from our Friday BOT demonstrated: (original author: @qhduan )

import cron from 'node-cron'

interface CRONConfig {
  time: string,
  reply: string
}

const CRON_CONFIG: CRONConfig[] = [
  {
    reply: '星期一了,如果主席还没发活动总结的话要注意了',
    /**
     * 定时任务
     *     ┌─────────────── second (optional)
     *     │ ┌───────────── minute
     *     │ │ ┌─────────── hour
     *     │ │ │  ┌──────── day of month
     *     │ │ │  │ ┌────── month
     *     │ │ │  │ │ ┌──── day of week
     *     │ │ │  │ │ │
     *     │ │ │  │ │ │
     *     * * *  * * *      // */
    time: '0 0 19 * * 1',
  },
]

/**
 * TODO: Huan(202006)
 */
export async function crontab () {
  for (const cronConfig of CRON_CONFIG) {
    cron.schedule(cronConfig.time, async () => {
      // await Chatops.instance().say(cronConfig.reply)
    })
  }
}

See:

@huan huan added the enhancement New feature or request label Aug 1, 2020
@huan huan changed the title NewPlugin: Contab NewPlugin: Crontab Aug 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant