Created
August 24, 2020 12:08
-
-
Save azukacchi/0263fcc20f2a0ce8ba6ed06bdcffedcf to your computer and use it in GitHub Desktop.
block (or mute) retweeters of a tweet! if you wish to not ever engage in or encounter an unreasonable conversation on twitter with people who interact with a certain tweet
This file contains 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
import tweepy | |
import re | |
import time | |
## You should already have a Twitter developer account first | |
## with Read and Write permission | |
consumer_key = "YOUR KEY HERE" | |
consumer_secret = "YOUR KEY HERE" | |
access_token = "YOUR KEY HERE" | |
access_token_secret = "YOUR KEY HERE" | |
auth = tweepy.OAuthHandler(consumer_key, consumer_secret) | |
auth.set_access_token(access_token, access_token_secret) | |
api = tweepy.API(auth, wait_on_rate_limit=True, wait_on_rate_limit_notify=True) | |
twtlink = 'PASTE THE TWEET LINK WHICH RETWEETERS YOU WANT TO BLOCK' # paste inside the ' ' | |
regex = r'(?=twitter\.com\/(\w+)\/status\/(\d+))' | |
twtid = int(re.search(regex, twtlink).group(2)) | |
user_name = re.search(regex, twtlink).group(1) | |
rtid = api.retweeters(twtid) | |
for id in rtid: | |
api.create_block(id=id) | |
#api.create_mute(id=id) IF YOU WANT TO ONLY MUTE THEM | |
time.sleep(3) | |
api.create_block(screen_name=user_name) | |
print(f"Number of people who retweeted the tweets that you've blocked: {len(rtid)}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment