Commit 90f622dd authored by nanahira's avatar nanahira

check every tweet instead of one

parent 0d755dee
Pipeline #18764 passed with stage
in 39 seconds
...@@ -248,10 +248,14 @@ def searchban(screen_name): ...@@ -248,10 +248,14 @@ def searchban(screen_name):
replies = twitter_b.get("https://twitter.com/i/api/graphql/{}/{}".format(ENDPOINT["UserTweetsAndReplies"], "UserTweetsAndReplies"), params=get_reply_param) replies = twitter_b.get("https://twitter.com/i/api/graphql/{}/{}".format(ENDPOINT["UserTweetsAndReplies"], "UserTweetsAndReplies"), params=get_reply_param)
# print(replies.text) # print(replies.text)
try: try:
ghostban = True
ghostTweetId = None
ghostReplyId = None
showmore = False
showmoreTweetId = None
showmoreReplyId = None
repliesJson = replies.json() repliesJson = replies.json()
# print(repliesJson)
maindata = repliesJson["data"]["user"]["result"]["timeline"]["timeline"]["instructions"] maindata = repliesJson["data"]["user"]["result"]["timeline"]["timeline"]["instructions"]
for d in maindata: for d in maindata:
if d["type"] == "TimelineAddEntries": if d["type"] == "TimelineAddEntries":
...@@ -260,15 +264,15 @@ def searchban(screen_name): ...@@ -260,15 +264,15 @@ def searchban(screen_name):
tmp = ent["content"]["itemContent"]["tweet_results"]["result"]["legacy"] tmp = ent["content"]["itemContent"]["tweet_results"]["result"]["legacy"]
if "in_reply_to_status_id_str" in tmp: if "in_reply_to_status_id_str" in tmp:
reply = tmp reply = tmp
# print("Found a reply!", tmp["full_text"]) tweetId = reply["in_reply_to_status_id_str"]
break if ghostTweetId is None:
ghostTweetId = tweetId
if reply is None: ghostReplyId = reply["id_str"]
returnjson["tests"]["ghost"] = {} if showmoreTweetId is None:
returnjson["tests"]["more_replies"] = {} showmoreTweetId = tweetId
else: showmoreReplyId = reply["id_str"]
tweet_detail_vars = { tweet_detail_vars = {
"focalTweetId": reply["in_reply_to_status_id_str"], "focalTweetId": tweetId,
"includePromotedContent":False, "includePromotedContent":False,
"withBirdwatchNotes":False, "withBirdwatchNotes":False,
"withSuperFollowsUserFields":False, "withSuperFollowsUserFields":False,
...@@ -279,31 +283,28 @@ def searchban(screen_name): ...@@ -279,31 +283,28 @@ def searchban(screen_name):
"withVoice":False, "withVoice":False,
} }
tweetdetails = twitter_b.get("https://twitter.com/i/api/graphql/{}/{}".format(ENDPOINT["TweetDetail"], "TweetDetail"), params={"variables": json.dumps(tweet_detail_vars), "features": FeaturesJson}) tweetdetails = twitter_b.get("https://twitter.com/i/api/graphql/{}/{}".format(ENDPOINT["TweetDetail"], "TweetDetail"), params={"variables": json.dumps(tweet_detail_vars), "features": FeaturesJson})
tweetData = tweetdetails.json()["data"]
if "threaded_conversation_with_injections" not in tweetData:
continue
insts = tweetdetails.json()["data"]["threaded_conversation_with_injections"]["instructions"] 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: for inst in insts:
if not ghostban and showmore:
# all checks done
break
if inst["type"] == "TimelineAddEntries": if inst["type"] == "TimelineAddEntries":
for ent in inst["entries"]: for ent in inst["entries"]:
if not ghostban and showmore:
# all checks done
break
print("Current entry of {} is: {}".format(screen_name, ent["entryId"])) print("Current entry of {} is: {}".format(screen_name, ent["entryId"]))
if ent["entryId"].startswith("conversationthread") and ghostban: if ent["entryId"].startswith("conversationthread") and ghostban:
for item in ent["content"]["items"]: for item in ent["content"]["items"]:
#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: 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"] replyId = item["item"]["itemContent"]["tweet_results"]["result"]["legacy"]["id_str"]
returnjson["tests"]["ghost"] = {"ban": False, "in_reply_to": validId} returnjson["tests"]["ghost"] = {"ban": False, "tweet": tweetId, "in_reply_to": replyId}
ghostban = False ghostban = False
print("Found valid reply {}, so {} is not ghost banned.".format(validId, screen_name)) print("Found valid reply {} => {}, so {} is not ghost banned.".format(tweetId, replyId, screen_name))
break 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") and not showmore: if ent["entryId"].startswith("cursor-showmorethreadsprompt") and not showmore:
# showmore = True # showmore = True
cursor_vars = tweet_detail_vars cursor_vars = tweet_detail_vars
...@@ -319,36 +320,45 @@ def searchban(screen_name): ...@@ -319,36 +320,45 @@ def searchban(screen_name):
break break
for c_ent in c_i["entries"]: for c_ent in c_i["entries"]:
if c_ent["entryId"].startswith("conversationthread"): if c_ent["entryId"].startswith("conversationthread"):
# more = True print("Checking more contents of {} by {}".format(tweetId, screen_name))
print("Checking more contents of {}".format(screen_name))
for c_item in c_ent["content"]["items"]: for c_item in c_ent["content"]["items"]:
if c_item["item"]["itemContent"]["tweet_results"]["result"]["legacy"]["user_id_str"] == user_id: if c_item["item"]["itemContent"]["tweet_results"]["result"]["legacy"]["user_id_str"] == user_id:
inReplyToShowMore = c_item["item"]["itemContent"]["tweet_results"]["result"]["legacy"]["id_str"] replyId = 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": replyId, "tweet": tweetId}
returnjson["tests"]["more_replies"] = {"ban": True, "in_reply_to": inReplyToShowMore} print("{} is reply deboosted because of {} => {}.".format(screen_name, tweetId, replyId))
print("{} is reply deboosted because of {}.".format(screen_name, inReplyToShowMore))
showmore = True showmore = True
# more = False
break 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: if ghostban:
print("{} is ghost banned.".format(screen_name)) print("{} is ghost banned.".format(screen_name))
returnjson["tests"]["ghost"] = {"ban": True, "in_reply_to": inReplyToGhost} returnjson["tests"]["ghost"] = {
"ban": True,
"tweet": ghostTweetId,
"in_reply_to": ghostReplyId
}
if not showmore: if not showmore:
returnjson["tests"]["more_replies"] = { returnjson["tests"]["more_replies"] = {
"ban": False, "ban": False,
"in_reply_to": inReplyToShowMore, "in_reply_to": showmoreReplyId,
"tweet": showmoreTweetId
}
# No search ban || more replies => No ghost ban
if returnjson["tests"]["search"] and returnjson["tests"]["search"] != "_error" and "ban" in returnjson["tests"]["ghost"] and returnjson["tests"]["ghost"]["ban"] == True or "ban" in returnjson["tests"]["more_replies"] and returnjson["tests"]["more_replies"]["ban"] == True:
returnjson["tests"]["ghost"] = {
"ban": False,
"tweet": ghostTweetId,
"in_reply_to": ghostReplyId
}
# 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:
returnjson["tests"]["more_replies"] = {
"ban": False,
"in_reply_to": showmoreReplyId,
"tweet": showmoreTweetId
} }
replyTweet = reply["in_reply_to_status_id_str"]
for testField in ["ghost", "more_replies"]:
if testField in returnjson["tests"]:
returnjson["tests"][testField]["tweet"] = replyTweet
except KeyError as e: except KeyError as e:
print("Errored testing {}".format(screen_name)) print("Errored testing {}".format(screen_name))
# print(Exception.with_traceback(e)) print(e)
returnjson["tests"]["ghost"] = {} returnjson["tests"]["ghost"] = {}
returnjson["tests"]["more_replies"] = {} returnjson["tests"]["more_replies"] = {}
...@@ -357,13 +367,7 @@ def searchban(screen_name): ...@@ -357,13 +367,7 @@ def searchban(screen_name):
#print("ban" in returnjson["tests"]["ghost"]) #print("ban" in returnjson["tests"]["ghost"])
#print(returnjson["tests"]["ghost"]) #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
# 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:
returnjson["tests"]["more_replies"] = {"ban": False}
print("Result of {}: {}".format(screen_name, json.dumps(returnjson))) print("Result of {}: {}".format(screen_name, json.dumps(returnjson)))
return returnjson return returnjson
......
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