Skip to content

Instantly share code, notes, and snippets.

@donpdonp
Last active August 29, 2015 14:01
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 donpdonp/c970a30a672f4742f727 to your computer and use it in GitHub Desktop.
Save donpdonp/c970a30a672f4742f727 to your computer and use it in GitHub Desktop.
neuronbot bitbucket
function(msg) {
var override = false;
if(/^bitbucket$/.test(msg.message)) {
override = true;
}
if(override || (msg.type == "ticktock" && (new Date(Date.parse(msg.message))).getMinutes() % 10 == 0) ) {
var bitbucket_json = http.get("http://status.bitbucket.org/?format=json")
var bitbucket = JSON.parse(bitbucket_json)
var key = 'bitbucket:status'
var old_json = db.get(key)
var old_bitbucket = old_json ? JSON.parse(old_json) : {status:{indicator: "none"}}
if(old_bitbucket.status.indicator != bitbucket.status.indicator) {
db.set(key, bitbucket_json)
var report
if(bitbucket.status.indicator == "major") {
report = "Bitbucket: "+bitbucket.status.description
}
if(old_bitbucket.status.indicator == "major" && bitbucket.status.indicator == "none") {
report = "Bitbucket issue resolved. Status is back to normal."
}
if(report) {
return {target:"#pdxbots", message:report}
}
}
if(override){
return 'Bitbucket report: '+bitbucket.status.description
}
}
function status(json) {
json.components.map(function(c){if(c.status == "major_outage"){return c.description}})
return "Major outage in: "+json.join(',')
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment