feat(command): 黑白名单开关、自动保存与管理界面重构

- 新增 list_enabled 开关控制是否启用名单过滤
- 表单变更后 800ms 自动保存,去掉手动保存按钮
- Header 显示"未保存"指示器,保存中 toast 提示
- 内容区限制最大宽度 900px,优化宽屏显示
- 侧边栏增加圆角选中态,运行状态带脉冲动画
- 白名单模式灰掉黑名单输入,关闭名单时显示遮罩
- 命令测试结果增加成功/失败颜色反馈
- 回调格式改用等宽字体代码块
This commit is contained in:
2026-05-03 21:56:48 +08:00
parent f82363f45f
commit 58e53c8aec
3 changed files with 470 additions and 376 deletions

View File

@@ -51,11 +51,12 @@ class WebHookPlugin(NcatBotPlugin):
"已配置" if os.environ.get("WEBHOOK_API_KEY") else "自动生成",
)
self.logger.info(
"命令监听: 前缀=%s 长度=%d~%d 范围=%s 名单=%s 回调=%s",
"命令监听: 前缀=%s 长度=%d~%d 范围=%s 名单=%s(%s) 回调=%s",
command.prefix,
command.length_min,
command.length_max,
command.scope,
"" if command.list_enabled else "",
command.list_mode,
command.callback_url or "未配置",
)
@@ -122,20 +123,21 @@ class WebHookPlugin(NcatBotPlugin):
continue
# 黑白名单过滤
if command.list_mode == "allow":
# 白名单模式:在名单内才放行
if command.allowed_groups and is_group:
if event.data.group_id not in command.allowed_groups:
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:
continue
if command.allowed_users and event.data.user_id not in command.allowed_users:
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:
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:
continue
if command.denied_users and event.data.user_id in command.denied_users:
continue
# 构建回调数据
data = {