🐛 Fix get_chat parse args

This commit is contained in:
xtaodada 2024-01-17 20:13:11 +08:00
parent 77f7555bbb
commit 24dfe2ce16
Signed by: xtaodada
GPG Key ID: 4CBB3F4FA8C85659
2 changed files with 10 additions and 4 deletions

View File

@ -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":

View File

@ -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)