Skip to content
This repository
file 29 lines (26 sloc) 0.662 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
# Description:
# None
#
# Dependencies:
# None
#
# Configuration:
# None
#
# Commands:
# hubot fml - A random message from fmylife.com
#
# Author:
# artfuldodger

module.exports = (robot) ->
  robot.respond /fml/i, (msg) ->
    fml msg

fml = (msg) ->
  msg
    .http('http://ajax.googleapis.com/ajax/services/feed/load?v=1.0&num=10&q=http://feeds.feedburner.com/fmylife')
      .get() (err, res, body) ->
        fmls = JSON.parse(body)
        random = Math.floor(Math.random() * fmls.responseData.feed.entries.length)
        text = fmls.responseData.feed.entries[random].content
        text = text[0..text.indexOf('<img')-1]
        msg.send text
Something went wrong with that request. Please try again.