Skip to content
This repository
Fetching contributors…

Cannot retrieve contributors at this time

file 14 lines (13 sloc) 0.5 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14
# Display a random tweet from twitter about a subject
#
# hubot <keyword> tweet - Returns a link to a tweet about <keyword>
#

module.exports = (robot) ->
  robot.respond /(.*) tweet/i, (msg) ->
    search = escape(msg.match[1])
    msg.http('http://search.twitter.com/search.json')
      .query(q: search)
      .get() (err, res, body) ->
        tweets = JSON.parse(body)
        tweet = msg.random tweets.results
        msg.send "http://twitter.com/#!/#{tweet.from_user}/status/#{tweet.id_str}"
Something went wrong with that request. Please try again.