Handle exception when connecting to sibyl

This commit is contained in:
blank X 2022-01-25 22:25:01 +07:00
parent ca25d44b9e
commit 3f04d08d1b
Signed by: blankie
GPG Key ID: CC15FC822C7F61F5
1 changed files with 7 additions and 2 deletions

View File

@ -208,8 +208,13 @@ async def get_spam_protection(entity):
async def get_sibyl(entity):
if not config['config'].get('sibyl_api'):
return '- <b>404:</b> Missing sibyl api key'
async with session.get(f'https://psychopass.animekaizoku.com/getInfo?token={config["config"]["sibyl_api"]}&userid={entity}') as resp:
json = await resp.json()
status = 500
try:
async with session.get(f'https://psychopass.animekaizoku.com/getInfo?token={config["config"]["sibyl_api"]}&userid={entity}') as resp:
status = resp.status
json = await resp.json()
except BaseException as ex:
return f'- <b>{status}:</b> {html.escape(type(ex).__name__)}: {html.escape(str(ex).replace(config["config"]["sibyl_api"], "<api key>"))}'
if json['error']:
return f'- <b>{json["error"]["code"]}:</b> {html.escape(json["error"]["message"])}'
json = json['result']