fix: pass ruff

This commit is contained in:
tcmofashi
2025-06-02 21:14:50 +08:00
parent 8212b98aa5
commit 20d68a7896
5 changed files with 6 additions and 14 deletions

View File

@@ -306,16 +306,16 @@ class KeywordRuleConfig(ConfigBase):
"""验证配置"""
if not self.keywords and not self.regex:
raise ValueError("关键词规则必须至少包含keywords或regex中的一个")
if not self.reaction:
raise ValueError("关键词规则必须包含reaction")
# 验证正则表达式
for pattern in self.regex:
try:
re.compile(pattern)
except re.error as e:
raise ValueError(f"无效的正则表达式 '{pattern}': {str(e)}")
raise ValueError(f"无效的正则表达式 '{pattern}': {str(e)}") from e
@dataclass