Skip to content

Instantly share code, notes, and snippets.

@scottmuc
Last active March 10, 2018 18:58
Show Gist options
  • Save scottmuc/11224684 to your computer and use it in GitHub Desktop.
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
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!"
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
@scottmuc
Copy link
Author

You need to create a Twitter application and generate your keys there. After wiping who I'm following, I deleted the app.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment