 
     gcal[userId].id        = userId
     gcal[userId].daysAhead = daysAhead
-    robot.reply "OK, your calendar, `gcal me` will show the next #{daysAhead} days."
+    msg.reply "OK, your calendar, `gcal me` will show the next #{daysAhead} days."
 
   # TODO: robot.respond /gcal auto/ # enable/disable auto away behavior
   # TODO: robot.respond /gcal whereabouts/ # where is everyone
   # TODO: for recurring, make sure I'm showing the next occurrence, and all after that
+  # TODO: set the cron interval for auto-away status updates
 
   # make every effort to return the correct timezone - http://momentjs.com/timezone/
   robot.respond /gcal timezone (.*)/, (msg)->

# Description:
#   Say Hi to Hubot.
#
# Dependencies:
#   None
#
# Configuration:
#   None
#
# Commands:
#   hubot hello - "hello!"
#   hubot orly - "yarly"
#
# Author:
#   tombell


module.exports = (robot) ->

  require('moment-timezone')
  # CronJob = require('cron').CronJob
  #
  # checkCalendars = new CronJob("0,5,10,15,20,25,30,35,40,45,50,55  * * * *", ()->
  #   # login to google calendars, refresh token if necessary
  #   #
  #   # for every user that is currently showing as available and has enabled gcal,
  #   #
  #   # robot.emit "googleapi:request",
  #   #   service: "analytics"
  #   #   version: "v3"
  #   #   endpoint: "management.profiles.list"
  #   #   params:                               # parameters to pass to API
  #   #   accountId: '~all'
  #   #   webPropertyId: '~all'
  #   #   callback: (err, data)->               # node-style callback
  #   #     return console.log(err) if err
  #   #     console.log data.items.map((item)->
  #   #     "#{item.name} - #{item.websiteUrl}"
  #   #     ).join("\n")
  #   #
  #   #   update their status.

  robot.respond /gcal calendar (.*)/i, (msg)->
    console.log msg


    gcal[userId].id       = userId
    gcal[userId].timeZone = timeZone
    msg.reply "OK, your calendar, `gcal me` will reflect your timzone, #{timeZone}."


  robot.respond /gcal me/i, (msg)->
