From 802b9d3906f1e10b56ce39e2496f4f87bcf67335 Mon Sep 17 00:00:00 2001 From: Holly Date: Wed, 10 Mar 2021 02:57:43 +0000 Subject: [PATCH] more gracefully handle rate limiting (in theory anyway) --- mtgcardlookup.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/mtgcardlookup.py b/mtgcardlookup.py index 4513a3c..0067edb 100755 --- a/mtgcardlookup.py +++ b/mtgcardlookup.py @@ -220,9 +220,13 @@ async def listen(c, me): reply_text += '\n\n' + '\n'.join(cards) if media: - media_ids = [] - for image, desc in media: - media_ids.append((await c.upload_attachment(fileobj=image, params={}, description=desc))['id']) + try: + media_ids = [] + for image, desc in media: + media_ids.append((await c.upload_attachment(fileobj=image, params={}, description=desc))['id']) + except atoot.api.RatelimitError: + media_ids = None + reply_text += '\n\nMedia attachments are temporarily disabled due to API restrictions, they will return shortly.' except Exception as e: # Oops! log(traceback.print_exc(), Severity.ERROR)