From 179e6c54554c9ad3919795102fcfb5e485556406 Mon Sep 17 00:00:00 2001 From: blank X Date: Tue, 25 Jan 2022 22:26:22 +0700 Subject: [PATCH] Handle exception when trying to connect to SPB --- sukuinote/plugins/einfo.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/sukuinote/plugins/einfo.py b/sukuinote/plugins/einfo.py index 38f43aa..63386c8 100644 --- a/sukuinote/plugins/einfo.py +++ b/sukuinote/plugins/einfo.py @@ -174,11 +174,13 @@ async def get_cas(entity): return f'- XXX: {html.escape(json.get("description", "XXX"))}' async def get_spam_protection(entity): - async with session.get(f'https://api.intellivoid.net/spamprotection/v1/lookup?query={entity}') as resp: - try: + status = 500 + try: + async with session.get(f'https://api.intellivoid.net/spamprotection/v1/lookup?query={entity}') as resp: + status = resp.staus json = await resp.json() - except BaseException as ex: - return f'- {resp.status}: {html.escape(type(ex).__name__)}: {html.escape(str(ex))}' + except BaseException as ex: + return f'- {status}: {html.escape(type(ex).__name__)}: {html.escape(str(ex))}' if json['success']: text = '' if json['results']['private_telegram_id']: