hubot-scripts
Version:
Allows you to opt in to a variety of scripts
34 lines (31 loc) • 908 B
text/coffeescript
module.exports = (robot) ->
robot.respond /is (.*?) (up|down)(\?)?/i, (msg) ->
isUp msg, msg.match[1], (domain) ->
msg.send domain
isUp = (msg, domain, cb) ->
msg.http("http://isitup.org/#{domain}.json")
.header('User-Agent', 'Hubot')
.get() (err, res, body) ->
response = JSON.parse(body)
if response.status_code is 1
cb "#{response.domain} looks UP from here."
else if response.status_code is 2
cb "#{response.domain} looks DOWN from here."
else if response.status_code is 3
cb "Are you sure '#{response.domain}' is a valid domain?"
else
msg.send "Not sure, #{response.domain} returned an error."