Instantly share code, notes, and snippets.

Embed
What would you like to do?
XRP Away™️ - automatically block XRP fanatics sliding into your Twitter mentions
# 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)
@ummjackson

This comment has been minimized.

Owner

ummjackson commented Dec 2, 2018

Some tips to get this working:

  • Make sure you're running Python 3.x
  • Don't forget to create a Twitter app @ https://apps.twitter.com and replace the API tokens on lines 5 & 6
  • You can run this manually from the terminal periodically, but it's recommended you set up a simple cron job to do this automatically every minute or so. If you're not familiar with cron, look up a crontab tutorial - it's pretty simple. An example job to run this every minute would look similar to: * * * * * /usr/bin/python3 /usr/xrpaway.py
@sci4me

This comment has been minimized.

sci4me commented Dec 2, 2018

This is now my favorite gist. Thank you for this!

@ummjackson

This comment has been minimized.

Owner

ummjackson commented Dec 2, 2018

I really missed an opportunity in not calling this XRPelliarmus, didn't I?

image

@DESIGNfromWITHIN

This comment has been minimized.

DESIGNfromWITHIN commented Dec 2, 2018

Just EPIC

@yorktronic

This comment has been minimized.

yorktronic commented Dec 2, 2018

So great.

@psiofxt

This comment has been minimized.

psiofxt commented Dec 3, 2018

It's beautiful

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment