🐛 Fix stats plugin player_id check

This commit is contained in:
xtaodada 2024-04-12 22:34:22 +08:00
parent 3295afa8f5
commit 3936c14d00
Signed by: xtaodada
GPG Key ID: 4CBB3F4FA8C85659

View File

@ -36,13 +36,8 @@ class PlayerStatsPlugins(Plugin):
uid: Optional[int] = None uid: Optional[int] = None
try: try:
args = context.args args = context.args
if args is not None and len(args) >= 1: if args is not None and len(args) == 9:
uid = int(args[0]) uid = int(args[0])
except ValueError as exc:
logger.warning("获取 uid 发生错误! 错误信息为 %s", str(exc))
await message.reply_text("输入错误")
return
try:
async with self.helper.genshin_or_public(user_id) as client: async with self.helper.genshin_or_public(user_id) as client:
if not client.public: if not client.public:
await client.get_record_cards() await client.get_record_cards()
@ -55,6 +50,10 @@ class PlayerStatsPlugins(Plugin):
logger.exception(exc) logger.exception(exc)
await message.reply_text("角色数据有误 估计是派蒙晕了") await message.reply_text("角色数据有误 估计是派蒙晕了")
return return
except ValueError as exc:
logger.warning("获取 uid 发生错误! 错误信息为 %s", str(exc))
await message.reply_text("输入错误")
return
await message.reply_chat_action(ChatAction.UPLOAD_PHOTO) await message.reply_chat_action(ChatAction.UPLOAD_PHOTO)
await render_result.reply_photo(message, filename=f"{client.player_id}.png", allow_sending_without_reply=True) await render_result.reply_photo(message, filename=f"{client.player_id}.png", allow_sending_without_reply=True)