Skip to content
Fetching contributors…
Cannot retrieve contributors at this time
26 lines (24 sloc) 644 Bytes
# Description:
# Hubot searches the Library of Congress image archives
#
# Dependencies:
# None
#
# Configuration:
# None
#
# Commands:
# hubot locpix me <query> - Search the Library of Congress image archives
#
# Author:
# pj4533
module.exports = (robot) ->
robot.respond /locpix?(?: me)? (.*)/i, (msg) ->
q = escape(msg.match[1])
msg.http('http://www.loc.gov/pictures/search/?fo=json&fa=displayed:anywhere&q=' + q )
.get() (err, res, body) ->
response = JSON.parse(body)
images = response.results
if images.length > 0
image = msg.random images
msg.send image.image.full
Something went wrong with that request. Please try again.