Skip to content

Instantly share code, notes, and snippets.

@ewdurbin
Created September 3, 2013 20:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ewdurbin/6429299 to your computer and use it in GitHub Desktop.
Save ewdurbin/6429299 to your computer and use it in GitHub Desktop.
url = require('url')
querystring = require('querystring')
component_name = (organization_id, component_id) ->
http.get("http://#{organization_id}.statuspage.io/index.json", (res) ->
payload = JSON.parse res.body.payload
component_name_str = ""
components = payload.components
for comp in components
if comp.id == component_id
component_name_str = comp.name
return component_name_str
)
module.exports = (robot) ->
robot.router.post '/hubot/statuspage', (req, res) ->
query = querystring.parse url.parse(req.url).query
res.end JSON.stringify {
received: true
}
user = {}
user.room = query.room if query.room
user.type = query.type if query.type
payload = JSON.parse req.body.payload
organization_id = payload.organization.id
component_id = payload.component_update.component_id
name = component_name organization_id, component_id
robot.send user, "#{name} changed status to #{payload.component_update.new_status} from #{payload.component_update.old_status} http://status.kissmetrics.com"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment