Skip to content

Instantly share code, notes, and snippets.

Last active November 24, 2022 06:36
Show Gist options
  • Save ummjackson/8fe9ef99819777c2e6655b5e71dd61ac to your computer and use it in GitHub Desktop.
Save ummjackson/8fe9ef99819777c2e6655b5e71dd61ac to your computer and use it in GitHub Desktop.
XRP Away™️ - automatically block XRP fanatics sliding into your Twitter mentions
# Requirement: pip install tweepy
import tweepy
# Credentials go here (generate at:
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 or "XRP" in tweet.user.description.upper():
# Submit the report
block = api.create_block(, screen_name=tweet.user.screen_name)
# Log blocked user
print("Blocked: " + + " / @" + tweet.user.screen_name)
Copy link

Some tips to get this working:

  • Make sure you're running Python 3.x
  • Don't forget to create a Twitter app @ 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/

Copy link

ghost commented Dec 2, 2018

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

Copy link

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


Copy link


Copy link

So great.

Copy link

psiofxt commented Dec 3, 2018

It's beautiful

Copy link

How do I run this Python script?

Copy link

wow, my nine year old kids would love this, thank you

Copy link

How do I run this Python script?
Please, attach here bat or bash startup script 😭😭😭

Copy link

smcl commented Jun 1, 2022

Sorry I assume you're going to be inundated with all sorts of takes on this, but I'm actually quite astonished at Elon Musk's critique. The code does a very specific task, it is well-formed, it's commented and even has instructions to install requirements and run it. By no definition is this "nonsense", it does exactly what it sets out to do and in addition there's no indication of incompetence (or being "a tool") - it's just a helpful little script.

It sounds like Elon just ... doesn't know software development (like really basic software development) got a bit embarrassed about it and decided to lash out instead of trying a line like "heh yeah i'm too busy squashing unions memeing on twitter saving the world to deal with code these days"

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