           body: JSON.stringify
            entity_id: "slack-ops"
            message_type: "critical"
-           entity_display_name: "Paged by @#{msg.message.user.name} in ##{room}"
+           entity_display_name: "Paged by @#{msg.message.user.name} in ##{room.name}"
            state_message: message
         .then (res) ->
           checkStatus res

        [ __, person ] = oncall.summary.match /(?:OVERRIDE:\s)?(.*)/
      cb person

  robot.respond /page oncall(?:\s+(.*))?/, (msg) ->
    [ __, message ] = msg.match
    room = msg.message.room
    team = teams[room]
    return invalidChannel msg unless team

    whoIsOncall team, (person) ->

fuzzy = require 'fuzzy'

module.exports = (robot) ->
  users = robot.brain.users() or @robot.adapter.client.rtm.dataStore.users
  url = process.env.HUBOT_VICTOROPS_POST_URL
  teams = JSON.parse process.env.HUBOT_VICTOROPS_TEAMS_MAP
  calendars = JSON.parse process.env.HUBOT_VICTOROPS_TEAMS_ICAL

  getRoom = (context) ->
    room = robot.adapter.client.rtm.dataStore.getChannelOrGroupByName context.message.room
    room = robot.adapter.client.rtm.dataStore.getChannelGroupOrDMById context.message.room unless room
    room

  parseJSON = (response) ->
    return response.json()
