mirror of
https://github.com/baiqwerdvd/StarRailUID.git
synced 2025-05-06 11:43:44 +08:00
✨深渊查询完善 (#38)
* 深渊查询完善
* 🚨 `pre-commit-ci`修复格式错误
* 深渊查询完善
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
parent
99a2930516
commit
008c066828
@ -31,11 +31,17 @@ async def send_srabyss_info(bot: Bot, ev: Event):
|
|||||||
schedule_type = '1'
|
schedule_type = '1'
|
||||||
await bot.logger.info('[sr查询深渊信息]深渊期数: {}'.format(schedule_type))
|
await bot.logger.info('[sr查询深渊信息]深渊期数: {}'.format(schedule_type))
|
||||||
|
|
||||||
if ev.text in ['九', '十', '十一', '十二']:
|
if ev.text in ['一', '二', '三', '四', '五', '六', '七', '八', '九', '十']:
|
||||||
floor = (
|
floor = (
|
||||||
ev.text.replace('九', '9')
|
ev.text.replace('一', '1')
|
||||||
.replace('十一', '11')
|
.replace('二', '2')
|
||||||
.replace('十二', '12')
|
.replace('三', '3')
|
||||||
|
.replace('四', '4')
|
||||||
|
.replace('五', '5')
|
||||||
|
.replace('六', '6')
|
||||||
|
.replace('七', '7')
|
||||||
|
.replace('八', '8')
|
||||||
|
.replace('九', '9')
|
||||||
.replace('十', '10')
|
.replace('十', '10')
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
@ -44,10 +50,10 @@ async def send_srabyss_info(bot: Bot, ev: Event):
|
|||||||
floor = int(floor)
|
floor = int(floor)
|
||||||
else:
|
else:
|
||||||
floor = None
|
floor = None
|
||||||
|
# print(floor)
|
||||||
await bot.logger.info('[sr查询深渊信息]深渊层数: {}'.format(floor))
|
await bot.logger.info('[sr查询深渊信息]深渊层数: {}'.format(floor))
|
||||||
# data = GsCookie()
|
# data = GsCookie()
|
||||||
# raw_abyss_data = await data.get_spiral_abyss_data(uid, schedule_type)
|
# raw_abyss_data = await data.get_spiral_abyss_data(uid, schedule_type)
|
||||||
# print(raw_abyss_data)
|
# print(raw_abyss_data)
|
||||||
im = await draw_abyss_img(ev.user_id, uid, schedule_type)
|
im = await draw_abyss_img(ev.user_id, uid, floor, schedule_type)
|
||||||
await bot.send(im)
|
await bot.send(im)
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
import asyncio
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Union
|
from typing import Union, Optional
|
||||||
|
|
||||||
from PIL import Image, ImageDraw
|
from PIL import Image, ImageDraw
|
||||||
from gsuid_core.logger import logger
|
from gsuid_core.logger import logger
|
||||||
@ -10,8 +9,6 @@ from .utils import get_icon
|
|||||||
from ..utils.convert import GsCookie
|
from ..utils.convert import GsCookie
|
||||||
from ..utils.image.convert import convert_img
|
from ..utils.image.convert import convert_img
|
||||||
from ..sruid_utils.api.mys.models import AbyssAvatar
|
from ..sruid_utils.api.mys.models import AbyssAvatar
|
||||||
|
|
||||||
# )
|
|
||||||
from ..utils.image.image_tools import get_qq_avatar, draw_pic_with_ring
|
from ..utils.image.image_tools import get_qq_avatar, draw_pic_with_ring
|
||||||
from ..utils.fonts.starrail_fonts import (
|
from ..utils.fonts.starrail_fonts import (
|
||||||
sr_font_22,
|
sr_font_22,
|
||||||
@ -21,10 +18,18 @@ from ..utils.fonts.starrail_fonts import (
|
|||||||
sr_font_42,
|
sr_font_42,
|
||||||
)
|
)
|
||||||
|
|
||||||
# from ..utils.resource.download_url import download_file
|
abyss_list = {
|
||||||
# from ..utils.resource.generate_char_card import create_single_char_card
|
'1': '琥珀恩赐其一',
|
||||||
# from ..utils.resource.RESOURCE_PATH import (
|
'2': '琥珀恩赐其二',
|
||||||
# CHAR_ICON_PATH,
|
'3': '琥珀恩赐其三',
|
||||||
|
'4': '琥珀恩赐其四',
|
||||||
|
'5': '琥珀恩赐其五',
|
||||||
|
'6': '琥珀恩赐其六',
|
||||||
|
'7': '琥珀恩赐其七',
|
||||||
|
'8': '琥珀恩赐其八',
|
||||||
|
'9': '琥珀恩赐其九',
|
||||||
|
'10': '琥珀恩赐其十',
|
||||||
|
}
|
||||||
|
|
||||||
TEXT_PATH = Path(__file__).parent / 'texture2D'
|
TEXT_PATH = Path(__file__).parent / 'texture2D'
|
||||||
white_color = (255, 255, 255)
|
white_color = (255, 255, 255)
|
||||||
@ -134,6 +139,7 @@ async def _draw_floor_card(
|
|||||||
async def draw_abyss_img(
|
async def draw_abyss_img(
|
||||||
qid: Union[str, int],
|
qid: Union[str, int],
|
||||||
uid: str,
|
uid: str,
|
||||||
|
floor: Optional[int] = None,
|
||||||
schedule_type: str = '1',
|
schedule_type: str = '1',
|
||||||
) -> Union[bytes, str]:
|
) -> Union[bytes, str]:
|
||||||
# 获取Cookies
|
# 获取Cookies
|
||||||
@ -156,30 +162,21 @@ async def draw_abyss_img(
|
|||||||
# char_temp = {}
|
# char_temp = {}
|
||||||
|
|
||||||
# 获取查询者数据
|
# 获取查询者数据
|
||||||
# if floor:
|
if floor:
|
||||||
# floor = floor - 9
|
floor_num = 1
|
||||||
# if floor < 0:
|
if floor > 10:
|
||||||
# return '楼层不能小于9层!'
|
return '楼层不能大于10层!'
|
||||||
# if len(raw_abyss_data['floors']) >= floor + 1:
|
if len(raw_abyss_data['all_floor_detail']) < floor:
|
||||||
# floors_data = raw_abyss_data['floors'][floor]
|
return '你还没有挑战该层!'
|
||||||
# else:
|
else:
|
||||||
# return '你还没有挑战该层!'
|
if raw_abyss_data['max_floor'] == '':
|
||||||
# else:
|
return '你还没有挑战本期深渊!\n可以使用[sr上期深渊]命令查询上期~'
|
||||||
# if len(raw_abyss_data['floors']) == 0:
|
floor_num = len(raw_abyss_data['all_floor_detail'])
|
||||||
# return '你还没有挑战本期深渊!\n可以使用[上期深渊]命令查询上期~'
|
|
||||||
# floors_data = raw_abyss_data['floors'][-1]
|
|
||||||
if raw_abyss_data['max_floor'] == '':
|
|
||||||
return '你还没有挑战本期深渊!\n可以使用[sr上期深渊]命令查询上期~'
|
|
||||||
# if floors_data['levels'][-1]['battles']:
|
|
||||||
# is_unfull = False
|
|
||||||
# else:
|
|
||||||
# is_unfull = True
|
|
||||||
|
|
||||||
# 获取背景图片各项参数
|
# 获取背景图片各项参数
|
||||||
based_w = 900
|
based_w = 900
|
||||||
floor_num = len(raw_abyss_data['all_floor_detail'])
|
|
||||||
if floor_num >= 3:
|
if floor_num >= 3:
|
||||||
based_h = 1227
|
based_h = 2367
|
||||||
else:
|
else:
|
||||||
based_h = 657 + 570 * floor_num
|
based_h = 657 + 570 * floor_num
|
||||||
img = img_bg.copy()
|
img = img_bg.copy()
|
||||||
@ -233,7 +230,6 @@ async def draw_abyss_img(
|
|||||||
'lm',
|
'lm',
|
||||||
)
|
)
|
||||||
|
|
||||||
task = []
|
|
||||||
for index_floor, level in enumerate(raw_abyss_data['all_floor_detail']):
|
for index_floor, level in enumerate(raw_abyss_data['all_floor_detail']):
|
||||||
if index_floor >= 3:
|
if index_floor >= 3:
|
||||||
break
|
break
|
||||||
@ -279,28 +275,21 @@ async def draw_abyss_img(
|
|||||||
# )
|
# )
|
||||||
# char_temp[char["id"]] = talent_num
|
# char_temp[char["id"]] = talent_num
|
||||||
# break
|
# break
|
||||||
task.append(
|
await _draw_abyss_card(
|
||||||
_draw_abyss_card(
|
char,
|
||||||
char,
|
0, # type: ignore
|
||||||
0, # type: ignore
|
floor_pic,
|
||||||
floor_pic,
|
index_char,
|
||||||
index_char,
|
index_part,
|
||||||
index_part,
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
await asyncio.gather(*task)
|
await _draw_floor_card(
|
||||||
task.clear()
|
level_star,
|
||||||
task.append(
|
floor_pic,
|
||||||
_draw_floor_card(
|
img,
|
||||||
level_star,
|
index_floor,
|
||||||
floor_pic,
|
floor_name,
|
||||||
img,
|
round_num,
|
||||||
index_floor,
|
|
||||||
floor_name,
|
|
||||||
round_num,
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
await asyncio.gather(*task)
|
|
||||||
|
|
||||||
# title_data = {
|
# title_data = {
|
||||||
# '最强一击!': damage_rank[0],
|
# '最强一击!': damage_rank[0],
|
||||||
|
@ -197,6 +197,8 @@ class MysApi(_MysApi):
|
|||||||
'CHALLENGE_INFO_URL',
|
'CHALLENGE_INFO_URL',
|
||||||
uid,
|
uid,
|
||||||
params={
|
params={
|
||||||
|
'isPrev': 'true',
|
||||||
|
'need_all': 'true',
|
||||||
'role_id': uid,
|
'role_id': uid,
|
||||||
'schedule_type': schedule_type,
|
'schedule_type': schedule_type,
|
||||||
'server': server_id,
|
'server': server_id,
|
||||||
@ -204,7 +206,7 @@ class MysApi(_MysApi):
|
|||||||
cookie=ck,
|
cookie=ck,
|
||||||
header=self._HEADER,
|
header=self._HEADER,
|
||||||
)
|
)
|
||||||
print(data)
|
# print(data)
|
||||||
if isinstance(data, Dict):
|
if isinstance(data, Dict):
|
||||||
data = cast(AbyssData, data['data'])
|
data = cast(AbyssData, data['data'])
|
||||||
return data
|
return data
|
||||||
|
Loading…
x
Reference in New Issue
Block a user