Skip to content

Instantly share code, notes, and snippets.

@AgentO3
Created May 7, 2014 14:12
Show Gist options
  • Save AgentO3/a37a94f0d3daabcb5332 to your computer and use it in GitHub Desktop.
Save AgentO3/a37a94f0d3daabcb5332 to your computer and use it in GitHub Desktop.
# 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