更新 Auth 模块的权限逻辑

This commit is contained in:
洛水居室 2022-07-17 12:08:09 +08:00
parent 6e8f3c16bd
commit ba3f936558
No known key found for this signature in database
GPG Key ID: C9DE87DA724B88FC

View File

@ -196,6 +196,9 @@ class Auth:
if user.id == context.bot.id:
return
Log.info(f"用户 {user.full_name}[{user.id}] 尝试加入群 {chat.title}[{chat.id}]")
not_enough_rights = context.chat_data.get("not_enough_rights", False)
if not_enough_rights:
return
if message.from_user.id in await get_admin_list(
bot=context.bot,
cache=self.service.cache,
@ -216,9 +219,11 @@ class Auth:
permissions=ChatPermissions(can_send_messages=False))
except BadRequest as err:
if "Not enough rights" in str(err):
Log.warning(f"权限不够 chat_id[{message.chat_id}]", err)
await message.reply_markdown_v2(f"派蒙无法修改 {user.mention_markdown_v2()} 的权限!"
f"请检查是否给派蒙授权管理了")
Log.warning(f"权限不够 chat_id[{message.chat_id}]")
reply_message = await message.reply_markdown_v2(f"派蒙无法修改 {user.mention_markdown_v2()} 的权限!"
f"请检查是否给派蒙授权管理了")
context.chat_data["not_enough_rights"] = True
await self.clean_message(context, chat.id, context.bot.id, reply_message.message_id)
return
else:
raise err