Skip to content

Instantly share code, notes, and snippets.

@0xDispatch
Created August 6, 2023 19:09
Show Gist options
  • Save 0xDispatch/3c3528db7828cb70dcea19a34861dd30 to your computer and use it in GitHub Desktop.
Save 0xDispatch/3c3528db7828cb70dcea19a34861dd30 to your computer and use it in GitHub Desktop.
a python code to block anyone tweeting about one piece
#wont work tho
import tweepy
# Authenticate to Twitter
auth = tweepy.OAuth1UserHandler(
"CONSUMER_KEY", "CONSUMER_SECRET",
"ACCESS_TOKEN", "ACCESS_TOKEN_SECRET"
)
# Create API object
api = tweepy.Client(auth=auth)
# Define the stream listener
class MyStreamListener(tweepy.StreamListener):
def on_status(self, status):
# Check if tweet contains the word "ون بيس"
if "ون بيس" in status.text:
# Block the user who tweeted
api.create_block(status.author.id)
print(f"Blocked {status.author.name} for tweeting 'ون بيس'.")
# Create the stream object
myStreamListener = MyStreamListener()
myStream = tweepy.Stream(auth = api.auth, listener=myStreamListener)
# Start streaming tweets
myStream.filter(track=["ون بيس"])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment