Last active
May 3, 2018 00:58
-
-
Save oreoshake/46f3d6c1368f3227a31a1b3f4e16a71f to your computer and use it in GitHub Desktop.
Deletes your blocks. Is really slow. Will probably hit rate limits quickly.
This file contains hidden or 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 'twitter' | |
client = Twitter::REST::Client.new do |config| | |
config.consumer_key = ENV["CONSUMER_KEY"] | |
config.consumer_secret = ENV["CONSUMER_SECRET"] | |
config.access_token = ENV["ACCESS_TOKEN"] | |
config.access_token_secret = ENV["ACCESS_TOKEN_SECRET"] | |
end | |
USER_ID = < your user id > | |
USER_ID = 43220757 | |
cursor = -1 | |
while cursor != 0 do | |
puts "*" * 40 | |
puts "grabbing a fresh batch of blocks (#{cursor})" | |
puts "*" * 40 | |
block_ids = client.send(:perform_get, "/1.1/blocks/ids.json", id: USER_ID, cursor: cursor)[:ids] | |
cursor = block_ids[:next_cursor] | |
block_ids.each_with_index do |block_id, index| | |
res = client.send(:perform_post, "/1.1/blocks/destroy.json", user_id: block_id) | |
if res[:name] | |
puts "Unblocked #{res[:name]}: #{res[:screen_name]} (#{index} of #{block_ids.count})" | |
else | |
puts "Couldn't unblock #{blocked_id} (#{index} of #{block_ids.count})" | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment