Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #3 from sleekslush/master

Shorten URLs using bit.ly
  • Loading branch information...
commit ec50aa06cbc40ba360652e7dba65a7e788df5d77 2 parents aec7417 + acf1b20
Zakaria Zajac authored
Showing with 16 additions and 0 deletions.
  1. +16 −0 src/scripts/shorten.coffee
View
16 src/scripts/shorten.coffee
@@ -0,0 +1,16 @@
+# Shorten URLs with bit.ly
+#
+# (bitly|shorten) me <url> - Shorten the URL using bit.ly
+
+module.exports = (robot) ->
+ robot.respond /(bitly|shorten) me (.*)$/, (msg) ->
+ msg
+ .http("http://api.bitly.com/v3/shorten")
+ .query
+ login: process.env.HUBOT_BITLY_USERNAME
+ apiKey: process.env.HUBOT_BITLY_API_KEY
+ longUrl: msg.match[2]
+ format: "json"
+ .get() (err, res, body) ->
+ response = JSON.parse body
+ msg.send if response.status_code is 200 then response.data.url else response.status_txt
Please sign in to comment.
Something went wrong with that request. Please try again.