<commit_before># Description:
#   Random jokes from /r/jokes
#
# Dependencies:
#   None
#
# Configuration:
#   None
#
# Commands:
#   hubot joke me - Pull a random joke from /r/jokes
#
# Author:
#   tombell

module.exports = (robot) ->

  robot.respond /joke me/i, (msg) ->
    msg.http('http://www.reddit.com/r/jokes.json')
      .get() (err, res, body) ->
        try
          data = JSON.parse body
          children = data.data.children
          joke = msg.random(children).data

          if joke.selftext.match /^\.\.\./
            joketext = joke.title.replace(/\*\.\.\.$/,'') + ' ' + joke.selftext.replace(/^\.\.\.\s*/, '')
          else
            joketext = joke.selftext

          msg.send joketext.trim()

        catch ex
          msg.send "Erm, something went EXTREMELY wrong - #{ex}"<commit_msg>master: Removing conditional from reddit jokes so that the title is always included<commit_after># Description:
#   Random jokes from /r/jokes
#
# Dependencies:
#   None
#
# Configuration:
#   None
#
# Commands:
#   hubot joke me - Pull a random joke from /r/jokes
#
# Author:
#   tombell

module.exports = (robot) ->

  robot.respond /joke me/i, (msg) ->
    msg.http('http://www.reddit.com/r/jokes.json')
      .get() (err, res, body) ->
        try
          data = JSON.parse body
          children = data.data.children
          joke = msg.random(children).data


          joketext = joke.title.replace(/\*\.\.\.$/,'') + ' ' + joke.selftext.replace(/^\.\.\.\s*/, '')

          msg.send joketext.trim()

        catch ex
          msg.send "Erm, something went EXTREMELY wrong - #{ex}"
{'fraction_non_alphanumeric': 0.16521739130434782, 'fraction_numerical': 0.0, 'mean_word_length': 1.9833333333333334, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4309729', 'n_tokens_mistral': 551, 'n_tokens_neox': 545, 'n_words': 126}