Skip to content
This repository
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 16 lines (15 sloc) 0.608 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
# Is it the day ?
#
# is it <action> day ? - Returns if it's the day for your action.
#
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.