Created
August 15, 2012 03:52
-
-
Save micmmakarov/3355673 to your computer and use it in GitHub Desktop.
Find random tweet and then translate it to italian and repost
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'twitter' | |
require 'google_translate' | |
# We using credentials of "Rails School" twitter account | |
Twitter.configure do |config| | |
# credentials here! | |
end | |
# for translator | |
translator = Google::Translator.new | |
tweets = Twitter.search("#barackobama").results | |
random_tweet_text = tweets.sample.text | |
piged_tweet = translator.translate("en", "it", random_tweet_text)[0] | |
hash_tags = "#international #railsschool" | |
message = piged_tweet.slice(0..(140 - hash_tags.size - 2)) | |
Twitter.update("#{message} #{hash_tags}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment