From 3f04d08d1b916afd80145733751c0518423f7b4b Mon Sep 17 00:00:00 2001 From: blank X Date: Tue, 25 Jan 2022 22:25:01 +0700 Subject: [PATCH] Handle exception when connecting to sibyl --- sukuinote/plugins/einfo.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/sukuinote/plugins/einfo.py b/sukuinote/plugins/einfo.py index bdfcacb..38f43aa 100644 --- a/sukuinote/plugins/einfo.py +++ b/sukuinote/plugins/einfo.py @@ -208,8 +208,13 @@ async def get_spam_protection(entity): async def get_sibyl(entity): if not config['config'].get('sibyl_api'): return '- 404: 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'- {status}: {html.escape(type(ex).__name__)}: {html.escape(str(ex).replace(config["config"]["sibyl_api"], ""))}' if json['error']: return f'- {json["error"]["code"]}: {html.escape(json["error"]["message"])}' json = json['result']