🤖 自动格式化代码 [skip ci]
This commit is contained in:
@@ -328,7 +328,10 @@ class BasePlugin(ABC):
|
||||
Returns:
|
||||
Dict[str, Any]: 迁移后的配置
|
||||
"""
|
||||
def migrate_section(old_section: Dict[str, Any], new_section: Dict[str, Any], section_name: str) -> Dict[str, Any]:
|
||||
|
||||
def migrate_section(
|
||||
old_section: Dict[str, Any], new_section: Dict[str, Any], section_name: str
|
||||
) -> Dict[str, Any]:
|
||||
"""迁移单个配置节"""
|
||||
result = new_section.copy()
|
||||
|
||||
@@ -337,7 +340,9 @@ class BasePlugin(ABC):
|
||||
# 特殊处理:config_version字段总是使用新版本
|
||||
if section_name == "plugin" and key == "config_version":
|
||||
# 保持新的版本号,不迁移旧值
|
||||
logger.debug(f"{self.log_prefix} 更新配置版本: {section_name}.{key} = {result[key]} (旧值: {value})")
|
||||
logger.debug(
|
||||
f"{self.log_prefix} 更新配置版本: {section_name}.{key} = {result[key]} (旧值: {value})"
|
||||
)
|
||||
continue
|
||||
|
||||
# 键存在于新配置中,复制值
|
||||
@@ -357,8 +362,14 @@ class BasePlugin(ABC):
|
||||
|
||||
# 迁移每个配置节
|
||||
for section_name, new_section_data in new_config.items():
|
||||
if section_name in old_config and isinstance(old_config[section_name], dict) and isinstance(new_section_data, dict):
|
||||
migrated_config[section_name] = migrate_section(old_config[section_name], new_section_data, section_name)
|
||||
if (
|
||||
section_name in old_config
|
||||
and isinstance(old_config[section_name], dict)
|
||||
and isinstance(new_section_data, dict)
|
||||
):
|
||||
migrated_config[section_name] = migrate_section(
|
||||
old_config[section_name], new_section_data, section_name
|
||||
)
|
||||
else:
|
||||
# 新增的节或类型不匹配,使用默认值
|
||||
migrated_config[section_name] = new_section_data
|
||||
@@ -514,7 +525,9 @@ class BasePlugin(ABC):
|
||||
expected_version = self._get_expected_config_version()
|
||||
|
||||
if current_version != expected_version:
|
||||
logger.info(f"{self.log_prefix} 检测到配置版本需要更新: 当前=v{current_version}, 期望=v{expected_version}")
|
||||
logger.info(
|
||||
f"{self.log_prefix} 检测到配置版本需要更新: 当前=v{current_version}, 期望=v{expected_version}"
|
||||
)
|
||||
|
||||
# 生成新的默认配置结构
|
||||
new_config_structure = self._generate_config_from_schema()
|
||||
|
||||
@@ -117,7 +117,7 @@ class MuteAction(BaseAction):
|
||||
return True, None
|
||||
|
||||
logger.warning(f"{self.log_prefix} 群组 {current_group_key} 没有禁言动作权限")
|
||||
return False, f"当前群组没有使用禁言动作的权限"
|
||||
return False, "当前群组没有使用禁言动作的权限"
|
||||
|
||||
async def execute(self) -> Tuple[bool, Optional[str]]:
|
||||
"""执行智能禁言判定"""
|
||||
@@ -304,7 +304,7 @@ class MuteCommand(BaseCommand):
|
||||
return True, None
|
||||
|
||||
logger.warning(f"{self.log_prefix} 用户 {current_user_key} 没有禁言命令权限")
|
||||
return False, f"你没有使用禁言命令的权限"
|
||||
return False, "你没有使用禁言命令的权限"
|
||||
|
||||
async def execute(self) -> Tuple[bool, Optional[str]]:
|
||||
"""执行禁言命令"""
|
||||
|
||||
Reference in New Issue
Block a user