Last active
August 29, 2015 14:01
-
-
Save donpdonp/c970a30a672f4742f727 to your computer and use it in GitHub Desktop.
neuronbot bitbucket
This file contains 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
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