Skip to content

Commit

Permalink
fix: won't toot when all tags are blacklisted
Browse files Browse the repository at this point in the history
  • Loading branch information
Holger Huo authored and Holger Huo committed May 9, 2021
1 parent ae979f8 commit 2af7474
Showing 1 changed file with 23 additions and 20 deletions.
43 changes: 23 additions & 20 deletions mtb.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,20 +83,6 @@ def construct_status():
sys.exit()

tags = json.loads(data)

if not tags:
# Exits if no tags trending
if no_trends_status:
post = no_trends_status
logger.info(
f"No tags trending."
)
return post
else:
logger.info(
f"No tags trending. Exiting now."
)
sys.exit()

if status_body:
post = status_body
Expand All @@ -109,13 +95,30 @@ def construct_status():
if blacklist_raw:
for line in blacklist_raw.splitlines():
blacklist.append(line)

for tag in tags:
if not tag["name"] in blacklist:
# Check if exists in blacklist
post += '#' + tag["name"] + '\n'

return post
tag_list = ''
if tags:
for tag in tags:
if not tag["name"] in blacklist:
# Check if exists in blacklist
tag_list += '#' + tag["name"] + '\n'

if tag_list:
post = post + tag_list
return post
else:
if no_trends_status:
post = no_trends_status
logger.info(
f"No tags trending."
)
return post
else:
logger.info(
f"No tags trending. Exiting now."
)
sys.exit()


def toot(post):
# Toot the toot!
Expand Down

0 comments on commit 2af7474

Please sign in to comment.