 
   robot.respond /stop thesis countdown/, (msg) ->
     msg.send "Ok, I stop that"
-    running = false
     clearInterval(deadlineIntervalId)
+    deadlineIntervalId = null

  printTimeBeforeDeadline = (msg) ->
    now = new Date()
    durationBeforeDeadline = deadline.getTime() - now.getTime()
    console.log(deadline)
    console.log(now)
    console.log("duration " + durationBeforeDeadline)
    if durationBeforeDeadline > 0
      nbOfDays = durationBeforeDeadline / dayDurationMilli
      nbOfHours = (durationBeforeDeadline % dayDurationMilli) / hourDurationMilli
      nbOfMinutes = (durationBeforeDeadline % hourDurationMilli) / minuteDurationMilli
      nbOfSeconds = (durationBeforeDeadline % minuteDurationMilli) / 1000
      # msg.send "Ok guys, " + nbOfDays + " days, " + nbOfHours + " hours, " + nbOfMinutes + " minutes and " + nbOfSeconds + "seconds left, good luck"
    else
      # msg.send "Thesis is over, YIIIIIHHAAAAA!!!"
      clearInterval(deadlineIntervalId)
      running = false

  robot.respond /start thesis countdown/, (msg) ->
    if running
      msg.send "It's already running"
      return

    running = true
    msg.send "Ok, I do that"
    printTimeBeforeDeadline(msg)
    deadlineIntervalId = setInterval() ->


module.exports = (robot) ->
  deadlineIntervalId = null
  deadline = new Date()
  deadline.setDate(15, 8, 2014)
  deadline.setUTCHours(14)
  deadline.setMinutes(0)
  dayDurationMilli = 24 * 3600 * 1000
