Don't throw an exception when it cannot connect to nekos.life
This commit is contained in:
parent
81b3d012b8
commit
7daa29a2e2
|
@ -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,9 +8,13 @@ from .. import config, help_dict, log_errors, session, slave, public_log_errors
|
|||
|
||||
help_text = ''
|
||||
|
||||
resp = requests.get('https://nekos.life/api/v2/endpoints')
|
||||
json = resp.json()
|
||||
for i in json:
|
||||
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()
|
||||
if i.startswith('/api/v2/img/<\''):
|
||||
|
@ -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><command without dot></i>')
|
||||
help_dict['nekos'] = ('Nekos.life', help_text + '\nCan also be activated inline with: @{bot} <i><command without dot></i>')
|
||||
|
|
|
@ -1,12 +1,17 @@
|
|||
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
|
||||
|
||||
resp = requests.get('https://nekos.life/api/v2/endpoints')
|
||||
json = resp.json()
|
||||
for i in json:
|
||||
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()
|
||||
if i.startswith('/api/v2/img/<\''):
|
||||
|
|
Loading…
Reference in New Issue