Skip to content
This repository has been archived by the owner on Jun 8, 2023. It is now read-only.

Commit

Permalink
party_gifs.coffee - Make a GIF on the fly from search terms.
Browse files Browse the repository at this point in the history
  • Loading branch information
joshed-io committed Nov 23, 2012
1 parent fb430e7 commit 3660af8
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions 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.