添加按钮

This commit is contained in:
a376148946 2023-12-02 17:17:19 +08:00
parent 91383b71b8
commit 2178d57c86
3 changed files with 30 additions and 6 deletions

View File

@ -13,7 +13,9 @@ from ..utils.sr_prefix import PREFIX
from ..utils.error_reply import UID_HINT
from .get_char_img import draw_char_info_img
from ..utils.image.convert import convert_img
from gsuid_core.message_models import Button
from ..utils.resource.RESOURCE_PATH import TEMP_PATH
from starrail_damage_cal.map.SR_MAP_PATH import avatarId2Name
sv_char_info_config = SV('sr面板设置', pm=2)
sv_get_char_info = SV('sr面板查询', priority=10)
@ -22,6 +24,7 @@ sv_get_sr_original_pic = SV('sr查看面板原图', priority=5)
@sv_get_char_info.on_prefix(f'{PREFIX}查询')
async def send_char_info(bot: Bot, ev: Event):
name = ev.text.strip()
im = await _get_char_info(bot, ev, ev.text)
if isinstance(im, str):
await bot.send(im)
@ -30,14 +33,27 @@ async def send_char_info(bot: Bot, ev: Event):
img = await convert_img(cast(Image.Image, im[0]))
else:
img = str(im[0])
await bot.send(img)
await bot.send_option(
img,
[
Button('🔄更换武器', f'sr查询{name}'),
Button('⏫提高命座', f'sr查询六魂{name}'),
],
)
if im[1]:
with Path.open(TEMP_PATH / f'{ev.msg_id}.jpg', 'wb') as f:
f.write(cast(bytes, im[1]))
elif isinstance(im, Image.Image):
await bot.send(await convert_img(im))
elif isinstance(im, bytes):
await bot.send(im)
# await bot.send(im)
await bot.send_option(
im,
[
Button('🔄更换武器', f'sr查询{name}', action = 2),
Button('⏫提高命座', f'sr查询六魂{name}', action = 2),
],
)
elif im is None:
return
else:
@ -72,5 +88,11 @@ async def send_card_info(bot: Bot, ev: Event):
await bot.logger.info(f'[sr强制刷新]uid: {uid}')
im = await api_to_card(uid)
await bot.logger.info(f'UID{uid}获取角色数据成功!')
if isinstance(im, Tuple):
buttons = [
Button(f'✅查询{avatarId2Name[str(avatarid)]}', f'sr查询{avatarId2Name[str(avatarid)]}')
for avatarid in im[1]
]
await bot.send_option(im[0], buttons)
else:
await bot.send(im)
return None

View File

@ -42,7 +42,8 @@ async def api_to_card(uid: str) -> Union[str, bytes]:
):
return await convert_img(pic_500)
return await draw_enka_card(uid=uid, char_list=char_id_list, showfrom=1)
img = await draw_enka_card(uid=uid, char_list=char_id_list, showfrom=1)
return img,char_id_list
async def draw_enka_card(uid: str, char_list: List, showfrom: int = 0):

View File

@ -118,7 +118,8 @@
"托帕&账账",
"托帕",
"账账",
"账账启动器"
"账账启动器",
"托帕 账账"
],
"1201": [
"青雀",