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):
# print(replies.text)
try:
foundTweet = False
ghostban = True
ghostTweetId = None
ghostReplyId = None
......@@ -265,6 +266,7 @@ def searchban(screen_name):
if "in_reply_to_status_id_str" in tmp:
reply = tmp
tweetId = reply["in_reply_to_status_id_str"]
foundTweet = True
if ghostTweetId is None:
ghostTweetId = tweetId
ghostReplyId = reply["id_str"]
......@@ -328,34 +330,40 @@ def searchban(screen_name):
print("{} is reply deboosted because of {} => {}.".format(screen_name, tweetId, replyId))
showmore = True
break
if ghostban:
print("{} is ghost banned.".format(screen_name))
returnjson["tests"]["ghost"] = {
"ban": True,
"tweet": ghostTweetId,
"in_reply_to": ghostReplyId
}
if not showmore:
returnjson["tests"]["more_replies"] = {
"ban": False,
"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
}
if foundTweet:
if ghostban:
print("{} is ghost banned.".format(screen_name))
returnjson["tests"]["ghost"] = {
"ban": True,
"tweet": ghostTweetId,
"in_reply_to": ghostReplyId
}
if not showmore:
print("{} is not reply deboosted.".format(screen_name))
returnjson["tests"]["more_replies"] = {
"ban": False,
"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
}
else:
print("No replies found for {}.".format(screen_name))
returnjson["tests"]["ghost"] = {}
returnjson["tests"]["more_replies"] = {}
except KeyError as e:
print("Errored testing {}".format(screen_name))
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