diff --git a/README.md b/README.md index 89f71d9..2f41e31 100644 --- a/README.md +++ b/README.md @@ -107,6 +107,7 @@ _✨ 支持多API预设、MCP协议、联网搜索、视觉模型的AI群聊插 | LLMCHAT__DEFAULT_PRESET | 否 | off | 默认使用的预设名称,配置为off则为关闭 | | LLMCHAT__RANDOM_TRIGGER_PROB | 否 | 0.05 | 默认随机触发概率 [0, 1] | | LLMCHAT__DEFAULT_PROMPT | 否 | 你的回答应该尽量简洁、幽默、可以使用一些语气词、颜文字。你应该拒绝回答任何政治相关的问题。 | 默认提示词 | +| LLMCHAT__BLACKLIST_USER_IDS | 否 | [] | 黑名单用户ID列表,机器人将不会处理黑名单用户的消息 | | LLMCHAT__MCP_SERVERS | 否 | {} | MCP服务器配置,具体见下表 | 其中LLMCHAT__API_PRESETS为一个列表,每项配置有以下的配置项 diff --git a/nonebot_plugin_llmchat/__init__.py b/nonebot_plugin_llmchat/__init__.py index 0b14e1c..b2021c2 100755 --- a/nonebot_plugin_llmchat/__init__.py +++ b/nonebot_plugin_llmchat/__init__.py @@ -166,6 +166,10 @@ async def is_triggered(event: GroupMessageEvent) -> bool: if state.preset_name == "off": return False + # 黑名单用户 + if event.user_id in plugin_config.blacklist_user_ids: + return False + state.past_events.append(event) # 原有@触发条件 diff --git a/nonebot_plugin_llmchat/config.py b/nonebot_plugin_llmchat/config.py index 26f9b67..fa873d5 100755 --- a/nonebot_plugin_llmchat/config.py +++ b/nonebot_plugin_llmchat/config.py @@ -43,6 +43,7 @@ class ScopedConfig(BaseModel): description="默认提示词", ) mcp_servers: dict[str, MCPServerConfig] = Field({}, description="MCP服务器配置") + blacklist_user_ids: set[int] = Field(set(), description="黑名单用户ID列表") class Config(BaseModel):