Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Simplified commands to 'uptime' and 'uptime add' #557

Merged
merged 1 commit into from

3 participants

@Iristyle
  • The original command text was really painful to type
  • While there is already an 'uptime' command in uptime.coffee used to get the bot status, I don't think there's a reason that the commands can't overlap
  • uptime add now can parse a friendly name from the command, with a fallback to the url
@technicalpickles

While the original is definitely painful to type, some folks may be used to it, and would be surprised when it goes away after merging & releasing this. Could you please add responds for the original message to continue to be support, or at least to warn that it's been changed?

Also, I would consider changing uptime to uptimerobot to be inline with the backend service for this.

@Iristyle

I don't really agree with keeping the old lengthy command names, as it clutters the list from help and adds extra regexs to parse.

I also don't care for renaming the command to the longer uptimerobot from uptime (since the whole point was to shorten the absurd original strings).

But I made the changes anyway.

Hopefully this is pulled now.

@Iristyle Iristyle Added cmds 'uptimerobot', 'uptimerobot add'
- The original command text was really painful to type
- 'uptimerobot add' can parse a friendly name from the command,
with a fallback to the url
70b46d5
@tombell tombell merged commit 540c901 into github:master
@Iristyle Iristyle deleted the Iristyle:patch-10 branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jan 5, 2013
  1. @Iristyle

    Added cmds 'uptimerobot', 'uptimerobot add'

    Iristyle authored Iristyle committed
    - The original command text was really painful to type
    - 'uptimerobot add' can parse a friendly name from the command,
    with a fallback to the url
This page is out of date. Refresh to see the latest.
Showing with 13 additions and 4 deletions.
  1. +13 −4 src/scripts/uptime-robot.coffee
View
17 src/scripts/uptime-robot.coffee
@@ -8,7 +8,9 @@
# HUBOT_UPTIMEROBOT_APIKEY
#
# Commands:
+# hubot uptimerobot - Show the status of the monitored sites
# hubot what is the uptime of the monitored sites? - Show the status of the monitored sites
+# hubot uptimerobot add <url>[ as <friendlyname>] - Instructs uptime robot to monitor the <url>, optionally with a name
# hubot start monitoring the http uptime of <url> - Instructs uptime robot to monitor the <url>
#
# Author:
@@ -17,7 +19,7 @@
module.exports = (robot) ->
apikey = process.env.HUBOT_UPTIMEROBOT_APIKEY
- robot.respond /what is the uptime of the monitored sites?/i, (msg) ->
+ getMonitors = (msg) ->
msg.http("http://api.uptimerobot.com/getMonitors")
.query({ apiKey: apikey, logs: 0, format: "json", noJsonCallback: 1 })
.get() (err, res, body) ->
@@ -41,10 +43,11 @@ module.exports = (robot) ->
else if response.stat is "fail"
msg.send "Uhoh, #{response.message}";
+ robot.respond /what is the uptime of the monitored sites?/i, getMonitors
+ robot.respond /uptimerobot/i, getMonitors
- robot.respond /start monitoring the http uptime of (.*)$/i, (msg) ->
- monitorUrl = msg.match[1]
- monitorFriendlyName = msg.match[1]
+ newMonitor = (monitorUrl, monitorFriendlyName) ->
+ monitorFriendlyName ?= monitorUrl
msg.http("http://api.uptimerobot.com/newMonitor")
.query({ apiKey: apikey, monitorFriendlyName: monitorFriendlyName, monitorURL: monitorUrl, monitorType: 1, format: "json", noJsonCallback: 1 })
.get() (err, res, body) ->
@@ -55,3 +58,9 @@ module.exports = (robot) ->
if response.stat is "fail"
msg.send "#{response.message}"
+
+ robot.respond /start monitoring the http uptime of (.*)$/i, (msg) ->
+ newMonitor(msg.match[1], null)
+ robot.respond /uptimerobot add (http(s?)\:\/\/\S+)( as (.+))?/i, (msg) ->
+ newMonitor(msg.match[1], msg.match[4])
+
Something went wrong with that request. Please try again.