Created
May 7, 2014 14:12
-
-
Save AgentO3/a37a94f0d3daabcb5332 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Description: | |
# Randomly selects a photo and caption from dbareactions.com and posts it to your chat | |
# | |
# Dependencies: | |
# string": "~1.8.1" | |
# | |
# Configuration: | |
# None | |
# | |
# Commands: | |
# hubot dba me - A randomly selects a photo and caption from dbareactions.com | |
# | |
# Author: | |
# @AgentO3 | |
S = require('string'); | |
url = 'http://dbareactions.com/api/read/json?debug=1&type=photo&num=50' | |
module.exports = (robot) -> | |
robot.respond /dba?(?: me)?$/i, (msg) -> | |
reqPics(url, msg) | |
reqPics = (url, msg) -> | |
msg.http(url) | |
.get() (err, res, body) -> | |
pick = msg.random(JSON.parse(body).posts) | |
msg.send pick["photo-url-400"] | |
msg.send S(pick["photo-caption"]).stripTags().decodeHTMLEntities().s |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment