From 7ab92b630c04dd5230cc260eea07b7c780126761 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B4=9B=E6=B0=B4=E5=B1=85=E5=AE=A4?= Date: Mon, 23 Jan 2023 21:34:13 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Add=20Allow=20Bind=20User=20Invite?= =?UTF-8?q?=20Bot?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/config.py | 1 + plugins/system/chat_member.py | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/core/config.py b/core/config.py index 9724ffb2..9c928d8d 100644 --- a/core/config.py +++ b/core/config.py @@ -21,6 +21,7 @@ dotenv.load_dotenv() class JoinGroups(str, Enum): NO_ALLOW = "NO_ALLOW" ALLOW_AUTH_USER = "ALLOW_AUTH_USER" + ALLOW_USER = "ALLOW_USER" ALLOW_ALL = "ALLOW_ALL" diff --git a/plugins/system/chat_member.py b/plugins/system/chat_member.py index 0e24d2f8..feab54c2 100644 --- a/plugins/system/chat_member.py +++ b/plugins/system/chat_member.py @@ -71,6 +71,15 @@ class ChatMember(Plugin): logger.error("获取信息出现错误", exc_info=exc) else: quit_status = False + elif config.join_groups == JoinGroups.ALLOW_USER: + try: + await self.user_service.get_user_by_id(user.id) + except UserNotFoundError: + logger.warning("用户 %s[%s] 邀请请求被拒绝", user.full_name, user.id) + except Exception as exc: + logger.error("获取信息出现错误", exc_info=exc) + else: + quit_status = False elif config.join_groups == JoinGroups.ALLOW_ALL: quit_status = False else: