Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

whitespace not mandatory #1

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,19 @@
"url": "https://github.com/hubot-scripts/hubot-uptimerobot/issues"
},
"dependencies": {
"coffee-script": "~1.6",
"array-query": "~0.1.0",
"uptime-robot": "0.0.1"
"coffee-script": "~1.6",
"uptime-robot": "^1.3.0"
},
"devDependencies": {
"mocha": "*",
"chai": "*",
"sinon-chai": "*",
"sinon": "*",
"grunt-contrib-watch": "~0.5.3",
"grunt-mocha-test": "~0.7.0",
"grunt-release": "~0.6.0",
"matchdep": "~0.1.2",
"grunt-contrib-watch": "~0.5.3"
"mocha": "*",
"sinon": "*",
"sinon-chai": "*"
},
"main": "index.coffee",
"scripts": {
Expand Down
16 changes: 13 additions & 3 deletions src/uptimerobot.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ module.exports = (robot) ->
.regex(new RegExp filter, 'i')
.on res

response_array = {attachments: []};
for monitor, i in monitors
name = monitor.friendlyname
url = monitor.url
Expand All @@ -53,18 +54,27 @@ module.exports = (robot) ->
when "2" then "up"
when "8" then "seems down"
when "9" then "down"
response_array.attachments[i] = {
"fallback": "#{status.toUpperCase()} <- #{url} (#{uptime}% uptime)",
"color": if monitor.status == "2" then "good" else "danger",
"title": url,
"title_link": url,
"footer": "#{uptime}% uptime",
"fields": if monitor.status == "2" then [] else [{"title": "Status", "value": status, "short": true}]
}

msg.send response_array

msg.send "#{status.toUpperCase()} <- #{url} (#{uptime}% uptime)"

robot.respond /uptime add-check (\S+)( as (.*))?$/i, (msg) ->
url = require('url').parse(msg.match[1])
friendlyName = msg.match[3] or url.href

# Check that url format is correct.
monitorUrl = url.href if url.protocol

# Create monitor
msg.http("http://api.uptimerobot.com/newMonitor")
msg.http("https://api.uptimerobot.com/newMonitor")
.query({
apiKey: apiKey
monitorFriendlyName: friendlyName
Expand Down
Loading