Customizable visibility of toots (public/unlisted)

This commit is contained in:
Raphael Fetzer 2023-01-21 13:48:38 +01:00
parent 13bb1b6785
commit 7d03160f43
2 changed files with 12 additions and 5 deletions

View File

@ -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

View File

@ -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