LoginSignup
6
6

More than 5 years have passed since last update.

ペットボトルは第一と第三水曜日しかゴミ出し出来ない

Last updated at Posted at 2015-10-05

ペットボトルは月に2回しかゴミ出し出来ないので一度忘れるとオフィスにペットボトルが溢れることになる
ので、ゴミ出しの日を朝slackに通知する様にしてみた。
同様に可燃ごみ不燃ごみもいけます。

Agenda  = require('agenda')
agenda  = new Agenda({db:{address: process.env.MONGO_URL}})

module.exports = (robot) ->
  numberOfTheWeek = (year, month, day) ->
    d = new Date(year, month, day)
    Math.floor((d.getDate() - d.getDay() + 12) / 7)

  agenda.define 'agenda:garbage:plastic-bottles', (job, done) ->
    robot.logger.info '@agenda:garbage:plastic-bottles'
    today = new Date()
    week = numberOfTheWeek(today.getFullYear(), today.getMonth() + 1, today.getDate())
    return unless (week == 1 or week == 3)
    robot.send {room: "***@conference.***.xmpp.slack.com"}, "今日はペットボトルを捨てる日です!"
    done()

  agenda.every('0 10 * * 3', 'agenda:garbage:plastic-bottles')
  agenda.start()

※ agenda(スケジューラ)を使っているのでmongodbが必要

6
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
6