Skip to content

Instantly share code, notes, and snippets.

@jqtrde
Forked from robinsloan/shh.rb
Created March 8, 2018 16:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jqtrde/0ddd3dda81bb26abba02641829f130fe to your computer and use it in GitHub Desktop.
Save jqtrde/0ddd3dda81bb26abba02641829f130fe to your computer and use it in GitHub Desktop.
Disable RTs from all the people you follow on Twitter.
require "rubygems"
require "twitter"
# get these from apps.twitter.com
CONSUMER_KEY = "foo"
CONSUMER_SECRET = "bar"
OAUTH_TOKEN = "blee"
OAUTH_TOKEN_SECRET = "baz"
TWITTER_USER = "your_username" # needs to be the one associated with keys above
client = Twitter::REST::Client.new do |config|
config.consumer_key = CONSUMER_KEY
config.consumer_secret = CONSUMER_SECRET
config.access_token = OAUTH_TOKEN
config.access_token_secret = OAUTH_TOKEN_SECRET
end
following_ids = client.friend_ids(TWITTER_USER).to_a
puts "🙉"
following_ids.each do |id|
begin
puts "Disabling RTs from your pal #{client.user(id).screen_name}"
client.friendship_update(client.user(id), {:retweets => false})
rescue Twitter::Error::TooManyRequests => error
puts "Got an error, probably rate-limiting... waiting #{error.rate_limit.reset_in} seconds to try again"
sleep(error.rate_limit.reset_in)
retry
end
end
puts "Done!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment