Skip to content

Commit

Permalink
Add joke me from /r/jokes
Browse files Browse the repository at this point in the history
  • Loading branch information
tombell committed May 10, 2012
1 parent c9c0595 commit 4f06097
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/scripts/reddit-jokes.coffee
@@ -0,0 +1,15 @@
# joke me - Pull a random joke from /r/jokes

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.selftext
msg.send joke

catch ex
msg.send "Erm, something went EXTREMELY wrong - #{ex}"

0 comments on commit 4f06097

Please sign in to comment.