Handle exceptions with malformed reply command

This commit is contained in:
Mint 2023-03-06 02:27:13 +03:00
parent 90894fe346
commit f1656ff933

View file

@ -77,15 +77,19 @@ class ReplyBot:
if command in ('pin', 'unpin'):
await (self.pleroma.pin if command == 'pin' else self.pleroma.unpin)(target_post_id)
elif command == 'reply':
status = await self.pleroma.get_status(argument)
if status['content'] != "":
keywords = cleanup_toot(utils.extract_post_content(status['content']), self.cfg)
else:
keywords = None
try:
status = await self.pleroma.get_status(argument)
if status['content'] != "":
keywords = cleanup_toot(utils.extract_post_content(status['content']), self.cfg)
else:
keywords = None
toot = await utils.make_post(self.cfg, keywords)
toot = self.cleanup_toot(toot, self.cfg)
await self.pleroma.reply(status, toot, cw=self.cfg['cw'])
toot = await utils.make_post(self.cfg, keywords)
toot = self.cleanup_toot(toot, self.cfg)
await self.pleroma.reply(status, toot, cw=self.cfg['cw'])
except:
tg.start_soon(self.pleroma.react, post_id, '')
tg.start_soon(self.pleroma.reply, notification['status'], 'Error: ' + exc.args[0])
except pleroma.BadRequest as exc:
async with anyio.create_task_group() as tg:
tg.start_soon(self.pleroma.react, post_id, '')