Created
December 2, 2018 03:48
-
-
Save RandyMcMillan/81996bb8e5fa43dacf51f9daff85a6d7 to your computer and use it in GitHub Desktop.
XRP Away™️ - automatically block XRP fanatics sliding into your Twitter mentions
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
# Requirement: pip install tweepy | |
import tweepy | |
# Credentials go here (generate at: https://apps.twitter.com) | |
auth = tweepy.OAuthHandler('consumer_key', 'consumer_secret') | |
auth.set_access_token('access_token', 'access_token_secret') | |
# Connect to Twitter | |
api = tweepy.API(auth) | |
# Grab last 200 mentions (max. threshold the Twitter API supports) | |
mentions = api.mentions_timeline(count=200) | |
# Loop through the mentions | |
for tweet in mentions: | |
# If the username or bio contains XRP (case-insensitive), block them | |
if "XRP" in tweet.user.screen_name.upper() or "XRP" in tweet.user.name.upper() or "XRP" in tweet.user.description.upper(): | |
# Submit the report | |
block = api.create_block(user_id=tweet.user.id, screen_name=tweet.user.screen_name) | |
# Log blocked user | |
print("Blocked: " + tweet.user.name + " / @" + tweet.user.screen_name) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment