Skip to content

Instantly share code, notes, and snippets.

@1syo
Created May 8, 2015 10:43
Show Gist options
  • Save 1syo/7ee665d336ba0882fdd0 to your computer and use it in GitHub Desktop.
Save 1syo/7ee665d336ba0882fdd0 to your computer and use it in GitHub Desktop.
# Description:
# airbrake
HUBOT_AIRBRAKE_KEY=process.env.HUBOT_AIRBRAKE_KEY
module.exports = (robot) ->
robot.router.post "/hubot/airbrake/:room", (req, res) ->
data = { project_id: req.body.error.project.id, notice_id: req.body.error.last_notice.id, group_id: req.body.error.id }
robot.brain.set('airbrake', data)
res.end "Done"
robot.respond /a(?:irbrake)? last( \| (general|backtrace|params|env|session|context))?/i, (msg) ->
msg.send msg.match[2]
# airbrake = robot.brain.get('airbrake')
# url = "https://airbrake.io/api/v3/projects/#{airbrake.project_id}/groups/#{airbrake.group_id}/notices/#{airbrake.notice_id}?key=#{HUBOT_AIRBRAKE_KEY}"
# msg.http(url).get() (err, res, body) ->
# unless err
# msg.send body
# else
# msg.send 'error!'
robot.respond /a(?:irbrake)? projects/i, (msg) ->
url = "https://airbrake.io/api/v3/projects?key=#{HUBOT_AIRBRAKE_KEY}"
msg.http(url).get() (err, res, body) ->
unless err
msg.send body
else
msg.send 'error!'
robot.respond /a(?:irbrake)? errors ([^\s]+)( \| (.+))?/i, (msg) ->
# url = "https://airbrake.io/api/v3/projects/#{airbrake.project_id}/groups/#{airbrake.group_id}?key=#{HUBOT_AIRBRAKE_KEY}"
msg.send msg.match[1], msg.match[3]
robot.respond /a(?:irbrake)? notice ([^\s]+)( \| (general|backtrace|params|env|session|context))?/i, (msg) ->
# url = "https://airbrake.io/api/v3/projects/#{airbrake.project_id}/groups/#{airbrake.group_id}?key=#{HUBOT_AIRBRAKE_KEY}"
msg.send msg.match[1], msg.match[3]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment