From 526ec8cf178038526bc331cb6949db3827a8225f Mon Sep 17 00:00:00 2001 From: sam01101 Date: Tue, 5 Oct 2021 23:24:48 +0800 Subject: [PATCH] [fix] `block` and `unblock` command not handling params (#136) --- pagermaid/modules/account.py | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/pagermaid/modules/account.py b/pagermaid/modules/account.py index f135c87..d9fea9e 100644 --- a/pagermaid/modules/account.py +++ b/pagermaid/modules/account.py @@ -285,23 +285,21 @@ async def block_user(context): return await context.edit(lang('block_process')) + user = None if context.reply_to_msg_id: reply_message = await context.get_reply_message() user = reply_message.sender_id else: if len(context.parameter) == 1: - user = context.parameter[0] + [user] = context.parameter if user.isnumeric(): user = int(user) + elif context.message.entities is not None: + if isinstance(context.message.entities[0], MessageEntityMentionName): + user = context.message.entities[0].user_id else: user_object = await context.client.get_me() user = user_object.id - if context.message.entities is not None: - if isinstance(context.message.entities[0], MessageEntityMentionName): - user = context.message.entities[0].user_id - else: - await context.edit(f"{lang('error_prefix')}{lang('arg_error')}") - return result = None if not user: await context.edit(f"{lang('error_prefix')}{lang('arg_error')}") @@ -326,23 +324,21 @@ async def unblock_user(context): return await context.edit(lang('unblock_process')) + user = None if context.reply_to_msg_id: reply_message = await context.get_reply_message() user = reply_message.from_id.user_id else: if len(context.parameter) == 1: - user = context.parameter[0] + [user] = context.parameter if user.isnumeric(): user = int(user) + elif context.message.entities is not None: + if isinstance(context.message.entities[0], MessageEntityMentionName): + user = context.message.entities[0].user_id else: user_object = await context.client.get_me() user = user_object.id - if context.message.entities is not None: - if isinstance(context.message.entities[0], MessageEntityMentionName): - user = context.message.entities[0].user_id - else: - await context.edit(f"{lang('error_prefix')}{lang('arg_error')}") - return result = None if not user: await context.edit(f"{lang('error_prefix')}{lang('arg_error')}")