Skip to content
This repository has been archived by the owner. It is now read-only.
Branch: master
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
41 lines (34 sloc) 940 Bytes
# Description:
# A way to search images on
# Configuration:
# Commands:
# hubot gif me <query> - Returns an animated gif matching the requested search term.
giphy =
api_key: process.env.HUBOT_GIPHY_API_KEY
base_url: ''
module.exports = (robot) ->
robot.respond /(gif|giphy)( me)? (.*)/i, (msg) ->
giphyMe msg, msg.match[3], (url) ->
msg.send url
giphyMe = (msg, query, cb) ->
endpoint = '/gifs/search'
url = "#{giphy.base_url}#{endpoint}"
q: query
api_key: giphy.api_key
.get() (err, res, body) ->
response = undefined
response = JSON.parse(body)
images =
if images.length > 0
image = msg.random images
cb image.images.original.url
catch e
response = undefined
cb 'Error'
return if response is undefined
You can’t perform that action at this time.