Files
nonebot-plugin-tetris-stats/nonebot_plugin_tetris_stats/Utils/Request.py
scdhh f1291a9923 修复所有type hint(当时写的时候mypy炸了
使用神秘新架构
独立request模块
版本推进
fixed #1 [BUG] 茶服无法查询用户名内带有大写字母的用户
2022-07-24 17:24:37 +08:00

18 lines
544 B
Python

from nonebot.log import logger
from typing import Any
import aiohttp
async def request(Url: str) -> tuple[bool, bool, dict[str, Any]]:
# 封装请求函数
try:
async with aiohttp.ClientSession() as session:
async with session.get(Url) as resp:
data = await resp.json()
return (True, data['success'], data)
except aiohttp.client_exceptions.ClientConnectorError as e:
logger.error(f'[TETRIS STATS] request.request: 请求错误\n{e}')
return (False, False, {})