a few more nice changes

This commit is contained in:
Game_Time 2023-08-12 21:05:53 +05:00
parent f4a09515fe
commit 1da39e5242
2 changed files with 10 additions and 9 deletions

View file

@ -3,10 +3,13 @@
import asyncio import asyncio
async def invalidate_key(provider_and_key: str) -> none: async def invalidate_key(provider_and_key: str) -> none:
"""Invalidates a key stored in the secret/ folder by storing it in the associated .invalid.txt file. """
Invalidates a key stored in the secret/ folder by storing it in the associated .invalid.txt file.
The schmea in which <provider_and_key> should be passed is: The schmea in which <provider_and_key> should be passed is:
<provider_name><key>, e.g. <provider_name><key>, e.g.
closed4>sk-... closed4>sk-...
""" """
if not provider_and_key: if not provider_and_key:

View file

@ -96,12 +96,11 @@ async def stream(
webhook = dhooks.Webhook(os.getenv('DISCORD_WEBHOOK__API_ISSUE')) webhook = dhooks.Webhook(os.getenv('DISCORD_WEBHOOK__API_ISSUE'))
webhook.send(content=f'API Issue: **`{exc}`**\nhttps://i.imgflip.com/7uv122.jpg') webhook.send(content=f'API Issue: **`{exc}`**\nhttps://i.imgflip.com/7uv122.jpg')
error = await errors.yield_error( yield await errors.yield_error(
500, 500,
'Sorry, the API has no working keys anymore.', 'Sorry, the API has no working keys anymore.',
'The admins have been messaged automatically.' 'The admins have been messaged automatically.'
) )
yield error
return return
for k, v in target_request.get('headers', {}).items(): for k, v in target_request.get('headers', {}).items():
@ -180,12 +179,11 @@ async def stream(
except Exception as exc: except Exception as exc:
if 'Connection closed' in str(exc): if 'Connection closed' in str(exc):
error = await errors.yield_error( yield await errors.yield_error(
500, 500,
'Sorry, there was an issue with the connection.', 'Sorry, there was an issue with the connection.',
'Please first check if the issue on your end. If this error repeats, please don\'t heistate to contact the staff!.' 'Please first check if the issue on your end. If this error repeats, please don\'t heistate to contact the staff!.'
) )
yield error
return return
break break