title: Using node-cron with coffeescript
body: <p>I'm trying to write a coffeescript script for hubot that makes use of node-cron. I found an example like so and it works great:</p>
  
  <pre><code>module.exports = (robot) -&gt;
    cronJob = require('cron').CronJob
    new cronJob('0 */1 * * * *', everyMinute(robot), null, true)
  
  everyMinute = (robot) -&gt;
    -&gt; robot.messageRoom '#billing', 'hey brah!'
  </code></pre>
  
  <p>However, this is my current script. It doesn't ever seem to fire the node event. I'm basically trying to check the status of a remote API every minute and set the result in hubot's brain. What am I doing wrong here? This is basically the first coffeescript I've ever written so still find my feet.</p>
  
  <pre><code>module.exports = (robot) -&gt;
  
    cronJob = require('cron').CronJob
    new cronJob('0 */1 * * * *', getOnPoint, null, true)
  
    getOnPoint = -&gt;
      robot.http("https://#{pagerDutyDomain}.pagerduty.com/api/v1/schedules/#{pagerDutyService}")
      .headers(Authorization: "Token token=\"#{pagerDutyToken}\"", Accept: 'application/json')
        .query(since: '2015-11-23T21:15:49Z', until: '2015-11-23T22:15:49Z')
        .get() (err,res,body) -&gt;
          if res.statusCode isnt 200
            msg.send "Request didn't come back HTTP 200 :( got back #{body}"
            return
  
          json = JSON.parse(body)
          onpoint_person = json.schedule.final_schedule.rendered_schedule_entries[0].user.email
          robot.logger.debug "Setting onpoint to #{onpoint_person}"
          robot.brain.set 'onpoint_person', onpoint_person.split("@")[0]
  </code></pre>
  
  <p>I looked at the JS that the coffeescript compiled to and it's clear that the way I'm declaring the function is important, but I have no idea why.</p>
  
  <p>Any help much appreciated.</p>