Skip to content
This repository
file 30 lines (27 sloc) 0.794 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
# Description:
# Display a random quote or one from a specific person
#
# Dependencies:
# None
#
# Configuration:
# HUBOT_QUOTE_MAX_LINES
#
# Commands:
# hubot enlighten - random quote
# hubot quote - random quote
# hubot quote from <person> - quote from person
#
# Author:
# cldwalker

module.exports = (robot) ->
  robot.respond /enlighten|quote from (.*)|quote/i, (msg) ->
    params = {max_lines: process.env.HUBOT_QUOTE_MAX_LINES || '4'}
    if msg.match[1]
      params['source'] = msg.match[1].split(/\s+/).join('+')

    msg.http('http://www.iheartquotes.com/api/v1/random')
      .query(params)
      .get() (err, res, body) ->
        body = body.replace(/\s*\[\w+\]\s*http:\/\/iheartquotes.*\s*$/m, '')
        body = body.replace(/&quot;/g, "'")
        msg.send body
Something went wrong with that request. Please try again.