Don't throw an exception when it cannot connect to nekos.life

This commit is contained in:
blank X 2020-11-24 15:17:50 +07:00
parent 81b3d012b8
commit 7daa29a2e2
2 changed files with 74 additions and 65 deletions

View File

@ -1,4 +1,5 @@
import os
import logging
import requests
from pyrogram import Client, filters
from pyrogram.types.messages_and_media import Photo, Animation
@ -7,8 +8,12 @@ from .. import config, help_dict, log_errors, session, slave, public_log_errors
help_text = ''
try:
resp = requests.get('https://nekos.life/api/v2/endpoints')
json = resp.json()
except Exception:
logging.exception('Cannot connect to nekos.life')
else:
for i in json:
_, i = i.split(' ', 1)
i = i.strip()
@ -43,5 +48,4 @@ for i in json:
func = None
help_text += '{prefix}' + i.lower() + f' - Gets a {"gif" if "gif" in i else "picture"} of {i.lower()}\n'
break
help_dict['nekos'] = ('Nekos.life', help_text + '\nCan also be activated inline with: @{bot} <i>&lt;command without dot&gt;</i>')

View File

@ -1,11 +1,16 @@
import os
import logging
import requests
from pyrogram import Client, filters
from pyrogram.types import InputTextMessageContent, InlineQueryResultArticle, InlineQueryResultPhoto, InlineQueryResultAnimation
from .. import log_errors, session, app_user_ids
try:
resp = requests.get('https://nekos.life/api/v2/endpoints')
json = resp.json()
except Exception:
logging.exception('Cannot connect to nekos.life')
else:
for i in json:
_, i = i.split(' ', 1)
i = i.strip()