🎨 优化一部分使用体验,补全gs帮助

This commit is contained in:
Wuyi无疑 2023-03-27 00:36:25 +08:00
parent 46d4ff7f6b
commit 98e37957ec
15 changed files with 106 additions and 36 deletions

View File

@ -9,7 +9,7 @@ from .draw_abyss_card import draw_abyss_img
sv_abyss = SV('查询深渊')
@sv_abyss.on_command(('查询深渊', 'sy', '查询上期深渊', 'sqsy'), block=True)
@sv_abyss.on_command(('查询深渊', 'sy', '查询上期深渊', 'sqsy', '上期深渊'), block=True)
async def send_abyss_info(bot: Bot, ev: Event):
await bot.logger.info('开始执行[查询深渊信息]')
uid = await get_uid(bot, ev)

View File

@ -89,7 +89,8 @@ async def consume_remind(uid):
msg = f'取消公告红点完毕! 一共取消了{len(ids)}'
async with httpx.AsyncClient(
base_url="https://hk4e-api.mihoyo.com/common/hk4e_cn/announcement/api"
base_url='https://hk4e-api.mihoyo.com/common/hk4e_cn/announcement/api',
timeout=None,
) as client:
for ann_id in ids:
for p in platform:

View File

@ -57,7 +57,7 @@ def cache(ttl=datetime.timedelta(hours=1), **kwargs):
@cache(ttl=datetime.timedelta(minutes=30), arg_key='url')
async def cache_request_json(url):
async with httpx.AsyncClient() as client:
async with httpx.AsyncClient(timeout=None) as client:
res = await client.get(url, timeout=10)
return res.json(object_hook=_Dict)

View File

@ -2,6 +2,8 @@ import json
import time
from typing import List, Union, Literal, Optional
from httpx import ReadTimeout
from ..utils.error_reply import UID_HINT
from ..gsuid_utils.api.enka.models import EnkaData
from ..utils.resource.RESOURCE_PATH import PLAYER_PATH
@ -59,7 +61,10 @@ async def enka_to_dict(
if enka_data:
pass
else:
enka_data = await get_enka_info(uid, ENKA_API[0])
try:
enka_data = await get_enka_info(uid, ENKA_API[0])
except ReadTimeout:
return '网络不太稳定...'
if isinstance(enka_data, str):
return []
if isinstance(enka_data, dict):

View File

@ -89,6 +89,14 @@
"need_ck": true,
"need_sk": false,
"need_admin": false
},
{
"name": "留影叙佳期",
"desc": "获取当天的留影叙佳期画片",
"eg": "留影叙佳期",
"need_ck": true,
"need_sk": false,
"need_admin": false
}
]
},
@ -182,6 +190,14 @@
"need_ck": true,
"need_sk": false,
"need_admin": false
},
{
"name": "我的卡组",
"desc": "后可以跟数字指定套牌",
"eg": "我的卡组2",
"need_ck": true,
"need_sk": false,
"need_admin": false
}
]
},
@ -391,39 +407,47 @@
"desc": "获取游戏信息",
"data": [
{
"name": "武器",
"name": "武器介绍",
"desc": "武器信息,可后跟数字",
"eg": "武器天空、武器天空90",
"eg": "武器介绍天空、武器天空90",
"need_ck": false,
"need_sk": false,
"need_admin": false
},
{
"name": "角色",
"name": "角色介绍",
"desc": "角色信息,可后跟数字",
"eg": "角色七七90、角色真珠",
"eg": "角色介绍七七90、角色介绍真珠",
"need_ck": false,
"need_sk": false,
"need_admin": false
},
{
"name": "命座、天赋",
"name": "角色命座",
"desc": "角色命座和技能",
"eg": "命座6可莉、天赋4北斗",
"eg": "角色命座6可莉",
"need_ck": false,
"need_sk": false,
"need_admin": false
},
{
"name": "圣遗物",
"name": "角色天赋",
"desc": "角色技能介绍",
"eg": "角色天赋4北斗",
"need_ck": false,
"need_sk": false,
"need_admin": false
},
{
"name": "圣遗物介绍",
"desc": "查询圣遗物",
"eg": "圣遗物冰封",
"eg": "圣遗物介绍冰封",
"need_ck": false,
"need_sk": false,
"need_admin": false
},
{
"name": "食物、原魔",
"name": "食物介绍、原魔介绍",
"desc": "查询食物和怪物信息",
"eg": "食物鸡、原魔公子",
"need_ck": false,
@ -431,17 +455,9 @@
"need_admin": false
},
{
"name": "语音",
"desc": "查询角色语音",
"eg": "语音可莉357",
"need_ck": false,
"need_sk": false,
"need_admin": false
},
{
"name": "原牌",
"desc": "查询原牌",
"eg": "原牌神里、原牌运筹帷幄",
"name": "武器材料、角色材料",
"desc": "查询材料消耗",
"eg": "角色材料可莉",
"need_ck": false,
"need_sk": false,
"need_admin": false
@ -455,9 +471,9 @@
"need_admin": true
},
{
"name": "xx在哪",
"name": "哪里有xx",
"desc": "查找地图资源点",
"eg": "甜甜花在哪",
"eg": "哪里有甜甜花",
"need_ck": false,
"need_sk": false,
"need_admin": false
@ -601,5 +617,50 @@
"need_admin": false
}
]
},
"GsCore": {
"desc": "核心组件管理",
"data": [
{
"name": "启动core",
"desc": "能看到这想必不需要这个命令",
"eg": "启动core",
"need_ck": false,
"need_sk": false,
"need_admin": true
},
{
"name": "连接core",
"desc": "有时候意外失联",
"eg": "连接core",
"need_ck": false,
"need_sk": false,
"need_admin": true
},
{
"name": "gs关闭core",
"desc": "有时候只想单独关闭core",
"eg": "gs关闭core",
"need_ck": false,
"need_sk": false,
"need_admin": true
},
{
"name": "gs全部更新",
"desc": "更新core和v4插件",
"eg": "gs全部更新",
"need_ck": false,
"need_sk": false,
"need_admin": true
},
{
"name": "gs一键安装",
"desc": "能看到这想必不需要这个命令",
"eg": "gs一键安装",
"need_ck": false,
"need_sk": false,
"need_admin": true
}
]
}
}

View File

@ -15,7 +15,7 @@ async def draw_genshin_map(
try:
raw_data = await get_map_data(resource_name, map_id)
except MiniggNotFoundError:
return f'{resource_name} {map_id} 未找到...'
return f'未在{map_name}找到{resource_name}...'
with open(MAP_DATA / f'{map_name}_{resource_name}.jpg', 'wb') as f:
f.write(raw_data) # 保存到文件夹中
return raw_data

View File

@ -294,7 +294,7 @@ class MihoyoBBSCoin:
data: Dict = {},
) -> Dict:
for _ in range(2):
async with AsyncClient() as client:
async with AsyncClient(timeout=None) as client:
req = await client.request(
method=method,
url=url,

View File

@ -22,4 +22,4 @@ async def calc_reg_time(uid: str) -> str:
return f'UID{uid} 的注册时间为\n{regtime_date}'
except Exception as e:
logger.error(e)
return '数据获取错误, 可尝试使用“刷新ck”功能'
return '数据获取错误, 可尝试使用【刷新ck】或者发送【扫码登陆】以绑定CK'

View File

@ -22,7 +22,9 @@ async def get_akasha_abyss_info() -> AkashaAbyssData:
AkashaAbyssData: 虚空数据库 API 深渊出场数据响应数据
''' # noqa: E501
async with AsyncClient(
headers={'User-Agent': f'gsuid-utils/{__version__}'}, verify=False
headers={'User-Agent': f'gsuid-utils/{__version__}'},
verify=False,
timeout=None,
) as client:
req = await client.get(url=AKASHA_ABYSS_URL)
raw = req.text.lstrip('var static_abyss_total =')

View File

@ -81,7 +81,7 @@ async def _ambr_request(
params: Optional[AnyDict] = None,
data: Optional[AnyDict] = None,
) -> Optional[AnyDict]:
async with AsyncClient() as client:
async with AsyncClient(timeout=None) as client:
req = await client.request(
method, url=url, headers=header, params=params, json=data
)

View File

@ -31,6 +31,7 @@ async def get_enka_info(
async with AsyncClient(
base_url=ADDRESS[address],
headers={'User-Agent': f'gsuid-utils/{__version__}'},
timeout=None,
) as client:
req = await client.get(url=f'/api/uid/{uid}')
return req.json()

View File

@ -48,7 +48,7 @@ async def get_abyss_review(
async def get_abyss_review_raw() -> bytes:
async with AsyncClient(
headers={'User-Agent': f'gsuid-utils/{__version__}'},
headers={'User-Agent': f'gsuid-utils/{__version__}'}, timeout=None
) as client:
req = await client.get(url=HHW_ABYSS)
return req.read()

View File

@ -92,7 +92,7 @@ async def get_map_data(
Returns:
bytes: 图片
'''
async with AsyncClient() as client:
async with AsyncClient(timeout=None) as client:
req = await client.get(
url=MINIGG_MAP_URL,
params={
@ -121,7 +121,7 @@ async def get_audio_info(
str: 语音 URL
'''
warnings.warn('Audio API is already deprecated.', DeprecationWarning)
async with AsyncClient() as client:
async with AsyncClient(timeout=None) as client:
req = await client.get(
url=MINIGG_AUDIO_URL,
params={
@ -166,7 +166,7 @@ async def minigg_request(
}
if match_categories:
params['matchCategories'] = '1'
async with AsyncClient(base_url=MINIGG_URL) as client:
async with AsyncClient(base_url=MINIGG_URL, timeout=None) as client:
req = await client.get(endpoint, params=params)
data = req.json()
if 'retcode' in data:

View File

@ -34,7 +34,7 @@ async def get_pic(url, size: Optional[Tuple[int, int]] = None) -> Image.Image:
"""
从网络获取图片格式化为RGBA格式的指定尺寸
"""
async with httpx.AsyncClient() as client:
async with httpx.AsyncClient(timeout=None) as client:
resp = await client.get(url=url)
if resp.status_code != 200:
if size is None: