Skip to content

Instantly share code, notes, and snippets.

@gswallow
Created December 18, 2014 19:41
Show Gist options
  • Save gswallow/8a97c8ebe574036a897c to your computer and use it in GitHub Desktop.
Save gswallow/8a97c8ebe574036a897c to your computer and use it in GitHub Desktop.
danzig bomb
# 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