Skip to content

Instantly share code, notes, and snippets.

@rosemarydotworld
Created June 12, 2014 21:38
Show Gist options
  • Save rosemarydotworld/592a85fdcef420b2bd9d to your computer and use it in GitHub Desktop.
Save rosemarydotworld/592a85fdcef420b2bd9d to your computer and use it in GitHub Desktop.
Babygoat Me Lite, a Hubot script that grabs baby goat images from GIS, AKA the most important code I have ever cobbled together.
# Description:
# Baby goats, motherfucker
#
# Dependencies:
# None
#
# Configuration:
# None
#
# Commands:
# hubot babygoat me - Get a baby goat
module.exports = (robot) ->
robot.respond /babygoat me/i, (msg) ->
imageMe msg, "baby goat", (url) ->
msg.send url
imageMe = (msg, query, cb) ->
q = v: '1.0', rsz: '8', q: query, safe: 'active'
msg.http('http://ajax.googleapis.com/ajax/services/search/images')
.query(q)
.get() (err, res, body) ->
images = JSON.parse(body)
images = images.responseData?.results
if images?.length > 0
image = msg.random images
cb "#{image.unescapedUrl}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment