Commit 2ea5f4a3 authored by nanahira's avatar nanahira

make reply not none

parent ea8cdbfb
Pipeline #9701 passed with stage
in 26 seconds
......@@ -192,84 +192,89 @@ def searchban(screen_name):
reply = tmp
# print("Found a reply!", tmp["full_text"])
break
tweet_detail_vars = {
"focalTweetId":reply["in_reply_to_status_id_str"],
"includePromotedContent":False,
"withBirdwatchNotes":False,
"withSuperFollowsUserFields":False,
"withDownvotePerspective":False,
"withReactionsMetadata":False,
"withReactionsPerspective":False,
"withSuperFollowsTweetFields":False,
"withVoice":False,
"__fs_interactive_text":False,
"__fs_responsive_web_uc_gql_enabled":False,
"__fs_dont_mention_me_view_api_enabled":False
}
tweetdetails = twitter_b.get("https://twitter.com/i/api/graphql/{}/{}".format(ENDPOINT["TweetDetail"], "TweetDetail"), params={"variables": json.dumps(tweet_detail_vars)})
insts = tweetdetails.json()["data"]["threaded_conversation_with_injections"]["instructions"]
showmore = False
for inst in insts:
if inst["type"] == "TimelineAddEntries":
for ent in inst["entries"]:
print("Current entry of {} is: {}".format(screen_name, ent["entryId"]))
if ent["entryId"].startswith("conversationthread"):
ghostban = True
for item in ent["content"]["items"]:
if "tweet_results" in item["item"]["itemContent"] and item["item"]["itemContent"]["tweet_results"]["result"]["legacy"]["user_id_str"] == user_id:
returnjson["tests"]["ghost"] = {"ban": False}
ghostban = False
break
if ghostban:
print("{} is ghost banned.".format(screen_name))
returnjson["tests"]["ghost"] = {"ban": True}
if ent["entryId"].startswith("cursor-bottom"):
print("{}'s test touched bottom.".format(screen_name))
#returnjson["tests"]["ghost"] = {}
#returnjson["tests"]["more_replies"] = {}
break
if ent["entryId"].startswith("cursor-showmorethreadsprompt"):
showmore = True
cursor_vars = tweet_detail_vars
cursor_vars["cursor"] = ent["content"]["itemContent"]["value"]
cursor = twitter_b.get("https://twitter.com/i/api/graphql/{}/{}".format(ENDPOINT["TweetDetail"], "TweetDetail"), params={"variables": json.dumps(cursor_vars)})
cursor_insts = cursor.json()["data"]["threaded_conversation_with_injections"]["instructions"]
for c_i in cursor_insts:
if c_i["type"] == "TimelineAddEntries":
if len(c_i["entries"]) == 0:
returnjson["tests"]["more_replies"] = {"ban": True}
break
for c_ent in c_i["entries"]:
if c_ent["entryId"].startswith("conversationthread"):
more = True
print("Checking more contents of {}".format(screen_name))
for c_item in c_ent["content"]["items"]:
if c_item["item"]["itemContent"]["tweet_results"]["result"]["legacy"]["user_id_str"] == user_id:
returnjson["tests"]["ghost"] = {"ban": False}
returnjson["tests"]["more_replies"] = {"ban": True, "tweet":reply["id_str"], "in_reply_to": c_item["item"]["itemContent"]["tweet_results"]["result"]["legacy"]["id_str"]}
print("{} is reply deboosted.".format(screen_name))
more = False
break
if more:
print("{} is both ghost banned and reply deboosted.".format(screen_name))
returnjson["tests"]["ghost"] = {"ban": True}
returnjson["tests"]["more_replies"] = {"ban": True}
if not showmore:
returnjson["tests"]["more_replies"] = {
"ban": False,
"in_reply_to": "-1",
"tweet": "-1"
if reply is None:
returnjson["tests"]["ghost"] = {}
returnjson["tests"]["more_replies"] = {}
else:
tweet_detail_vars = {
"focalTweetId": reply["in_reply_to_status_id_str"],
"includePromotedContent":False,
"withBirdwatchNotes":False,
"withSuperFollowsUserFields":False,
"withDownvotePerspective":False,
"withReactionsMetadata":False,
"withReactionsPerspective":False,
"withSuperFollowsTweetFields":False,
"withVoice":False,
"__fs_interactive_text":False,
"__fs_responsive_web_uc_gql_enabled":False,
"__fs_dont_mention_me_view_api_enabled":False
}
tweetdetails = twitter_b.get("https://twitter.com/i/api/graphql/{}/{}".format(ENDPOINT["TweetDetail"], "TweetDetail"), params={"variables": json.dumps(tweet_detail_vars)})
insts = tweetdetails.json()["data"]["threaded_conversation_with_injections"]["instructions"]
showmore = False
for inst in insts:
if inst["type"] == "TimelineAddEntries":
for ent in inst["entries"]:
print("Current entry of {} is: {}".format(screen_name, ent["entryId"]))
if ent["entryId"].startswith("conversationthread"):
ghostban = True
for item in ent["content"]["items"]:
if "tweet_results" in item["item"]["itemContent"] and item["item"]["itemContent"]["tweet_results"]["result"]["legacy"]["user_id_str"] == user_id:
returnjson["tests"]["ghost"] = {"ban": False}
ghostban = False
break
if ghostban:
print("{} is ghost banned.".format(screen_name))
returnjson["tests"]["ghost"] = {"ban": True}
if ent["entryId"].startswith("cursor-bottom"):
print("{}'s test touched bottom.".format(screen_name))
#returnjson["tests"]["ghost"] = {}
#returnjson["tests"]["more_replies"] = {}
break
if ent["entryId"].startswith("cursor-showmorethreadsprompt"):
showmore = True
cursor_vars = tweet_detail_vars
cursor_vars["cursor"] = ent["content"]["itemContent"]["value"]
cursor = twitter_b.get("https://twitter.com/i/api/graphql/{}/{}".format(ENDPOINT["TweetDetail"], "TweetDetail"), params={"variables": json.dumps(cursor_vars)})
cursor_insts = cursor.json()["data"]["threaded_conversation_with_injections"]["instructions"]
for c_i in cursor_insts:
if c_i["type"] == "TimelineAddEntries":
if len(c_i["entries"]) == 0:
returnjson["tests"]["more_replies"] = {"ban": True}
break
for c_ent in c_i["entries"]:
if c_ent["entryId"].startswith("conversationthread"):
more = True
print("Checking more contents of {}".format(screen_name))
for c_item in c_ent["content"]["items"]:
if c_item["item"]["itemContent"]["tweet_results"]["result"]["legacy"]["user_id_str"] == user_id:
returnjson["tests"]["ghost"] = {"ban": False}
returnjson["tests"]["more_replies"] = {"ban": True, "tweet":reply["id_str"], "in_reply_to": c_item["item"]["itemContent"]["tweet_results"]["result"]["legacy"]["id_str"]}
print("{} is reply deboosted.".format(screen_name))
more = False
break
if more:
print("{} is both ghost banned and reply deboosted.".format(screen_name))
returnjson["tests"]["ghost"] = {"ban": True}
returnjson["tests"]["more_replies"] = {"ban": True}
if not showmore:
returnjson["tests"]["more_replies"] = {
"ban": False,
"in_reply_to": "-1",
"tweet": "-1"
}
except KeyError as e:
print("Errored testing {}".format(screen_name))
print(Exception.with_traceback(e))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment