mirror of
https://github.com/A-Minos/nonebot-plugin-tetris-stats.git
synced 2026-03-05 05:36:54 +08:00
修复所有type hint(当时写的时候mypy炸了
使用神秘新架构 独立request模块 版本推进 fixed #1 [BUG] 茶服无法查询用户名内带有大写字母的用户
This commit is contained in:
17
nonebot_plugin_tetris_stats/Utils/Request.py
Normal file
17
nonebot_plugin_tetris_stats/Utils/Request.py
Normal file
@@ -0,0 +1,17 @@
|
||||
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, {})
|
||||
Reference in New Issue
Block a user