Skip to content
Newer
Older
100644 26 lines (24 sloc) 644 Bytes
a8ef8bb @pj4533 added locpix
pj4533 authored Dec 15, 2012
1 # Description:
2 # Hubot searches the Library of Congress image archives
3 #
4 # Dependencies:
5 # None
6 #
7 # Configuration:
8 # None
9 #
10 # Commands:
db738b7 @pj4533 just added description
pj4533 authored Dec 15, 2012
11 # hubot locpix me <query> - Search the Library of Congress image archives
a8ef8bb @pj4533 added locpix
pj4533 authored Dec 15, 2012
12 #
13 # Author:
14 # pj4533
15
16 module.exports = (robot) ->
436ee29 @pj4533 fixed matching added some quick and dirty error checking
pj4533 authored Dec 15, 2012
17 robot.respond /locpix?(?: me)? (.*)/i, (msg) ->
18 q = escape(msg.match[1])
84de32e @pj4533 fix for locpix script
pj4533 authored Dec 16, 2012
19 msg.http('http://www.loc.gov/pictures/search/?fo=json&fa=displayed:anywhere&q=' + q )
a8ef8bb @pj4533 added locpix
pj4533 authored Dec 15, 2012
20 .get() (err, res, body) ->
21 response = JSON.parse(body)
22 images = response.results
23 if images.length > 0
24 image = msg.random images
25 msg.send image.image.full
Something went wrong with that request. Please try again.