From 24dfe2ce16e9922ce63a01968c15f70c11905921 Mon Sep 17 00:00:00 2001 From: xtaodada Date: Wed, 17 Jan 2024 20:13:11 +0800 Subject: [PATCH] :bug: Fix get_chat parse args --- plugins/admin/get_chat.py | 7 +++++-- plugins/admin/group_manage.py | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/plugins/admin/get_chat.py b/plugins/admin/get_chat.py index a6c7d2a..f7206fe 100644 --- a/plugins/admin/get_chat.py +++ b/plugins/admin/get_chat.py @@ -82,8 +82,11 @@ class GetChat(Plugin): def get_chat_id(self, context: "ContextTypes.DEFAULT_TYPE") -> Optional[int]: args = self.get_args(context) - if args and len(args) > 1 and args[0].isnumeric(): - return int(args[0]) + if args: + try: + return int(args[0]) + except ValueError: + return None @staticmethod def gen_button(chat_id: int) -> "InlineKeyboardMarkup": diff --git a/plugins/admin/group_manage.py b/plugins/admin/group_manage.py index 8df31e3..f3e5f43 100644 --- a/plugins/admin/group_manage.py +++ b/plugins/admin/group_manage.py @@ -57,8 +57,11 @@ class GroupManage(Plugin): def get_chat_id(self, context: "ContextTypes.DEFAULT_TYPE") -> Optional[int]: args = self.get_args(context) - if args and len(args) > 1 and args[0].isnumeric(): - return int(args[0]) + if args: + try: + return int(args[0]) + except ValueError: + return None async def add_block_group(self, chat_id: int): group = await self.group_service.get_group_by_id(chat_id)