Skip to content

Instantly share code, notes, and snippets.

@jwoertink
Created November 15, 2011 18:54
Show Gist options
  • Save jwoertink/1367961 to your computer and use it in GitHub Desktop.
Save jwoertink/1367961 to your computer and use it in GitHub Desktop.
desc "Lookes for tweets with a random hashtag, and retweets"
task :retweet do
#Search twitter for loveadvice and loveadvicetv related tweets in the past X hours, and re-tweet them.
search = Twitter::Search.new
keywords = ["love", "loveadvice", "loveadvicetv", "relationhip", "marriage", "dating", "datingadvice"]
hashtag = keywords.sort_by { rand }.first
search.hashtag(hashtag).language("en").no_retweets.per_page(1)
results = search.fetch
tweet = results.first
client = Twitter::Client.new
retweet = "RT @#{tweet.from_user} #{tweet.text}"
retweet = (retweet.length > 140 ? retweet[0..136] + "..." : retweet)
client.update(retweet)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment