深渊查询完善 (#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:
季落 2023-05-18 22:27:26 +08:00 committed by GitHub
parent 99a2930516
commit 008c066828
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 53 additions and 56 deletions

View File

@ -31,11 +31,17 @@ async def send_srabyss_info(bot: Bot, ev: Event):
schedule_type = '1'
await bot.logger.info('[sr查询深渊信息]深渊期数: {}'.format(schedule_type))
if ev.text in ['', '', '十一', '']:
if ev.text in ['', '', '', '', '', '', '', '', '', '']:
floor = (
ev.text.replace('', '9')
.replace('十一', '11')
.replace('十二', '12')
ev.text.replace('', '1')
.replace('', '2')
.replace('', '3')
.replace('', '4')
.replace('', '5')
.replace('', '6')
.replace('', '7')
.replace('', '8')
.replace('', '9')
.replace('', '10')
)
else:
@ -44,10 +50,10 @@ async def send_srabyss_info(bot: Bot, ev: Event):
floor = int(floor)
else:
floor = None
# print(floor)
await bot.logger.info('[sr查询深渊信息]深渊层数: {}'.format(floor))
# data = GsCookie()
# raw_abyss_data = await data.get_spiral_abyss_data(uid, schedule_type)
# 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)

View File

@ -1,6 +1,5 @@
import asyncio
from pathlib import Path
from typing import Union
from typing import Union, Optional
from PIL import Image, ImageDraw
from gsuid_core.logger import logger
@ -10,8 +9,6 @@ from .utils import get_icon
from ..utils.convert import GsCookie
from ..utils.image.convert import convert_img
from ..sruid_utils.api.mys.models import AbyssAvatar
# )
from ..utils.image.image_tools import get_qq_avatar, draw_pic_with_ring
from ..utils.fonts.starrail_fonts import (
sr_font_22,
@ -21,10 +18,18 @@ from ..utils.fonts.starrail_fonts import (
sr_font_42,
)
# from ..utils.resource.download_url import download_file
# from ..utils.resource.generate_char_card import create_single_char_card
# from ..utils.resource.RESOURCE_PATH import (
# CHAR_ICON_PATH,
abyss_list = {
'1': '琥珀恩赐其一',
'2': '琥珀恩赐其二',
'3': '琥珀恩赐其三',
'4': '琥珀恩赐其四',
'5': '琥珀恩赐其五',
'6': '琥珀恩赐其六',
'7': '琥珀恩赐其七',
'8': '琥珀恩赐其八',
'9': '琥珀恩赐其九',
'10': '琥珀恩赐其十',
}
TEXT_PATH = Path(__file__).parent / 'texture2D'
white_color = (255, 255, 255)
@ -134,6 +139,7 @@ async def _draw_floor_card(
async def draw_abyss_img(
qid: Union[str, int],
uid: str,
floor: Optional[int] = None,
schedule_type: str = '1',
) -> Union[bytes, str]:
# 获取Cookies
@ -156,30 +162,21 @@ async def draw_abyss_img(
# char_temp = {}
# 获取查询者数据
# if floor:
# floor = floor - 9
# if floor < 0:
# return '楼层不能小于9层!'
# if len(raw_abyss_data['floors']) >= floor + 1:
# floors_data = raw_abyss_data['floors'][floor]
# else:
# return '你还没有挑战该层!'
# else:
# if len(raw_abyss_data['floors']) == 0:
# return '你还没有挑战本期深渊!\n可以使用[上期深渊]命令查询上期~'
# floors_data = raw_abyss_data['floors'][-1]
if floor:
floor_num = 1
if floor > 10:
return '楼层不能大于10层!'
if len(raw_abyss_data['all_floor_detail']) < floor:
return '你还没有挑战该层!'
else:
if raw_abyss_data['max_floor'] == '':
return '你还没有挑战本期深渊!\n可以使用[sr上期深渊]命令查询上期~'
# if floors_data['levels'][-1]['battles']:
# is_unfull = False
# else:
# is_unfull = True
floor_num = len(raw_abyss_data['all_floor_detail'])
# 获取背景图片各项参数
based_w = 900
floor_num = len(raw_abyss_data['all_floor_detail'])
if floor_num >= 3:
based_h = 1227
based_h = 2367
else:
based_h = 657 + 570 * floor_num
img = img_bg.copy()
@ -233,7 +230,6 @@ async def draw_abyss_img(
'lm',
)
task = []
for index_floor, level in enumerate(raw_abyss_data['all_floor_detail']):
if index_floor >= 3:
break
@ -279,19 +275,14 @@ async def draw_abyss_img(
# )
# char_temp[char["id"]] = talent_num
# break
task.append(
_draw_abyss_card(
await _draw_abyss_card(
char,
0, # type: ignore
floor_pic,
index_char,
index_part,
)
)
await asyncio.gather(*task)
task.clear()
task.append(
_draw_floor_card(
await _draw_floor_card(
level_star,
floor_pic,
img,
@ -299,8 +290,6 @@ async def draw_abyss_img(
floor_name,
round_num,
)
)
await asyncio.gather(*task)
# title_data = {
# '最强一击!': damage_rank[0],

View File

@ -197,6 +197,8 @@ class MysApi(_MysApi):
'CHALLENGE_INFO_URL',
uid,
params={
'isPrev': 'true',
'need_all': 'true',
'role_id': uid,
'schedule_type': schedule_type,
'server': server_id,
@ -204,7 +206,7 @@ class MysApi(_MysApi):
cookie=ck,
header=self._HEADER,
)
print(data)
# print(data)
if isinstance(data, Dict):
data = cast(AbyssData, data['data'])
return data