Skip to content
Browse files

party_gifs.coffee - Make a GIF on the fly from search terms.

  • Loading branch information...
1 parent fb430e7 commit 3660af83e2a5ee9d22befadc863db13539b2db85 @dzello dzello committed
Showing with 35 additions and 0 deletions.
  1. +35 −0 src/scripts/party_gifs.coffee
View
35 src/scripts/party_gifs.coffee
@@ -0,0 +1,35 @@
+# Description:
+# party_gifs.coffee - Make a GIF on the fly from search terms.
+#
+# Dependencies:
+# None
+#
+# Configuration:
+# None
+#
+# Commands:
+# hubot gif me <query> - Create a gif using images from the web.
+# hubot pty me <query> - Alias for 'gif'.
+#
+# Notes:
+# GIFs created by the gifs.pty.io API.
+# Images come from the Google Image API.
+#
+# Author:
+# dzello
+
+module.exports = (robot) ->
+ robot.respond /(gif|pty)( me)? (.*)/i, (msg) ->
+ gifMe(msg, msg.match[3])
+
+gifMe = (msg, query) ->
+ url = "http://gifs.pty.io/#{encodeURIComponent(query)}.gif"
+ msg.http(url)
+ .head() (err, res, body) ->
+ if res.statusCode == 404
+ msg.send "Couldn't find any images."
+ else if err or res.statusCode > 404
+ msg.send "An error occurred creating that GIF."
+ else
+ msg.send url
+

0 comments on commit 3660af8

Please sign in to comment.
Something went wrong with that request. Please try again.