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,6 +330,7 @@ def searchban(screen_name): ...@@ -328,6 +330,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 ghostban: if ghostban:
print("{} is ghost banned.".format(screen_name)) print("{} is ghost banned.".format(screen_name))
returnjson["tests"]["ghost"] = { returnjson["tests"]["ghost"] = {
...@@ -336,6 +339,7 @@ def searchban(screen_name): ...@@ -336,6 +339,7 @@ def searchban(screen_name):
"in_reply_to": ghostReplyId "in_reply_to": ghostReplyId
} }
if not showmore: if not showmore:
print("{} is not reply deboosted.".format(screen_name))
returnjson["tests"]["more_replies"] = { returnjson["tests"]["more_replies"] = {
"ban": False, "ban": False,
"in_reply_to": showmoreReplyId, "in_reply_to": showmoreReplyId,
...@@ -356,6 +360,10 @@ def searchban(screen_name): ...@@ -356,6 +360,10 @@ def searchban(screen_name):
"in_reply_to": showmoreReplyId, "in_reply_to": showmoreReplyId,
"tweet": showmoreTweetId "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