From 9af70e2ee420d6176a21fdf8e13f9963867528df Mon Sep 17 00:00:00 2001 From: Sierra Date: Thu, 22 Oct 2020 16:26:45 -0400 Subject: [PATCH] add content warning support --- tootgopher.py | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/tootgopher.py b/tootgopher.py index 45e8d98..9365033 100755 --- a/tootgopher.py +++ b/tootgopher.py @@ -57,8 +57,12 @@ def edit_post(post: str) -> str: return post # display post contents and verify with the user -def post_check(post: str) -> bool: +def post_check(post: str, cw: str) -> bool: print('You are about to post') + # If content warning is given + if (cw != ''): + print() + print(f"CW: \"{cw}\"") print() print(post) print() @@ -76,14 +80,22 @@ def main(): phlog_file = input('Post location (leave blank for root): ') urls = gen_url(config_data, phlog_file) - # get post description, generate post text - # TODO: content warnings + # Read content warning + cw = input('Content Warning? (Leave blank for none): ') + + # Edit post post = f"\n\nGopher: {urls['gopher']}\nHTML Proxy: {urls['proxy']}" post = edit_post(post) - # verify the post with the user and post it - if post_check(post): - toot_dict = m.status_post(post, visibility=config_data['visibility']) + print() + # Verify the post with the user and post it + if post_check(post, cw): + # Check if content warning is given + if (cw == ''): + toot_dict = m.status_post(post, visibility = config_data['visibility']) + else: + toot_dict = m.status_post(post, visibility = config_data['visibility'], spoiler_text = cw) + print(f"Posted at {toot_dict['url']}") else: print('Aborted.')