mirror of
https://github.com/NovaOSS/nova-api.git
synced 2024-11-25 20:53:58 +01:00
a few more nice changes
This commit is contained in:
parent
f4a09515fe
commit
1da39e5242
|
@ -3,11 +3,14 @@
|
||||||
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.
|
"""
|
||||||
The schmea in which <provider_and_key> should be passed is:
|
|
||||||
<provider_name><key>, e.g.
|
Invalidates a key stored in the secret/ folder by storing it in the associated .invalid.txt file.
|
||||||
closed4>sk-...
|
The schmea in which <provider_and_key> should be passed is:
|
||||||
"""
|
<provider_name><key>, e.g.
|
||||||
|
closed4>sk-...
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
if not provider_and_key:
|
if not provider_and_key:
|
||||||
return
|
return
|
||||||
|
|
|
@ -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
|
||||||
|
|
Loading…
Reference in a new issue