Skip to content
This repository
Fetching contributors…

Cannot retrieve contributors at this time

file 26 lines (24 sloc) 0.632 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
# Description:
# Displays a random pizza gif from animatedpizzagifs.com
#
# Dependencies:
# "jsdom": "~0.2.13"
#
# Configuration:
# None
#
# Commands:
# hubot pizza - Show a pizza gif
#
# Author:
# iangreenleaf

jsdom = require "jsdom"
PIZZA = "http://animatedpizzagifs.com"

module.exports = (robot) ->
  robot.respond /pizza/i, (msg) ->
    msg.http(PIZZA)
      .path("/")
      .get() (err, res, body) ->
        document = jsdom.jsdom body, null, features: { "QuerySelector": true, 'ProcessExternalResources': false }
        img = msg.random document.querySelectorAll "li img"
        msg.send "#{PIZZA}/#{img.src}"
Something went wrong with that request. Please try again.