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)