-
-
Save coderanger/6429373 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, cb) -> | |
http.get"http://#{organization_id}.statuspage.io/index.json", (res) -> | |
payload = JSON.parse(res.body.payload) | |
for comp in payload.components | |
if comp.id == component_id | |
return cb(comp.name) | |
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 | |
component_name organization_id, component_id, (name)-> | |
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