Last active
March 10, 2018 18:58
-
-
Save scottmuc/11224684 to your computer and use it in GitHub Desktop.
A script to unfollow everyone on Twitter and another to remove retweets from your Twitter timeline
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' | |
$stdout.sync = true | |
def rate_limited | |
begin | |
yield | |
rescue Twitter::Error::TooManyRequests => error | |
sleep error.rate_limit.reset_in + 1 | |
retry | |
end | |
end | |
client = Twitter::REST::Client.new do |config| | |
config.consumer_key = ENV.fetch('TW_CONSUMER_KEY') | |
config.consumer_secret = ENV.fetch('TW_CONSUMER_SECRET') | |
config.access_token = ENV.fetch('TW_ACCESS_TOKEN') | |
config.access_token_secret = ENV.fetch('TW_ACCESS_TOKEN_SECRET') | |
end | |
rate_limited do | |
client.friends.each do |user| | |
rate_limited do | |
client.friendship_update(user, :retweets => false ) | |
end | |
print "." | |
end | |
end | |
puts "\nEnjoy the quieter twitter stream!" |
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' | |
client = Twitter::REST::Client.new do |config| | |
config.consumer_key = ENV.fetch('TW_CONSUMER_KEY') | |
config.consumer_secret = ENV.fetch('TW_CONSUMER_SECRET') | |
config.access_token = ENV.fetch('TW_ACCESS_TOKEN') | |
config.access_token_secret = ENV.fetch('TW_ACCESS_TOKEN_SECRET') | |
end | |
BATCH_SIZE = 30 | |
while true do | |
users = client.friends.take(BATCH_SIZE) | |
if users.empty? | |
puts "Done! You now have no friends" | |
exit 0 | |
end | |
unfollowed = client.unfollow users | |
unfollowed.each do |user| | |
puts "unfollowed: #{user.handle}" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You need to create a Twitter application and generate your keys there. After wiping who I'm following, I deleted the app.