✨ feat(command): 黑白名单开关、自动保存与管理界面重构
- 新增 list_enabled 开关控制是否启用名单过滤 - 表单变更后 800ms 自动保存,去掉手动保存按钮 - Header 显示"未保存"指示器,保存中 toast 提示 - 内容区限制最大宽度 900px,优化宽屏显示 - 侧边栏增加圆角选中态,运行状态带脉冲动画 - 白名单模式灰掉黑名单输入,关闭名单时显示遮罩 - 命令测试结果增加成功/失败颜色反馈 - 回调格式改用等宽字体代码块
This commit is contained in:
28
plugin.py
28
plugin.py
@@ -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 = {
|
||||
|
||||
Reference in New Issue
Block a user