This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Script to get Hubot's external IP address

Get the Hubot server's external IP address via jsonip.com
  • Loading branch information...
1 parent 4a308c7 commit 6646c40b80730cc79effb8028215ea15381262aa @ndrake ndrake committed Aug 7, 2012
Showing with 27 additions and 0 deletions.
  1. +27 −0 src/scripts/ip.coffee
View
@@ -0,0 +1,27 @@
+# Description:
+# Return Hubot's external IP address (via jsonip.com)
+#
+# Dependencies:
+# None
+#
+# Configuration:
+# None
+#
+# Commands:
+# hubot ip - Returns Hubot server's external IP address
+#
+# Author:
+# ndrake
+
+module.exports = (robot) ->
+ robot.respond /ip/i, (msg) ->
+ msg.http("http://jsonip.com")
+ .get() (err, res, body) ->
+ json = JSON.parse(body)
+ switch res.statusCode
+ when 200
+ msg.send "External IP address: #{json.ip}"
+ else
+ msg.send "There was an error getting external IP (status: #{res.statusCode})."
+
+

0 comments on commit 6646c40

Please sign in to comment.