mirror of
https://github.com/PaiGramTeam/PamGram.git
synced 2024-11-16 12:02:16 +00:00
🐛 Fix TypeError
exception caused by characters
is None
This commit is contained in:
parent
15f50253a3
commit
1f1734ca03
@ -221,6 +221,10 @@ class PlayerCards(Plugin):
|
|||||||
if isinstance(data, str):
|
if isinstance(data, str):
|
||||||
await callback_query.answer(text=data, show_alert=True)
|
await callback_query.answer(text=data, show_alert=True)
|
||||||
return
|
return
|
||||||
|
if data.characters is None:
|
||||||
|
await message.delete()
|
||||||
|
await callback_query.answer("请先将角色加入到角色展柜并允许查看角色详情后再使用此功能,如果已经添加了角色,请等待角色数据更新后重试", show_alert=True)
|
||||||
|
return
|
||||||
buttons = self.gen_button(data, user.id, uid, update_button=False)
|
buttons = self.gen_button(data, user.id, uid, update_button=False)
|
||||||
render_data = await self.parse_holder_data(data)
|
render_data = await self.parse_holder_data(data)
|
||||||
holder = await self.template_service.render(
|
holder = await self.template_service.render(
|
||||||
@ -313,14 +317,16 @@ class PlayerCards(Plugin):
|
|||||||
update_button: bool = True,
|
update_button: bool = True,
|
||||||
) -> List[List[InlineKeyboardButton]]:
|
) -> List[List[InlineKeyboardButton]]:
|
||||||
"""生成按钮"""
|
"""生成按钮"""
|
||||||
buttons = [
|
buttons = []
|
||||||
InlineKeyboardButton(
|
if data.characters:
|
||||||
value.name,
|
buttons = [
|
||||||
callback_data=f"get_player_card|{user_id}|{uid}|{value.name}",
|
InlineKeyboardButton(
|
||||||
)
|
value.name,
|
||||||
for value in data.characters
|
callback_data=f"get_player_card|{user_id}|{uid}|{value.name}",
|
||||||
if value.name
|
)
|
||||||
]
|
for value in data.characters
|
||||||
|
if value.name
|
||||||
|
]
|
||||||
all_buttons = [buttons[i : i + 4] for i in range(0, len(buttons), 4)]
|
all_buttons = [buttons[i : i + 4] for i in range(0, len(buttons), 4)]
|
||||||
send_buttons = all_buttons[(page - 1) * 3 : page * 3]
|
send_buttons = all_buttons[(page - 1) * 3 : page * 3]
|
||||||
last_page = page - 1 if page > 1 else 0
|
last_page = page - 1 if page > 1 else 0
|
||||||
|
Loading…
Reference in New Issue
Block a user