From bcf2ad4ba1175966c03b1733a2dd56e47f64adf5 Mon Sep 17 00:00:00 2001 From: Holly Date: Sat, 13 Mar 2021 03:33:56 +0000 Subject: [PATCH] Don't choke when the status fails to send --- mtgcardlookup.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/mtgcardlookup.py b/mtgcardlookup.py index d178fe4..769c7c3 100755 --- a/mtgcardlookup.py +++ b/mtgcardlookup.py @@ -239,8 +239,14 @@ async def listen(c, me): reply_text = f'{status_author} Sorry! You broke me somehow. Please let Holly know what you did!' log('Sending reply...') - reply = await c.create_status(status=reply_text, media_ids=media_ids, in_reply_to_id=status_id, visibility=reply_visibility) - log(f'Reply sent! {reply["uri"]}') + try: + reply = await c.create_status(status=reply_text, media_ids=media_ids, in_reply_to_id=status_id, visibility=reply_visibility) + log(f'Reply sent! {reply["uri"]}') + except atoot.api.UnprocessedError as e: + log(f'Could not send reply!', Severity.ERROR) + log(traceback.format_exc(), Severity.ERROR) + error_msg = 'An error occured sending the reply. This most likely means that it would have been greater than 500 characters. If it was something else, please let Holly know!' + await c.create_status(status=f'{status_author} {error_msg}', in_reply_to_id=status_id, visibility=reply_visibility) # https://stackoverflow.com/a/55505152/2114129 async def repeat(interval, func, *args, **kwargs):