diff --git a/BlueArchiveUID/bauid_info/draw_user_info_pic.py b/BlueArchiveUID/bauid_info/draw_user_info_pic.py index 50a738c..9778d07 100644 --- a/BlueArchiveUID/bauid_info/draw_user_info_pic.py +++ b/BlueArchiveUID/bauid_info/draw_user_info_pic.py @@ -148,6 +148,7 @@ async def draw_assist_card(assist: Union[AssistInfo, RankAssistInfo]): 'mm', ) assist_card.paste(equip_bg, (304 + eindex * 131, 306), equip_bg) + return assist_card diff --git a/BlueArchiveUID/bauid_ranklist/__init__.py b/BlueArchiveUID/bauid_ranklist/__init__.py index c598630..65baae7 100644 --- a/BlueArchiveUID/bauid_ranklist/__init__.py +++ b/BlueArchiveUID/bauid_ranklist/__init__.py @@ -7,6 +7,13 @@ sv_ba_xtzx_rank = SV('BA什亭之匣学生排行榜') -@sv_ba_xtzx_rank.on_command(('ba学生排行')) +@sv_ba_xtzx_rank.on_command( + ( + 'ba学生排行', + 'ba学生排名', + 'ba角色排名', + 'ba角色排行', + ) +) async def send_rank_msg(bot: Bot, ev: Event): await bot.send(await draw_rank_pic(ev.text.strip())) diff --git a/BlueArchiveUID/bauid_ranklist/draw_rank_pic.py b/BlueArchiveUID/bauid_ranklist/draw_rank_pic.py index e98417f..4d4f8cc 100644 --- a/BlueArchiveUID/bauid_ranklist/draw_rank_pic.py +++ b/BlueArchiveUID/bauid_ranklist/draw_rank_pic.py @@ -29,6 +29,7 @@ async def draw_rank_pic(student: str) -> Union[bytes, str]: student_id = student_name_to_id(student) if student_id == '9999': return '要查询的角色不存在或别名未收录, 请尝试使用完整名字。' + data = await xtzx_api.get_xtzx_friend_ranking(1, student_id) if isinstance(data, int): return get_error(data) @@ -37,7 +38,6 @@ async def draw_rank_pic(student: str) -> Union[bytes, str]: img = get_bg(1100, 2800) for index, teacher in enumerate(teacher_data): info = teacher['assistInfoList'][0] - assist_card = await draw_assist_card(info) rank_key = info['baRank']['key'] rank_value = info['baRank']['value'] rank_str = f'{rank_key} / {rank_value}' @@ -50,6 +50,7 @@ async def draw_rank_pic(student: str) -> Union[bytes, str]: global_rank_color = get_color(global_rank_key) card = Image.open(TEXT_PATH / 'card.png') + card_draw = ImageDraw.Draw(card) card_draw.text( @@ -92,9 +93,10 @@ async def draw_rank_pic(student: str) -> Union[bytes, str]: cf(24), 'mm', ) - card.paste(assist_card, (0, 40), assist_card) + assist_card = await draw_assist_card(info) img.paste(card, (0, 28 + index * 550), card) + img.paste(assist_card, (0, 68 + index * 550), assist_card) img = await convert_img(img) return img diff --git a/BlueArchiveUID/utils/api/api.py b/BlueArchiveUID/utils/api/api.py index f552c25..c026c67 100644 --- a/BlueArchiveUID/utils/api/api.py +++ b/BlueArchiveUID/utils/api/api.py @@ -18,3 +18,4 @@ XTZX_FRIEND_REFRESH = XTZX_API + '/api/friends/refresh' XTZX_ASSIST = XTZX_API + '/api/friends/assist_query' XTZX_FRIEND_RANK = XTZX_API + '/api/friends/rank' +XTZX_FIND_RANK = XTZX_API + '/api/friends/findRank' diff --git a/BlueArchiveUID/utils/api/request.py b/BlueArchiveUID/utils/api/request.py index 40ec83e..79ec22b 100644 --- a/BlueArchiveUID/utils/api/request.py +++ b/BlueArchiveUID/utils/api/request.py @@ -9,6 +9,7 @@ ARONA_URL, BATTLE_URL, XTZX_RAID_TOP, + XTZX_FIND_RANK, XTZX_RAID_LIST, XTZX_RAID_RANK, XTZX_RAID_CHART, @@ -199,6 +200,25 @@ async def get_xtzx_friend_data( else: return -500 + async def get_xtzx_find_rank( + self, + friend_code: str, + ) -> Union[int, FriendData]: + data = await self._ba_request( + XTZX_FIND_RANK, + 'POST', + json={ + 'friend': friend_code, + }, + ) + if isinstance(data, Dict) and 'code' in data: + if data['code'] == 200: + return cast(FriendData, data['data']) + else: + return data['code'] + else: + return -500 + async def get_xtzx_friend_ranking( self, page: int,