 
     "#{inc.incident_number}: #{inc.created_on} #{summary} #{assigned_to}\n"
 
-  updateIncidents = (msg, incidentNumbers, status) ->
+  updateIncidents = (msg, incidentNumbers, statusFilter, updatedStatus) ->
     withPagerDutyUsers msg, (users) ->
       requesterId = pagerDutyUserId(msg, users)
       return unless requesterId
 
-      pagerDutyIncidents msg, "triggered,acknowledged", (incidents) ->
+      pagerDutyIncidents msg, statusFilter, (incidents) ->
         foundIncidents = []
         for incident in incidents
-          if incidentNumbers.indexOf("#{incident.incident_number}")
+          # FIXME this isn't working very consistently
+          if incidentNumbers.indexOf(incident.incident_number) > -1
             foundIncidents.push(incident)
 
         if foundIncidents.length == 0
-          msg.reply "Couldn't find incident #{incident_number}"
+          msg.reply "Couldn't find incidents #{incidentNumbers.join(', ')} in #{inspect incidents}"
         else
           # loljson
           data = {

  robot.respond /who('s|s| is)? (on call|oncall)/i, (msg) ->
    withCurrentOncall msg, (username) ->
      msg.reply "#{username} is on call"

  missingEnvironmentForApi = (msg) ->
    missingAnything = false

    pagerDutyIntegrationAPI msg, "trigger", description, (json) ->
      msg.reply "#{json.status}, key: #{json.incident_key}"

  robot.respond /(?:pager|major)(?: me)? ack(?:nowledge)? (.+)$/i, (msg) ->
    incidentNumbers = parseIncidentNumbers(msg.match[1])

    # only acknowledge triggered things, since it doesn't make sense to re-acknowledge if it's already in re-acknowledge
    # if it ever doesn't need acknowledge again, it means it's timed out and has become 'triggered' again anyways
    updateIncidents(msg, incidentNumbers, 'triggered,acknowledged', 'acknowledged')

  robot.respond /(pager|major)( me)? ack(nowledge)?$/i, (msg) ->
    pagerDutyIncidents msg, 'triggered,acknwowledged', (incidents) ->
      incidentNumbers = (incident.incident_number for incident in incidents)
      if incidentNumbers.length < 1
        msg.send "Nothing to acknowledge"
        return

      # only acknowledge triggered things
      updateIncidents(msg, incidentNumbers, 'triggered,acknowledged', 'acknowledged')

  robot.respond /(?:pager|major)(?: me)? res(?:olve)?(?:d)? (.+)$/i, (msg) ->
    incidentNumbers = parseIncidentNumbers(msg.match[1])

    # allow resolving of triggered and acknowedlge, since being explicit
    updateIncidents(msg, incidentNumbers, 'triggered,acknowledged', 'resolved')

  robot.respond /(pager|major)( me)? res(olve)?(d)?$/i, (msg) ->
    pagerDutyIncidents msg, "acknowledged", (incidents) ->
      incidentNumbers = (incident.incident_number for incident in incidents)
      if incidentNumbers.length < 1
        msg.send "Nothing to resolve"
        return

      # only resolve things that are acknowledged 
      updateIncidents(msg, incidentNumbers, 'acknowledged', 'resolved')

  robot.respond /(pager|major)( me)? notes (.+)$/i, (msg) ->
    incidentId = msg.match[3]
