/cleanbear_cron.coffee Secret
Created
December 5, 2015 04:55
Star
You must be signed in to star a gist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Description | |
# 掃除当番管理bot(定期実行部分). | |
# | |
# Author: | |
# Hiroaki Ninomiya <ninomiya@spacemarket.com> | |
Cron = require('cron').CronJob | |
Cleanbear = require('./cleanbear.coffee') | |
module.exports = (robot) -> | |
bear = new Cleanbear(robot) | |
# Beginning(Monday) | |
new Cron '0 0 12 * * 1', () => | |
current_sweeper = bear.getCurrentSweeper() | |
robot.messageRoom 'general', """ | |
クマ:bear: | |
今週の掃除当番は<@#{current_sweeper.id}>さんだクマ:bear: | |
よろしっクマ:bear: | |
""" if current_sweeper? | |
, null, true, 'Asia/Tokyo' | |
# Remind(Wednesday) | |
new Cron '0 0 12 * * 3', () => | |
current_sweeper = bear.getCurrentSweeper() | |
message = """ | |
水曜日だクマ:bear: | |
今週の掃除当番は<@#{current_sweeper.id}>さんだクマ:bear: | |
よろしっクマ:bear: | |
""" | |
robot.messageRoom 'general', message | |
, null, true, 'Asia/Tokyo' | |
# Weekend(Friday) | |
new Cron '0 0 12 * * 5', () => | |
current_sweeper = bear.getCurrentSweeper() | |
next_sweeper = bear.getNextSweeper() | |
robot.messageRoom 'general', """ | |
金曜日だクマ:bear: | |
<@#{current_sweeper.id}>さん、お疲れさまっクマ:bear: | |
来週の当番は<@#{next_sweeper.id}>さんクマ:bear: | |
""" if current_sweeper? | |
, null, true, 'Asia/Tokyo' | |
new Cron '30 0 21 * * 5', () => | |
bear.rotateSweeper() | |
robot.messageRoom 'general', '掃除当番を変更したクマ:bear:' | |
, null, true, 'Asia/Tokyo' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment