From 7d03160f43b56cba2c79292f6144d0e0fbfa7285 Mon Sep 17 00:00:00 2001 From: Raphael Fetzer <58503+pheraph@users.noreply.github.com> Date: Sat, 21 Jan 2023 13:48:38 +0100 Subject: [PATCH] Customizable visibility of toots (public/unlisted) --- cron-sample.sh | 4 +++- tootbot.py | 13 +++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/cron-sample.sh b/cron-sample.sh index 0e5a804..b38db5c 100644 --- a/cron-sample.sh +++ b/cron-sample.sh @@ -8,8 +8,10 @@ # 4- instance domain (https:// is automatically added) # 5- max age (in days) # 6- footer tags to add (optional) +# 7- delay (optional) +# 8- visibility unlisted (if 0 or unset visibility is public, if 1 visibility is unlisted) python3 tootbot.py geonym_fr geonym@amicale.net **password** test.amicale.net python3 tootbot.py cq94 cquest@amicale.net **password** test.amicale.net -python3 tootbot.py https://www.data.gouv.fr/fr/datasets/recent.atom cquest+opendata@amicale.net **password** amicale.net 2 "#dataset #opendata #datagouvfr" +python3 tootbot.py https://www.data.gouv.fr/fr/datasets/recent.atom cquest+opendata@amicale.net **password** amicale.net 2 "#dataset #opendata #datagouvfr" 0 1 diff --git a/tootbot.py b/tootbot.py index 4d586fd..b948ed9 100755 --- a/tootbot.py +++ b/tootbot.py @@ -37,7 +37,7 @@ def unredir(redir): if len(sys.argv) < 4: - print("Usage: python3 tootbot.py twitter_account mastodon_login mastodon_passwd mastodon_instance [max_days [footer_tags [delay]]]") # noqa + print("Usage: python3 tootbot.py twitter_account mastodon_login mastodon_passwd mastodon_instance [max_days [footer_tags [delay [unlisted]]]]") # noqa sys.exit(1) if len(sys.argv) > 4: @@ -60,6 +60,11 @@ if len(sys.argv) > 7: else: delay = 0 +if len(sys.argv) > 8 and (int(sys.argv[8]) == 1): + mastodon_visibility = "unlisted" +else: + mastodon_visibility = "public" + source = sys.argv[1] mastodon = sys.argv[2] passwd = sys.argv[3] @@ -203,7 +208,7 @@ if source[:4] == 'http': in_reply_to_id=None, media_ids=toot_media, sensitive=False, - visibility='public', + visibility=mastodon_visibility, spoiler_text=None) if "id" in toot: db.execute("INSERT INTO tweets VALUES ( ? , ? , ? , ? , ? )", @@ -334,7 +339,7 @@ else: in_reply_to_id=None, media_ids=toot_media, sensitive=False, - visibility='unlisted', + visibility=mastodon_visibility, spoiler_text=None) except: print("10s delay") @@ -343,7 +348,7 @@ else: in_reply_to_id=None, media_ids=toot_media, sensitive=False, - visibility='unlisted', + visibility=mastodon_visibility, spoiler_text=None) pass