🐛 修复回复消息时 photoNone 引发的错误

This commit is contained in:
洛水居室 2022-10-19 15:14:41 +08:00
parent ab2c0226b8
commit 55f3086c4c
No known key found for this signature in database
GPG Key ID: C9DE87DA724B88FC

View File

@ -1,4 +1,4 @@
from typing import Any, List, Tuple, Union
from typing import Any, List, Tuple, Union, Optional
from enkanetwork import (
CharacterInfo,
@ -44,7 +44,7 @@ class PlayerCards(Plugin, BasePlugin):
self.user_service = user_service
self.client = EnkaNetworkAPI(lang="chs", agent=config.enka_network_api_agent)
self.template_service = template_service
self.temp_photo = open("resources/img/kitsune.png", "rb")
self.temp_photo: Optional[str] = None
async def _fetch_user(self, uid) -> Union[EnkaNetworkResponse, str]:
try:
@ -115,8 +115,12 @@ class PlayerCards(Plugin, BasePlugin):
temp = []
if len(temp) > 0:
buttons.append(temp)
if isinstance(self.temp_photo, str):
photo = self.temp_photo
else:
photo = open("resources/img/kitsune.png", "rb")
reply_message = await message.reply_photo(
photo=self.temp_photo, caption="请选择你要查询的角色", reply_markup=InlineKeyboardMarkup(buttons)
photo=photo, caption="请选择你要查询的角色", reply_markup=InlineKeyboardMarkup(buttons)
)
if reply_message.photo:
self.temp_photo = reply_message.photo[-1].file_id