Created
September 3, 2013 20:42
-
-
Save ewdurbin/6429299 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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