Skip to content
This repository
Jonas Baumann March 06, 2013
file 27 lines (25 sloc) 0.712 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
# Description:
# Is it the day?
#
# Dependencies:
# None
#
# Configuration:
# None
#
# Commands:
# hubot is it <action> day ? - Returns if it's the day for your action
#
# Author:
# KuiKui
             
module.exports = (robot) ->
  robot.respond /is it (\w+) day ?\?/i, (msg) ->
    action = msg.match[1]
    nbDay = Math.floor(new Date().getTime() / 1000 / 86400)
    actionHash = action.length + action.charCodeAt(0) + action.charCodeAt(action.length - 1)
    destiny = Math.cos(nbDay + actionHash) + 1
    limit = (Math.sin(actionHash) + 1) / 2
    if destiny > limit
      msg.send "Sorry, it's not " + action + " day. But try tomorrow..."
    else
      msg.send "Yes, it's " + action + " day !"
Something went wrong with that request. Please try again.