Created
October 11, 2019 01:43
-
-
Save cduruk/18772f51a6ace65cdb5cc848ab7b49c0 to your computer and use it in GitHub Desktop.
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
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