diff --git a/plugins/sentinel/__init__.py b/plugins/sentinel/__init__.py index 1dafd1b..06c860d 100644 --- a/plugins/sentinel/__init__.py +++ b/plugins/sentinel/__init__.py @@ -4,6 +4,7 @@ import logging import asyncio import os import time +import shutil import yaml import urllib.request import json as _json diff --git a/services/plugin_service.py b/services/plugin_service.py index 5b830e4..39c6d3a 100644 --- a/services/plugin_service.py +++ b/services/plugin_service.py @@ -312,12 +312,18 @@ class PluginService: logger.error(f"插件目录不存在: {plugin_path}") return False - # 检查插件配置文件 + # 检查插件配置文件 (自动从 .example 模板创建) config_file = plugin_path / "config.yaml" if not config_file.exists(): - logger.error(f"插件配置文件不存在: {config_file}") - return False - + template = plugin_path / "config.yaml.example" + if template.exists(): + import shutil as _shutil + _shutil.copy(template, config_file) + logger.info(f"📋 从模板创建插件配置: {config_file}") + else: + logger.error(f"插件配置文件不存在: {config_file}") + return False + # 加载插件配置 with open(config_file, 'r', encoding='utf-8') as f: plugin_config = yaml.safe_load(f)