Commit b708a39e authored by nanahira's avatar nanahira

fix incorrect ghost ban check

parent 1726827e
Pipeline #18577 passed with stage
in 59 seconds
......@@ -44,6 +44,7 @@ FeaturesDict = {
"verified_phone_label_enabled": False,
"responsive_web_twitter_blue_verified_badge_is_enabled": False,
"view_counts_public_visibility_enabled": False,
"view_counts_everywhere_api_enabled": False,
}
FeaturesJson = json.dumps(FeaturesDict)
......@@ -250,7 +251,7 @@ def searchban(screen_name):
try:
repliesJson = replies.json()
print(repliesJson)
# print(repliesJson)
maindata = repliesJson["data"]["user"]["result"]["timeline"]["timeline"]["instructions"]
for d in maindata:
if d["type"] == "TimelineAddEntries":
......@@ -280,36 +281,31 @@ def searchban(screen_name):
tweetdetails = twitter_b.get("https://twitter.com/i/api/graphql/{}/{}".format(ENDPOINT["TweetDetail"], "TweetDetail"), params={"variables": json.dumps(tweet_detail_vars), "features": FeaturesJson})
insts = tweetdetails.json()["data"]["threaded_conversation_with_injections"]["instructions"]
ghostban = True
inReplyToGhost = reply["id_str"]
inReplyToShowMore = reply["id_str"]
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
inReplyTo = reply["id_str"]
if ent["entryId"].startswith("conversationthread") and ghostban:
for item in ent["content"]["items"]:
if "tweet_results" in item["item"]["itemContent"]:
if item["item"]["itemContent"]["tweet_results"]["result"]["legacy"]["user_id_str"] == user_id:
returnjson["tests"]["ghost"] = {"ban": False, "in_reply_to": item["item"]["itemContent"]["tweet_results"]["result"]["legacy"]["id_str"]}
ghostban = False
break
else:
inReplyTo = item["item"]["itemContent"]["tweet_results"]["result"]["legacy"]["id_str"]
if ghostban:
print("{} is ghost banned.".format(screen_name))
returnjson["tests"]["ghost"] = {"ban": True, "in_reply_to": inReplyTo}
#print("Current sub entry of {} {} is: {}".format(screen_name, ent["entryId"], item["item"]["itemContent"]))
if "tweet_results" in item["item"]["itemContent"] and item["item"]["itemContent"]["tweet_results"]["result"]["legacy"]["user_id_str"] == user_id:
validId = item["item"]["itemContent"]["tweet_results"]["result"]["legacy"]["id_str"]
returnjson["tests"]["ghost"] = {"ban": False, "in_reply_to": validId}
ghostban = False
print("Found valid reply {}, so {} is not ghost banned.".format(validId, screen_name))
break
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
if ent["entryId"].startswith("cursor-showmorethreadsprompt") and not showmore:
# 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), "features": FeaturesJson})
......@@ -319,6 +315,7 @@ def searchban(screen_name):
if c_i["type"] == "TimelineAddEntries":
if len(c_i["entries"]) == 0:
returnjson["tests"]["more_replies"] = {"ban": True}
showmore = True
break
for c_ent in c_i["entries"]:
if c_ent["entryId"].startswith("conversationthread"):
......@@ -326,20 +323,24 @@ def searchban(screen_name):
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:
inReplyTo = c_item["item"]["itemContent"]["tweet_results"]["result"]["legacy"]["id_str"]
# returnjson["tests"]["ghost"] = {"ban": False, "in_reply_to": inReplyTo}
returnjson["tests"]["more_replies"] = {"ban": True, "in_reply_to": inReplyTo}
print("{} is reply deboosted.".format(screen_name))
inReplyToShowMore = c_item["item"]["itemContent"]["tweet_results"]["result"]["legacy"]["id_str"]
# returnjson["tests"]["ghost"] = {"ban": False, "in_reply_to": inReplyToShowMore}
returnjson["tests"]["more_replies"] = {"ban": True, "in_reply_to": inReplyToShowMore}
print("{} is reply deboosted because of {}.".format(screen_name, inReplyToShowMore))
showmore = True
# 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 ghostban:
print("{} is ghost banned.".format(screen_name))
returnjson["tests"]["ghost"] = {"ban": True, "in_reply_to": inReplyToGhost}
if not showmore:
returnjson["tests"]["more_replies"] = {
"ban": False,
"in_reply_to": reply["id_str"],
"in_reply_to": inReplyToShowMore,
}
replyTweet = reply["in_reply_to_status_id_str"]
for testField in ["ghost", "more_replies"]:
......@@ -357,8 +358,8 @@ def searchban(screen_name):
#print(returnjson["tests"]["ghost"])
# No search ban => No ghost ban
if returnjson["tests"]["search"] and returnjson["tests"]["search"] != "_error" and "ban" in returnjson["tests"]["ghost"] and returnjson["tests"]["ghost"]["ban"] == True:
returnjson["tests"]["ghost"]["ban"] = False
#if returnjson["tests"]["search"] and returnjson["tests"]["search"] != "_error" and "ban" in returnjson["tests"]["ghost"] and returnjson["tests"]["ghost"]["ban"] == True:
# returnjson["tests"]["ghost"]["ban"] = False
# No ghost ban && unknown more replies => No more replies ban
if "ban" not in returnjson["tests"]["more_replies"] and "ban" in returnjson["tests"]["ghost"] and returnjson["tests"]["ghost"]["ban"] == False:
......
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