Skip to content
This repository
file 37 lines (32 sloc) 0.937 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
# Description:
# HOLY FUCKING MINDFUCK!
#
# Dependencies:
# None
#
# Configuration:
# None
#
# Commands:
# hubot buscemi me <url> - Adds Steve Buscemi eyes to the specified URL
# hubot buscemi me <query> - Searches Google Images for the specified query and buscemi's it
#
# Author:
# dylanegan

module.exports = (robot) ->
  robot.respond /buscemi?(?: me)? (.*)/i, (msg) ->
    buscemi = "http://buscemi.heroku.com?src="
    imagery = msg.match[1]

    if imagery.match /^https?:\/\//i
      msg.send "#{buscemi}#{imagery}"
    else
      imageMe msg, imagery, (url) ->
        msg.send "#{buscemi}#{url}"

imageMe = (msg, query, cb) ->
  msg.http('http://ajax.googleapis.com/ajax/services/search/images')
    .query(v: "1.0", rsz: '8', q: query)
    .get() (err, res, body) ->
      images = JSON.parse(body)
      images = images.responseData.results
      image = msg.random images
      cb "#{image.unescapedUrl}#.png"

Something went wrong with that request. Please try again.