Skip to content
This repository
Browse code

add destiny.coffee script

  • Loading branch information...
commit 65004b0a1daac041060254c5a7f7773dad7a646e 1 parent 6b22f40
Denis Roussel KuiKui authored

Showing 1 changed file with 15 additions and 0 deletions. Show diff stats Hide diff stats

  1. +15 0 src/scripts/destiny.coffee
15 src/scripts/destiny.coffee
... ... @@ -0,0 +1,15 @@
  1 +# Is the day ?
  2 +#
  3 +# is the <action> day ? - Returns if it's the day for your action.
  4 +#
  5 +module.exports = (robot) ->
  6 + robot.respond /is the (\w+) day \?/i, (msg) ->
  7 + action = msg.match[1]
  8 + nbDay = Math.floor(new Date().getTime() / 1000 / 86400)
  9 + actionHash = action.length + action.charCodeAt(0) + action.charCodeAt(action.length - 1)
  10 + destiny = Math.cos(nbDay + actionHash) + 1
  11 + limit = (Math.sin(actionHash) + 1) / 2
  12 + if destiny > limit
  13 + msg.send "Sorry, it's not " + action + " day. But try tomorrow..."
  14 + else
  15 + msg.send "Yes, it's the " + action + " day !"

0 comments on commit 65004b0

Please sign in to comment.
Something went wrong with that request. Please try again.