mirror of
https://github.com/KimigaiiWuyi/GenshinUID.git
synced 2025-05-07 04:03:45 +08:00
🎨 动态获取gs配置
中的相关信息 (#523)
This commit is contained in:
parent
b09b27f16f
commit
f7e10b7825
@ -66,6 +66,10 @@ async def draw_config_img(bot_id: str) -> Union[bytes, str]:
|
||||
|
||||
async def _draw_config_line(img: Image.Image, name: str, index: int):
|
||||
detail = gsconfig[name].desc
|
||||
if name == '定时签到':
|
||||
detail = f'开启后每晚{gsconfig[name].data}将开始自动签到任务'
|
||||
elif name == '定时米游币':
|
||||
detail = f'开启后每晚{gsconfig[name].data}将开始自动米游币任务'
|
||||
config_line = Image.open(TEXT_PATH / 'config_line.png')
|
||||
config_line_draw = ImageDraw.Draw(config_line)
|
||||
if name.startswith('定时'):
|
||||
|
6
GenshinUID/gsuid_utils/api/akashadata/api.py
Normal file
6
GenshinUID/gsuid_utils/api/akashadata/api.py
Normal file
@ -0,0 +1,6 @@
|
||||
AKASHA_ABYSS_URL = (
|
||||
'https://akashadata.feixiaoqiu.com/static/data/abyss_total.js'
|
||||
)
|
||||
AKASHA_RANK_URL = (
|
||||
'https://akashadata.feixiaoqiu.com/static/data/abyss_record_list.js'
|
||||
)
|
@ -1,6 +1,6 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import TypedDict
|
||||
from typing import List, TypedDict
|
||||
|
||||
|
||||
class TeamListItem(TypedDict):
|
||||
@ -86,3 +86,16 @@ class AkashaAbyssData(TypedDict):
|
||||
last_rate: LastRate
|
||||
level_data: LevelData
|
||||
character_used_list: list[CharacterUsedListItem]
|
||||
|
||||
|
||||
class AKaShaUsage(TypedDict):
|
||||
i: int
|
||||
v: str
|
||||
d: str
|
||||
r: int
|
||||
|
||||
|
||||
class AKaShaRank(TypedDict):
|
||||
usage_list: List[AKaShaUsage]
|
||||
maxrate_list: List[AKaShaUsage]
|
||||
out_list: List[AKaShaUsage]
|
||||
|
@ -4,15 +4,16 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
from typing import Literal, Optional
|
||||
|
||||
from httpx import AsyncClient
|
||||
|
||||
from ..types import AnyDict
|
||||
from ...version import __version__
|
||||
from .models import AkashaAbyssData
|
||||
from .models import AKaShaRank, AkashaAbyssData
|
||||
from .api import AKASHA_RANK_URL, AKASHA_ABYSS_URL
|
||||
|
||||
AKASHA_ABYSS_URL = (
|
||||
'https://akashadata.feixiaoqiu.com/static/data/abyss_total.js'
|
||||
)
|
||||
_HEADER = {'User-Agent': f'gsuid-utils/{__version__}'}
|
||||
|
||||
|
||||
async def get_akasha_abyss_info() -> AkashaAbyssData:
|
||||
@ -21,11 +22,38 @@ async def get_akasha_abyss_info() -> AkashaAbyssData:
|
||||
Returns:
|
||||
AkashaAbyssData: 虚空数据库 API 深渊出场数据响应数据
|
||||
''' # noqa: E501
|
||||
raw_data = await _akasha_request(AKASHA_ABYSS_URL)
|
||||
raw_data = raw_data.lstrip('var static_abyss_total =')
|
||||
data = json.loads(raw_data)
|
||||
return data
|
||||
|
||||
|
||||
async def get_akasha_abyss_rank(is_info: bool = False) -> AKaShaRank:
|
||||
raw_data = await _akasha_request(AKASHA_RANK_URL)
|
||||
raw_data = raw_data.lstrip('var static_abyss_total =')
|
||||
data_list = raw_data.split(';')
|
||||
data1 = data_list[0].lstrip('var static_schedule_version_dict =')
|
||||
data2 = data_list[1].lstrip('var static_abyss_record_dict =')
|
||||
schedule_version_dict = json.loads(data1)
|
||||
abyss_record_dict = json.loads(data2)
|
||||
if is_info:
|
||||
return schedule_version_dict
|
||||
return abyss_record_dict
|
||||
|
||||
|
||||
async def _akasha_request(
|
||||
url: str,
|
||||
method: Literal['GET', 'POST'] = 'GET',
|
||||
header: AnyDict = _HEADER,
|
||||
params: Optional[AnyDict] = None,
|
||||
data: Optional[AnyDict] = None,
|
||||
) -> str:
|
||||
async with AsyncClient(
|
||||
headers={'User-Agent': f'gsuid-utils/{__version__}'},
|
||||
headers=header,
|
||||
verify=False,
|
||||
timeout=None,
|
||||
) as client:
|
||||
req = await client.get(url=AKASHA_ABYSS_URL)
|
||||
raw = req.text.lstrip('var static_abyss_total =')
|
||||
return json.loads(raw)
|
||||
req = await client.request(
|
||||
method=method, url=url, params=params, data=data
|
||||
)
|
||||
return req.text
|
||||
|
12
poetry.lock
generated
12
poetry.lock
generated
@ -1395,14 +1395,14 @@ websockets = ["websockets (>=10.0,<11.0)"]
|
||||
|
||||
[[package]]
|
||||
name = "nonebug"
|
||||
version = "0.3.2"
|
||||
version = "0.3.3"
|
||||
description = "nonebot2 test framework"
|
||||
category = "dev"
|
||||
optional = false
|
||||
python-versions = ">=3.8,<4.0"
|
||||
files = [
|
||||
{file = "nonebug-0.3.2-py3-none-any.whl", hash = "sha256:d488a8147e33d149f24924e2b75a60fe4b3d80e3d039ddc74f07733714628bf9"},
|
||||
{file = "nonebug-0.3.2.tar.gz", hash = "sha256:11fce06c3a35c86a7e15eac8ca3556e4f735db425a8c823098208b19907a4de9"},
|
||||
{file = "nonebug-0.3.3-py3-none-any.whl", hash = "sha256:c3e53e9fe0859083512b78b1af5c29c2ba73b86957fac6a028f094a64a04ea5a"},
|
||||
{file = "nonebug-0.3.3.tar.gz", hash = "sha256:3ef520e60c9af97fc4f4dbddcc46723aedb8a127b84369b49d2e9a40bea5b799"},
|
||||
]
|
||||
|
||||
[package.dependencies]
|
||||
@ -1920,14 +1920,14 @@ use-chardet-on-py3 = ["chardet (>=3.0.2,<6)"]
|
||||
|
||||
[[package]]
|
||||
name = "setuptools"
|
||||
version = "67.7.1"
|
||||
version = "67.7.2"
|
||||
description = "Easily download, build, install, upgrade, and uninstall Python packages"
|
||||
category = "main"
|
||||
optional = false
|
||||
python-versions = ">=3.7"
|
||||
files = [
|
||||
{file = "setuptools-67.7.1-py3-none-any.whl", hash = "sha256:6f0839fbdb7e3cfef1fc38d7954f5c1c26bf4eebb155a55c9bf8faf997b9fb67"},
|
||||
{file = "setuptools-67.7.1.tar.gz", hash = "sha256:bb16732e8eb928922eabaa022f881ae2b7cdcfaf9993ef1f5e841a96d32b8e0c"},
|
||||
{file = "setuptools-67.7.2-py3-none-any.whl", hash = "sha256:23aaf86b85ca52ceb801d32703f12d77517b2556af839621c641fca11287952b"},
|
||||
{file = "setuptools-67.7.2.tar.gz", hash = "sha256:f104fa03692a2602fa0fec6c6a9e63b6c8a968de13e17c026957dd1f53d80990"},
|
||||
]
|
||||
|
||||
[package.extras]
|
||||
|
@ -44,7 +44,7 @@ python-multipart==0.0.6 ; python_full_version >= "3.8.1" and python_full_version
|
||||
pytz-deprecation-shim==0.1.0.post0 ; python_full_version >= "3.8.1" and python_version < "4.0"
|
||||
pytz==2023.3 ; python_full_version >= "3.8.1" and python_version < "4.0"
|
||||
qrcode[pil]==7.4.2 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
|
||||
setuptools==67.7.1 ; python_full_version >= "3.8.1" and python_version < "4.0"
|
||||
setuptools==67.7.2 ; python_full_version >= "3.8.1" and python_version < "4.0"
|
||||
six==1.16.0 ; python_full_version >= "3.8.1" and python_version < "4.0"
|
||||
smmap==5.0.0 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
|
||||
sniffio==1.3.0 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
|
||||
|
Loading…
x
Reference in New Issue
Block a user