Skip to content

Instantly share code, notes, and snippets.

@ZeroPivot
Forked from robinsloan/shh.rb
Created November 28, 2020 21:57
Show Gist options
  • Save ZeroPivot/c921af5d60d50e2b41d76211458adfd5 to your computer and use it in GitHub Desktop.
Save ZeroPivot/c921af5d60d50e2b41d76211458adfd5 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
unless client.user(id).to_s == "17275139" # can't miss my dad's retweets 😮
puts "Disabling RTs from your pal #{client.user(id).screen_name}"
client.friendship_update(client.user(id), {:retweets => false})
end
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