From f79a749e9e9a8f54c7ddfc8fc1e9f253c643d0dd Mon Sep 17 00:00:00 2001 From: Mint <> Date: Mon, 6 Mar 2023 02:09:46 +0300 Subject: [PATCH] Option to post in public --- config.defaults.json | 1 + gen.py | 7 ++++++- pleroma.py | 6 +++++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/config.defaults.json b/config.defaults.json index c069dba..16e48e0 100644 --- a/config.defaults.json +++ b/config.defaults.json @@ -1,5 +1,6 @@ { "site": "https://botsin.space", + "public": false, "cw": null, "fetch_delay": 1, "learn_from_cw": false, diff --git a/gen.py b/gen.py index 7385e51..92bac67 100755 --- a/gen.py +++ b/gen.py @@ -24,6 +24,11 @@ async def main(): args = parse_args() cfg = utils.load_config(args.cfg) + if cfg['public']: + visibility = 'public' + else: + visibility = 'unlisted' + toot = await utils.make_post(cfg, mode=utils.TextGenerationMode.__members__[args.mode]) if cfg['strip_paired_punctuation']: toot = PAIRED_PUNCTUATION.sub("", toot) @@ -33,7 +38,7 @@ async def main(): if not args.simulate: async with Pleroma(api_base_url=cfg['site'], access_token=cfg['access_token']) as pl: try: - await pl.post(toot, visibility='unlisted', cw=cfg['cw']) + await pl.post(toot, visibility=visibility, cw=cfg['cw']) except Exception: raise diff --git a/pleroma.py b/pleroma.py index 1430486..a77e412 100644 --- a/pleroma.py +++ b/pleroma.py @@ -94,7 +94,11 @@ class Pleroma: content = ''.join('@' + x + ' ' for x in mentioned_accounts.values()) + content - visibility = 'unlisted' if to_status['visibility'] == 'public' else to_status['visibility'] + if cfg['public']: + visibility = 'public' + else: + visibility = 'unlisted' + visibility = visibility if to_status['visibility'] == 'public' else to_status['visibility'] if not cw and 'spoiler_text' in to_status and to_status['spoiler_text']: cw = 're: ' + to_status['spoiler_text']