Commit 0a2b143e authored by nanahira's avatar nanahira

it really was too slow

parent 7198a7e2
Pipeline #18767 passed with stage
in 27 seconds
...@@ -249,7 +249,6 @@ def searchban(screen_name): ...@@ -249,7 +249,6 @@ def searchban(screen_name):
# print(replies.text) # print(replies.text)
try: try:
foundTweet = False
ghostban = True ghostban = True
ghostTweetId = None ghostTweetId = None
ghostReplyId = None ghostReplyId = None
...@@ -258,15 +257,22 @@ def searchban(screen_name): ...@@ -258,15 +257,22 @@ def searchban(screen_name):
showmoreReplyId = None showmoreReplyId = None
repliesJson = replies.json() repliesJson = replies.json()
maindata = repliesJson["data"]["user"]["result"]["timeline"]["timeline"]["instructions"] maindata = repliesJson["data"]["user"]["result"]["timeline"]["timeline"]["instructions"]
checkedTweets = set()
for d in maindata: for d in maindata:
if not ghostban:
# all checks done
break
if d["type"] == "TimelineAddEntries": if d["type"] == "TimelineAddEntries":
for ent in d["entries"]: for ent in d["entries"]:
if not ghostban:
# all checks done
break
if ent["entryId"].startswith("tweet"): if ent["entryId"].startswith("tweet"):
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 and tmp["in_reply_to_status_id_str"] not in checkedTweets:
reply = tmp reply = tmp
tweetId = reply["in_reply_to_status_id_str"] tweetId = reply["in_reply_to_status_id_str"]
foundTweet = True checkedTweets.add(tweetId)
if ghostTweetId is None: if ghostTweetId is None:
ghostTweetId = tweetId ghostTweetId = tweetId
ghostReplyId = reply["id_str"] ghostReplyId = reply["id_str"]
...@@ -290,12 +296,12 @@ def searchban(screen_name): ...@@ -290,12 +296,12 @@ def searchban(screen_name):
continue continue
insts = tweetdetails.json()["data"]["threaded_conversation_with_injections"]["instructions"] insts = tweetdetails.json()["data"]["threaded_conversation_with_injections"]["instructions"]
for inst in insts: for inst in insts:
if not ghostban and showmore: if not ghostban:
# all checks done # all checks done
break break
if inst["type"] == "TimelineAddEntries": if inst["type"] == "TimelineAddEntries":
for ent in inst["entries"]: for ent in inst["entries"]:
if not ghostban and showmore: if not ghostban:
# all checks done # all checks done
break break
print("Current entry of {} is: {}".format(screen_name, ent["entryId"])) print("Current entry of {} is: {}".format(screen_name, ent["entryId"]))
...@@ -330,7 +336,7 @@ def searchban(screen_name): ...@@ -330,7 +336,7 @@ def searchban(screen_name):
print("{} is reply deboosted because of {} => {}.".format(screen_name, tweetId, replyId)) print("{} is reply deboosted because of {} => {}.".format(screen_name, tweetId, replyId))
showmore = True showmore = True
break break
if foundTweet: if len(checkedTweets) > 0:
if ghostban: if ghostban:
print("{} is ghost banned.".format(screen_name)) print("{} is ghost banned.".format(screen_name))
returnjson["tests"]["ghost"] = { returnjson["tests"]["ghost"] = {
......
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