Last active
November 3, 2016 20:37
-
-
Save jjgrainger/2e7f814b2fc0113e3bfb79e00716c2fc to your computer and use it in GitHub Desktop.
Hubot deliver gifs of kittens
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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