♻️ refactor(command): 黑白名单过滤从 AND 改为 OR 逻辑

- 白名单模式:用户在名单 OR 群在名单 → 放行
- 黑名单模式:用户在名单 OR 群在名单 → 拒绝
- 名单为空时表示不限制
- 更新前端提示说明 OR 逻辑的语义
This commit is contained in:
2026-05-04 00:05:18 +08:00
parent 58e53c8aec
commit 783049257e
2 changed files with 18 additions and 14 deletions

View File

@@ -125,18 +125,18 @@ class WebHookPlugin(NcatBotPlugin):
# 黑白名单过滤
if command.list_enabled:
if command.list_mode == "allow":
# 白名单模式:在名单内才放行
if command.allowed_groups and is_group:
if event.data.group_id not in command.allowed_groups:
# 白名单模式OR 逻辑):用户在名单 OR 群在名单 → 放行
# 名单为空时视为不限制
if command.allowed_users or command.allowed_groups:
user_ok = event.data.user_id in command.allowed_users
group_ok = is_group and event.data.group_id in command.allowed_groups
if not (user_ok or group_ok):
continue
if command.allowed_users and event.data.user_id not in command.allowed_users:
continue
elif command.list_mode == "deny":
# 黑名单模式:在名单内则拒绝
if command.denied_groups and is_group:
if event.data.group_id in command.denied_groups:
continue
if command.denied_users and event.data.user_id in command.denied_users:
# 黑名单模式:用户在名单 OR 群在名单 → 拒绝
user_blocked = event.data.user_id in command.denied_users
group_blocked = is_group and event.data.group_id in command.denied_groups
if user_blocked or group_blocked:
continue
# 构建回调数据