more gracefully handle rate limiting (in theory anyway)

This commit is contained in:
Holly 2021-03-10 02:57:43 +00:00
parent adf781c48f
commit 802b9d3906
1 changed files with 7 additions and 3 deletions

View File

@ -220,9 +220,13 @@ async def listen(c, me):
reply_text += '\n\n' + '\n'.join(cards)
if media:
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)