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 os
|
||||||
|
import logging
|
||||||
import requests
|
import requests
|
||||||
from pyrogram import Client, filters
|
from pyrogram import Client, filters
|
||||||
from pyrogram.types.messages_and_media import Photo, Animation
|
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 = ''
|
help_text = ''
|
||||||
|
|
||||||
|
try:
|
||||||
resp = requests.get('https://nekos.life/api/v2/endpoints')
|
resp = requests.get('https://nekos.life/api/v2/endpoints')
|
||||||
json = resp.json()
|
json = resp.json()
|
||||||
|
except Exception:
|
||||||
|
logging.exception('Cannot connect to nekos.life')
|
||||||
|
else:
|
||||||
for i in json:
|
for i in json:
|
||||||
_, i = i.split(' ', 1)
|
_, i = i.split(' ', 1)
|
||||||
i = i.strip()
|
i = i.strip()
|
||||||
|
@ -43,5 +48,4 @@ for i in json:
|
||||||
func = None
|
func = None
|
||||||
help_text += '{prefix}' + i.lower() + f' - Gets a {"gif" if "gif" in i else "picture"} of {i.lower()}\n'
|
help_text += '{prefix}' + i.lower() + f' - Gets a {"gif" if "gif" in i else "picture"} of {i.lower()}\n'
|
||||||
break
|
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,11 +1,16 @@
|
||||||
import os
|
import os
|
||||||
|
import logging
|
||||||
import requests
|
import requests
|
||||||
from pyrogram import Client, filters
|
from pyrogram import Client, filters
|
||||||
from pyrogram.types import InputTextMessageContent, InlineQueryResultArticle, InlineQueryResultPhoto, InlineQueryResultAnimation
|
from pyrogram.types import InputTextMessageContent, InlineQueryResultArticle, InlineQueryResultPhoto, InlineQueryResultAnimation
|
||||||
from .. import log_errors, session, app_user_ids
|
from .. import log_errors, session, app_user_ids
|
||||||
|
|
||||||
|
try:
|
||||||
resp = requests.get('https://nekos.life/api/v2/endpoints')
|
resp = requests.get('https://nekos.life/api/v2/endpoints')
|
||||||
json = resp.json()
|
json = resp.json()
|
||||||
|
except Exception:
|
||||||
|
logging.exception('Cannot connect to nekos.life')
|
||||||
|
else:
|
||||||
for i in json:
|
for i in json:
|
||||||
_, i = i.split(' ', 1)
|
_, i = i.split(' ', 1)
|
||||||
i = i.strip()
|
i = i.strip()
|
||||||
|
|
Loading…
Reference in New Issue