Skip to content

NewPlugin: Crontab #22

@huan

Description

@huan

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:

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions