Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

39 lines (33 sloc) 1.007 kB
# Description:
# Who doesnt love Penny Arcade?
#
# Dependencies:
# "htmlparser": "1.7.6"
# "soupselect: "0.2.0"
#
# Configuration:
# None
#
# Commands:
# hubot pa - The latest Penny Arcade comic
# hubot pa <date> - Penny Arcade comic from <date> - mm/dd/yyyy format
#
# Author:
# apblardo
htmlparser = require "htmlparser"
Select = require("soupselect").select
module.exports = (robot) ->
robot.respond /pa(\s(0?[1-9]|1[0-2]).(0?[1-9]|[1-2][0-9]|3[0-1]).(19\d{2}|20\d{2}))?$/i, (msg) ->
if msg.match[1] == undefined
date = ''
else
date = "#{msg.match[4]}/#{msg.match[2]}/#{msg.match[3]}/"
msg.http("http://penny-arcade.com/comic/#{date}")
.get() (err, res, body) ->
handler = new htmlparser.DefaultHandler()
parser = new htmlparser.Parser(handler)
parser.parseComplete(body)
img = Select handler.dom, ".comic img"
comic = img[0].attribs
msg.send comic.src
msg.send comic.alt
Jump to Line
Something went wrong with that request. Please try again.