Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

15 lines (13 sloc) 0.5 kb
# 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}"
Jump to Line
Something went wrong with that request. Please try again.