Created
June 12, 2014 21:38
-
-
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.
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: | |
# 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