mirror of
https://git.kiwifarms.net/mint/ebooks.git
synced 2024-10-22 23:29:06 +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'):
|
||||
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, '❌')
|
||||
|
|
Loading…
Reference in a new issue