From 0ca511e8489a20bd0956371dd4d23c3c40ba3bde Mon Sep 17 00:00:00 2001 From: Kay Faraday Date: Fri, 12 Aug 2022 00:33:34 +0000 Subject: [PATCH] simplify gen.py logic a bit --- gen.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/gen.py b/gen.py index d0b5f80..458d4d5 100755 --- a/gen.py +++ b/gen.py @@ -30,15 +30,17 @@ async def main(): toot = toot.replace("@", "@\u200b") # sanitize mentions toot = utils.remove_mentions(cfg, toot) - if not args.simulate: - async with Pleroma(api_base_url=cfg['site'], access_token=cfg['access_token']) as pl: - await pl.post(toot, visibility='unlisted', cw=cfg['cw']) - try: print(toot) except UnicodeEncodeError: print(toot.encode("ascii", "ignore")) # encode as ASCII, dropping any non-ASCII characters + if args.simulate: + return + + async with Pleroma(api_base_url=cfg['site'], access_token=cfg['access_token']) as pl: + await pl.post(toot, visibility='unlisted', cw=cfg['cw']) + if __name__ == '__main__': import anyio anyio.run(main)