Created
December 18, 2014 19:41
-
-
Save gswallow/8a97c8ebe574036a897c to your computer and use it in GitHub Desktop.
danzig bomb
This file contains hidden or 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 | |
# Grab a Glenn Danzig image. | |
# | |
# Dependencies: | |
# None | |
# | |
# Configuration: | |
# None | |
# | |
module.exports = (robot) -> | |
robot.respond /danzig me( (\d+)?)?/i, (msg) -> | |
count = msg.match[2] || 1 | |
danzigMe msg, count, (url) -> # WTF? | |
danzigMe = (msg, count) -> | |
q = v: '1.0', rsz: 8, q: 'Glenn Danzig', 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 | |
for i in [1..count] by 1 | |
rand = Math.floor(Math.random() * 8) | |
msg.send images[rand].unescapedUrl |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment