mirror of
https://git.kiwifarms.net/mint/ebooks.git
synced 2024-10-22 23:19:07 +00:00
Handle exceptions with malformed reply command
This commit is contained in:
parent
90894fe346
commit
f1656ff933
1 changed files with 12 additions and 8 deletions
20
reply.py
20
reply.py
|
@ -77,15 +77,19 @@ class ReplyBot:
|
||||||
if command in ('pin', 'unpin'):
|
if command in ('pin', 'unpin'):
|
||||||
await (self.pleroma.pin if command == 'pin' else self.pleroma.unpin)(target_post_id)
|
await (self.pleroma.pin if command == 'pin' else self.pleroma.unpin)(target_post_id)
|
||||||
elif command == 'reply':
|
elif command == 'reply':
|
||||||
status = await self.pleroma.get_status(argument)
|
try:
|
||||||
if status['content'] != "":
|
status = await self.pleroma.get_status(argument)
|
||||||
keywords = cleanup_toot(utils.extract_post_content(status['content']), self.cfg)
|
if status['content'] != "":
|
||||||
else:
|
keywords = cleanup_toot(utils.extract_post_content(status['content']), self.cfg)
|
||||||
keywords = None
|
else:
|
||||||
|
keywords = None
|
||||||
|
|
||||||
toot = await utils.make_post(self.cfg, keywords)
|
toot = await utils.make_post(self.cfg, keywords)
|
||||||
toot = self.cleanup_toot(toot, self.cfg)
|
toot = self.cleanup_toot(toot, self.cfg)
|
||||||
await self.pleroma.reply(status, toot, cw=self.cfg['cw'])
|
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:
|
except pleroma.BadRequest as exc:
|
||||||
async with anyio.create_task_group() as tg:
|
async with anyio.create_task_group() as tg:
|
||||||
tg.start_soon(self.pleroma.react, post_id, '❌')
|
tg.start_soon(self.pleroma.react, post_id, '❌')
|
||||||
|
|
Loading…
Reference in a new issue