Skip to content

Instantly share code, notes, and snippets.

@cduruk
Created October 11, 2019 01:43
Show Gist options
  • Save cduruk/18772f51a6ace65cdb5cc848ab7b49c0 to your computer and use it in GitHub Desktop.
Save cduruk/18772f51a6ace65cdb5cc848ab7b49c0 to your computer and use it in GitHub Desktop.
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
def remove_friendships(client)
begin
client.friends.each do |friend|
client.unfollow(friend)
end
rescue Twitter::Error::TooManyRequests => e
puts "rate limited; sleeping for #{e.rate_limit.reset_in} seconds"
sleep e.rate_limit.reset_in
retry
rescue StandardError => e
puts e.inspect
exit
end
end
remove_friendships(client)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment