simplify gen.py logic a bit
This commit is contained in:
parent
c7c2c6adcf
commit
0ca511e848
10
gen.py
10
gen.py
|
@ -30,15 +30,17 @@ async def main():
|
||||||
toot = toot.replace("@", "@\u200b") # sanitize mentions
|
toot = toot.replace("@", "@\u200b") # sanitize mentions
|
||||||
toot = utils.remove_mentions(cfg, toot)
|
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:
|
try:
|
||||||
print(toot)
|
print(toot)
|
||||||
except UnicodeEncodeError:
|
except UnicodeEncodeError:
|
||||||
print(toot.encode("ascii", "ignore")) # encode as ASCII, dropping any non-ASCII characters
|
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__':
|
if __name__ == '__main__':
|
||||||
import anyio
|
import anyio
|
||||||
anyio.run(main)
|
anyio.run(main)
|
||||||
|
|
Loading…
Reference in New Issue