-
-
Save unlobito/8d826855b97d2adc188182eecd559fb9 to your computer and use it in GitHub Desktop.
Unblock all blocked Twitter accounts
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
#!/usr/bin/env python3 | |
# Dependency: pip3 install twitter | |
import twitter | |
# Go to http://apps.twitter.com/, create an app, and fill in these values: | |
consumer_key = 'www' | |
consumer_secret = 'xxx' | |
access_token = 'yyy' | |
access_token_secret = 'zzz' | |
file_name = 'users.txt' | |
def twitter_login(): | |
"""Connect to Twitter, returning a Twitter instance.""" | |
auth = twitter.OAuth(access_token, access_token_secret, consumer_key, consumer_secret) | |
return twitter.Twitter(auth=auth, retry=True) | |
def unblock_all(t): | |
"""Unblock all blocked accounts, using the given Twitter instance.""" | |
blocked_count = 0 | |
with open(file_name) as file: | |
for user_id in file: | |
blocked_count = blocked_count + 1 | |
print(f"{blocked_count}: {user_id}") | |
try: | |
t.blocks.destroy(user_id=user_id, include_entities=False, skip_status=True) | |
except: | |
print("error") | |
if __name__ == "__main__": | |
t = twitter_login() | |
unblock_all(t) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment