Last active
August 18, 2023 12:09
-
-
Save robinsloan/a045d26c513681f13680f319fbfc84d2 to your computer and use it in GitHub Desktop.
Disable RTs from all the people you follow on Twitter.
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 "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