Skip to content

Instantly share code, notes, and snippets.

@avarx
Last active May 20, 2017 23:08
Show Gist options
  • Save avarx/f2940ca7b672cf75152acee024df6d47 to your computer and use it in GitHub Desktop.
Save avarx/f2940ca7b672cf75152acee024df6d47 to your computer and use it in GitHub Desktop.
import twitter
ACCESS_KEY = 'xxxx'
ACCESS_SECRET = 'xxxx'
CONSUMER_KEY = 'xxxx'
CONSUMER_SECRET = 'xxxx'
t = twitter.Twitter(auth=twitter.OAuth(ACCESS_KEY, ACCESS_SECRET, CONSUMER_KEY, CONSUMER_SECRET))
def twitter_block_user(screen_name):
try:
blocked = t.blocks.create(screen_name=screen_name)
if blocked:
print ("Blocked user: [ @%s ]." % screen_name)
else:
print ("Could not block: [ @%s ]." % screen_name)
except Exception:
pass
with open('blocklist') as fp:
for line in fp:
twitter_block_user(line.rstrip())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment