Skip to content

Instantly share code, notes, and snippets.

@superboum
Created February 11, 2020 13:07
Show Gist options
  • Save superboum/ab31bc4c85c731b9e89ebda5eaed9a3a to your computer and use it in GitHub Desktop.
Save superboum/ab31bc4c85c731b9e89ebda5eaed9a3a to your computer and use it in GitHub Desktop.
#!/usr/bin/python3
import requests, sys, time, tweepy
consumer_key = ""
consumer_secret= ""
access_token = ""
access_token_secret = ""
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)
api = tweepy.API(auth)
user = api.get_user(sys.argv[1])
print(f"select {user.name} @{user.screen_name}", flush=True)
to_sleep = 5
success_in_a_row = 0
for friend in tweepy.Cursor(api.friends, screen_name=user.screen_name).items():
while True:
pretty = f"@{friend.screen_name} ({friend.name})"
print(f"{pretty} in {to_sleep} seconds", flush=True)
time.sleep(to_sleep)
try:
username = friend.screen_name
headers = {'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.47 Safari/537.36'}
r = requests.get(f"https://shadowban.eu/.api/{username}",headers=headers)
if r.status_code == 429:
to_sleep += 5
success_in_a_row = 0
print(f"{pretty} hit a request limit, increased to {to_sleep} seconds", flush=True)
continue
elif r.status_code != 200:
print(f"Error {r.status_code} occured while fetching info for {pretty}", r, flush=True)
break
success_in_a_row += 1
if success_in_a_row > 5:
to_sleep = max(5, to_sleep - 5)
success_in_a_row = 0
print(f"reducing to {to_sleep} seconds", flush=True)
json = r.json()
if not json['profile']['exists']:
print(f"{pretty} does not exist", flush=True)
break
user_status = "clean"
if not json['tests']['typeahead']:
print(f"{pretty} is banned from search suggestion", flush=True)
user_status = "banned"
if not json['tests']['search']:
print(f"{pretty} is banned from search", flush=True)
user_status = "banned"
if 'more_replies' not in json['tests'] or 'tweet' not in json['tests']['more_replies'] or not json['tests']['more_replies']['tweet']:
print(f"{pretty} has never replied", flush=True)
user_status = "unknown"
elif json['tests']['more_replies']['ban']:
print(f"{pretty} is deboosted", flush=True)
user_status = "banned"
if json['tests']['ghost']['ban']:
print(f"{pretty} is banned", flush=True)
user_status = "banned"
if user_status == 'clean':
print(f"{pretty} is OK", flush=True)
break
except Exception as e:
print(f"{pretty} triggered an exception",type(e), e, flush=True)
break
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment