Skip to content

Instantly share code, notes, and snippets.

@nategrieb
Created February 4, 2015 23:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nategrieb/d0bd735c34e1870b14d0 to your computer and use it in GitHub Desktop.
Save nategrieb/d0bd735c34e1870b14d0 to your computer and use it in GitHub Desktop.
# Description:
# Do something when an alert is received on the timeline
#
# Dependencies:
# None
#
# Configuration:
# None
#
# Commands:
# victorops alert <alert_json>
TextMessage = require('hubot').TextMessage
module.exports = (robot) ->
robot.respond /VictorOps alert (.*)/i, (msg) ->
alert = JSON.parse msg.match[1]
for annotation in alert.ANNOTATIONS when annotation[0] == "HUBOT COMMAND"
command = alert[annotation[1]]
user = robot.brain.userForId "VictorOps"
console.log "Found hubot command in annotation: #{command}"
msg.send "Auto running command from annotation '#{command}'"
robot.receive new TextMessage user, "hubot #{command}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment