Skip to content

Instantly share code, notes, and snippets.

@jjgrainger
Last active November 3, 2016 20:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jjgrainger/2e7f814b2fc0113e3bfb79e00716c2fc to your computer and use it in GitHub Desktop.
Save jjgrainger/2e7f814b2fc0113e3bfb79e00716c2fc to your computer and use it in GitHub Desktop.
Hubot deliver gifs of kittens
# Description:
# Feeling down? Boost your mood with some Kitten Therapy!
#
# Dependencies:
# None
#
# Configuration:
# GIPHY_API_KEY - Your Giphy API key
#
# Commands:
# hubot kittens - Returns a random gif of cute kittens
module.exports = (robot) ->
# Giphy API url with key and tag
# this example uses the Giphy Public Beta API Key, its recommended
# you request a production key when needed https://github.com/Giphy/GiphyAPI#access-and-api-keys
giphy_api_key = process.env.GIPHY_API_KEY || 'dc6zaTOxFJmzC'
giphy = 'http://api.giphy.com/v1/gifs/random?tag=kittens&api_key=' + giphy_api_key
# respond to 'hubot kittens'
robot.respond /kittens/i, (msg) ->
robot.http(giphy).get() (err, res, body) ->
data = JSON.parse body
url = data.data.image_url
msg.send url
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment