Compare commits
2 Commits
b6b96a8661
...
0ca511e848
Author | SHA1 | Date |
---|---|---|
Kay Faraday | 0ca511e848 | |
Kay Faraday | c7c2c6adcf |
20
gen.py
20
gen.py
|
@ -30,25 +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:
|
||||
try:
|
||||
await pl.post(toot, visibility='unlisted', cw=cfg['cw'])
|
||||
except Exception:
|
||||
import traceback
|
||||
toot = (
|
||||
'An error occurred while submitting the generated post. '
|
||||
'Contact KayFaraday@freak.university for assistance. Full traceback:\n\n'
|
||||
+ traceback.format_exc()
|
||||
)
|
||||
await pl.post(toot, visibility='unlisted', cw='Error!')
|
||||
raise
|
||||
|
||||
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)
|
||||
|
|
Loading…
Reference in New Issue