Permalink
Browse files

add destiny.coffee script

  • Loading branch information...
1 parent 6b22f40 commit 65004b0a1daac041060254c5a7f7773dad7a646e @KuiKui KuiKui committed Nov 6, 2011
Showing with 15 additions and 0 deletions.
  1. +15 −0 src/scripts/destiny.coffee
View
15 src/scripts/destiny.coffee
@@ -0,0 +1,15 @@
+# Is the day ?
+#
+# is the <action> day ? - Returns if it's the day for your action.
+#
+module.exports = (robot) ->
+ robot.respond /is the (\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 the " + action + " day !"

0 comments on commit 65004b0

Please sign in to comment.