forgot to sanitize mentions in output

This commit is contained in:
io 2021-08-17 05:55:29 +00:00
parent 97a2f5de00
commit 5db218e362
2 changed files with 7 additions and 2 deletions

7
gen.py
View File

@ -18,13 +18,18 @@ def parse_args():
)
return parser.parse_args()
PAIRED_PUNCTUATION = re.compile(r"[{}]".format(re.escape('[](){}"‘’“”«»„')))
async def main():
args = parse_args()
cfg = utils.load_config(args.cfg)
toot = await utils.make_post(cfg, mode=utils.TextGenerationMode.__members__[args.mode])
if cfg['strip_paired_punctuation']:
toot = re.sub(r"[\[\]\(\)\{\}\"“”«»„]", "", toot)
toot = PAIRED_PUNCTUATION.sub("", toot)
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:

View File

@ -54,7 +54,7 @@ def load_config(cfg_path):
return cfg
def remove_mention(cfg, sentence):
def remove_mentions(cfg, sentence):
# optionally remove mentions
if cfg['mention_handling'] == 1:
return re.sub(r"^\S*@\u200B\S*\s?", "", sentence)