🎨 优化使用体验

This commit is contained in:
Wuyi无疑 2023-04-15 01:38:51 +08:00
parent 1f41172b8d
commit b4f2389191
11 changed files with 1208 additions and 28 deletions

1
.gitignore vendored
View File

@ -685,6 +685,7 @@ help.png
review.json
gs_data
*.xlsx
GenshinUID Help.xlsx
### Debug ###
testnb2/

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,8 @@
import json
from pathlib import Path
from ..utils.map.name_covert import alias_to_char_name
with open(
Path(__file__).parent / 'char_adv_list.json', "r", encoding='UTF-8'
) as f:
@ -48,7 +50,8 @@ async def weapon_adv(name):
return im
async def char_adv(name):
async def char_adv(name: str):
name = await alias_to_char_name(name)
for char, info in adv_lst.items():
if name in char:
im = [f'{char}', '-=-=-=-=-=-=-=-=-=-']

View File

@ -23,12 +23,12 @@ red_color = (255, 66, 66)
green_color = (74, 189, 119)
max_data = {
'成就': 944,
'华丽的宝箱': 185,
'珍贵的宝箱': 509,
'成就': 945,
'华丽的宝箱': 192,
'珍贵的宝箱': 510,
'精致的宝箱': 1639,
'普通的宝箱': 2687,
'奇馈宝箱': 146,
'普通的宝箱': 2690,
'奇馈宝箱': 161,
'解锁传送点': 304,
'解锁秘境': 51,
}

View File

@ -26,7 +26,7 @@ async def draw_config_img(bot_id: str) -> Union[bytes, str]:
sqla = get_sqla(bot_id)
# 获取背景图片各项参数
based_w = 850
based_h = 850 + 155 * (len(gsconfig) - 5)
based_h = 850 + 155 * (len(gsconfig) - 8)
CI_img = CustomizeImage('', based_w, based_h)
img = CI_img.bg_img

View File

@ -76,6 +76,7 @@ async def send_link_uid_msg(bot: Bot, ev: Event):
0: f'绑定UID{uid}成功!',
-1: f'UID{uid}的位数不正确!',
-2: f'UID{uid}已经绑定过了!',
-3: '你输入了错误的格式!',
},
)
elif ev.command.startswith('切换'):

View File

@ -52,9 +52,12 @@ class SQLA:
async def insert_bind_data(self, user_id: str, **data) -> int:
async with self.async_session() as session:
async with session.begin():
new_uid = data['uid'] if 'uid' in data else ''
new_uid: str = data['uid'] if 'uid' in data else ''
new_uid = new_uid.strip()
if len(new_uid) != 9:
return -1
elif not new_uid.isdigit():
return -3
if await self.bind_exists(user_id):
uid_list = await self.get_bind_uid_list(user_id)
if new_uid not in uid_list:

View File

@ -13,11 +13,17 @@ sample = {
char_json = {}
path = Path(__file__).parents[1] / 'genshinuid_adv'
data_path = Path(__file__).parent / 'help_data'
wb = load_workbook(str(path / 'Genshin All Char.xlsx'))
wb = load_workbook(str(data_path / 'Genshin All Char.xlsx'))
ws = wb.active
for char_i in range(2, 336, 5): # 角色行
for char_i in range(2, 1700, 5): # 角色行
char = ws.cell(char_i, 1).value
if char is None:
for _i in range(5):
val = ws.cell(char_i + _i, 1).value
if val is not None:
char = val
if not isinstance(char, str):
continue
char_name = char.replace('\n', '')

View File

@ -0,0 +1,31 @@
from typing import Literal, Optional
from PIL import Image
from aiohttp.client import ClientSession
AMBR_UI = 'https://api.ambr.top/assets/UI/{}.png'
ENKA_UI = 'https://enka.network/ui/{}.png'
async def _get_assets(
name: str, type: Literal['ENKA', 'AMBR'] = 'AMBR'
) -> Optional[Image.Image]:
if type == 'AMBR':
URL = AMBR_UI
else:
URL = ENKA_UI
async with ClientSession() as sess:
async with sess.get(URL.format(name)) as res:
if res.status == 200:
content = await res.read()
return Image.open(content)
else:
return None
async def get_assets_from_enka(name: str) -> Optional[Image.Image]:
return await _get_assets(name, 'ENKA')
async def get_assets_from_ambr(name: str) -> Optional[Image.Image]:
return await _get_assets(name, 'AMBR')

6
poetry.lock generated
View File

@ -593,14 +593,14 @@ test = ["pytest (>=6)"]
[[package]]
name = "fastapi"
version = "0.95.0"
version = "0.95.1"
description = "FastAPI framework, high performance, easy to learn, fast to code, ready for production"
category = "main"
optional = false
python-versions = ">=3.7"
files = [
{file = "fastapi-0.95.0-py3-none-any.whl", hash = "sha256:daf73bbe844180200be7966f68e8ec9fd8be57079dff1bacb366db32729e6eb5"},
{file = "fastapi-0.95.0.tar.gz", hash = "sha256:99d4fdb10e9dd9a24027ac1d0bd4b56702652056ca17a6c8721eec4ad2f14e18"},
{file = "fastapi-0.95.1-py3-none-any.whl", hash = "sha256:a870d443e5405982e1667dfe372663abf10754f246866056336d7f01c21dab07"},
{file = "fastapi-0.95.1.tar.gz", hash = "sha256:9569f0a381f8a457ec479d90fa01005cfddaae07546eb1f3fa035bc4797ae7d5"},
]
[package.dependencies]

View File

@ -17,7 +17,7 @@ email-validator==1.3.1 ; python_full_version >= "3.8.1" and python_full_version
et-xmlfile==1.1.0 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
fastapi-amis-admin==0.5.4 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
fastapi-user-auth==0.5.0 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
fastapi==0.95.0 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
fastapi==0.95.1 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
frozenlist==1.3.3 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
gitdb==4.0.10 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
gitpython==3.1.31 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"