Commit a322b59a authored by nanahira's avatar nanahira

handle cases with no tweets found

parent 90f622dd
Pipeline #18765 passed with stage
in 34 seconds
...@@ -249,6 +249,7 @@ def searchban(screen_name): ...@@ -249,6 +249,7 @@ 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
...@@ -265,6 +266,7 @@ def searchban(screen_name): ...@@ -265,6 +266,7 @@ def searchban(screen_name):
if "in_reply_to_status_id_str" in tmp: if "in_reply_to_status_id_str" in tmp:
reply = tmp reply = tmp
tweetId = reply["in_reply_to_status_id_str"] tweetId = reply["in_reply_to_status_id_str"]
foundTweet = True
if ghostTweetId is None: if ghostTweetId is None:
ghostTweetId = tweetId ghostTweetId = tweetId
ghostReplyId = reply["id_str"] ghostReplyId = reply["id_str"]
...@@ -328,34 +330,40 @@ def searchban(screen_name): ...@@ -328,34 +330,40 @@ 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 ghostban: if foundTweet:
print("{} is ghost banned.".format(screen_name)) if ghostban:
returnjson["tests"]["ghost"] = { print("{} is ghost banned.".format(screen_name))
"ban": True, returnjson["tests"]["ghost"] = {
"tweet": ghostTweetId, "ban": True,
"in_reply_to": ghostReplyId "tweet": ghostTweetId,
} "in_reply_to": ghostReplyId
if not showmore: }
returnjson["tests"]["more_replies"] = { if not showmore:
"ban": False, print("{} is not reply deboosted.".format(screen_name))
"in_reply_to": showmoreReplyId, returnjson["tests"]["more_replies"] = {
"tweet": showmoreTweetId "ban": False,
} "in_reply_to": showmoreReplyId,
# No search ban || more replies => No ghost ban "tweet": showmoreTweetId
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"] = { # No search ban || more replies => No ghost ban
"ban": False, 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:
"tweet": ghostTweetId, returnjson["tests"]["ghost"] = {
"in_reply_to": ghostReplyId "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"] = { # No ghost ban && unknown more replies => No more replies ban
"ban": False, if "ban" not in returnjson["tests"]["more_replies"] and "ban" in returnjson["tests"]["ghost"] and returnjson["tests"]["ghost"]["ban"] == False:
"in_reply_to": showmoreReplyId, returnjson["tests"]["more_replies"] = {
"tweet": showmoreTweetId "ban": False,
} "in_reply_to": showmoreReplyId,
"tweet": showmoreTweetId
}
else:
print("No replies found for {}.".format(screen_name))
returnjson["tests"]["ghost"] = {}
returnjson["tests"]["more_replies"] = {}
except KeyError as e: except KeyError as e:
print("Errored testing {}".format(screen_name)) print("Errored testing {}".format(screen_name))
print(e) print(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