forgot to sanitize mentions in output
This commit is contained in:
parent
97a2f5de00
commit
5db218e362
7
gen.py
7
gen.py
|
@ -18,13 +18,18 @@ def parse_args():
|
||||||
)
|
)
|
||||||
return parser.parse_args()
|
return parser.parse_args()
|
||||||
|
|
||||||
|
PAIRED_PUNCTUATION = re.compile(r"[{}]".format(re.escape('[](){}"‘’“”«»„')))
|
||||||
|
|
||||||
async def main():
|
async def main():
|
||||||
args = parse_args()
|
args = parse_args()
|
||||||
cfg = utils.load_config(args.cfg)
|
cfg = utils.load_config(args.cfg)
|
||||||
|
|
||||||
toot = await utils.make_post(cfg, mode=utils.TextGenerationMode.__members__[args.mode])
|
toot = await utils.make_post(cfg, mode=utils.TextGenerationMode.__members__[args.mode])
|
||||||
if cfg['strip_paired_punctuation']:
|
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:
|
if not args.simulate:
|
||||||
async with Pleroma(api_base_url=cfg['site'], access_token=cfg['access_token']) as pl:
|
async with Pleroma(api_base_url=cfg['site'], access_token=cfg['access_token']) as pl:
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -54,7 +54,7 @@ def load_config(cfg_path):
|
||||||
|
|
||||||
return cfg
|
return cfg
|
||||||
|
|
||||||
def remove_mention(cfg, sentence):
|
def remove_mentions(cfg, sentence):
|
||||||
# optionally remove mentions
|
# optionally remove mentions
|
||||||
if cfg['mention_handling'] == 1:
|
if cfg['mention_handling'] == 1:
|
||||||
return re.sub(r"^\S*@\u200B\S*\s?", "", sentence)
|
return re.sub(r"^\S*@\u200B\S*\s?", "", sentence)
|
||||||
|
|
Loading…
Reference in New Issue