Skip to content
This repository has been archived by the owner on Jun 8, 2023. It is now read-only.

Commit

Permalink
don't crash if no tweets are found
Browse files Browse the repository at this point in the history
  • Loading branch information
atmos committed Oct 28, 2011
1 parent 4b478a6 commit c5d1ab7
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/scripts/tweet.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,9 @@ module.exports = (robot) ->
.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}"

if tweets.results? and tweets.results.length > 0
tweet = msg.random tweets.results
msg.send "http://twitter.com/#!/#{tweet.from_user}/status/#{tweet.id_str}"
else
msg.reply "No one is tweeting about that."

0 comments on commit c5d1ab7

Please sign in to comment.