fix:更新插件属性
This commit is contained in:
@@ -29,20 +29,17 @@ class BasePlugin(ABC):
|
||||
"""
|
||||
|
||||
# 插件基本信息(子类必须定义)
|
||||
plugin_name: str = "" # 插件名称
|
||||
plugin_description: str = "" # 插件描述
|
||||
plugin_version: str = "1.0.0" # 插件版本
|
||||
plugin_author: str = "" # 插件作者
|
||||
plugin_name: str = "" # 插件内部标识符(如 "doubao_pic_plugin")
|
||||
enable_plugin: bool = False # 是否启用插件
|
||||
dependencies: List[str] = [] # 依赖的其他插件
|
||||
python_dependencies: List[PythonDependency] = [] # Python包依赖
|
||||
config_file_name: Optional[str] = None # 配置文件名
|
||||
|
||||
# 新增:manifest文件相关
|
||||
# manifest文件相关
|
||||
manifest_file_name: str = "_manifest.json" # manifest文件名
|
||||
manifest_data: Dict[str, Any] = {} # manifest数据
|
||||
|
||||
# 新增:配置定义
|
||||
# 配置定义
|
||||
config_schema: Dict[str, Union[Dict[str, ConfigField], str]] = {}
|
||||
config_section_descriptions: Dict[str, str] = {}
|
||||
|
||||
@@ -63,9 +60,17 @@ class BasePlugin(ABC):
|
||||
self._validate_plugin_info()
|
||||
|
||||
# 加载插件配置
|
||||
self._load_plugin_config() # 创建插件信息对象
|
||||
self._load_plugin_config()
|
||||
|
||||
# 从manifest获取显示信息
|
||||
self.display_name = self.get_manifest_info("name", self.plugin_name)
|
||||
self.plugin_version = self.get_manifest_info("version", "1.0.0")
|
||||
self.plugin_description = self.get_manifest_info("description", "")
|
||||
self.plugin_author = self._get_author_name()
|
||||
|
||||
# 创建插件信息对象
|
||||
self.plugin_info = PluginInfo(
|
||||
name=self.plugin_name,
|
||||
name=self.display_name, # 使用显示名称
|
||||
description=self.plugin_description,
|
||||
version=self.plugin_version,
|
||||
author=self.plugin_author,
|
||||
@@ -74,7 +79,7 @@ class BasePlugin(ABC):
|
||||
config_file=self.config_file_name or "",
|
||||
dependencies=self.dependencies.copy(),
|
||||
python_dependencies=self.python_dependencies.copy(),
|
||||
# 新增:manifest相关信息
|
||||
# manifest相关信息
|
||||
manifest_data=self.manifest_data.copy(),
|
||||
license=self.get_manifest_info("license", ""),
|
||||
homepage_url=self.get_manifest_info("homepage_url", ""),
|
||||
@@ -91,8 +96,12 @@ class BasePlugin(ABC):
|
||||
"""验证插件基本信息"""
|
||||
if not self.plugin_name:
|
||||
raise ValueError(f"插件类 {self.__class__.__name__} 必须定义 plugin_name")
|
||||
if not self.plugin_description:
|
||||
raise ValueError(f"插件 {self.plugin_name} 必须定义 plugin_description")
|
||||
|
||||
# 验证manifest中的必需信息
|
||||
if not self.get_manifest_info("name"):
|
||||
raise ValueError(f"插件 {self.plugin_name} 的manifest中缺少name字段")
|
||||
if not self.get_manifest_info("description"):
|
||||
raise ValueError(f"插件 {self.plugin_name} 的manifest中缺少description字段")
|
||||
|
||||
def _load_manifest(self):
|
||||
"""加载manifest文件(强制要求)"""
|
||||
@@ -128,26 +137,21 @@ class BasePlugin(ABC):
|
||||
raise IOError(error_msg) # noqa
|
||||
|
||||
def _apply_manifest_overrides(self):
|
||||
"""从manifest文件覆盖插件信息"""
|
||||
"""从manifest文件覆盖插件信息(现在只处理内部标识符的fallback)"""
|
||||
if not self.manifest_data:
|
||||
return
|
||||
|
||||
# 如果插件类中的信息为空,则从manifest中获取
|
||||
# 只有当插件类中没有定义plugin_name时,才从manifest中获取作为fallback
|
||||
if not self.plugin_name:
|
||||
self.plugin_name = self.manifest_data.get("name", "")
|
||||
|
||||
if not self.plugin_description:
|
||||
self.plugin_description = self.manifest_data.get("description", "")
|
||||
|
||||
if self.plugin_version == "1.0.0": # 默认版本
|
||||
self.plugin_version = self.manifest_data.get("version", "1.0.0")
|
||||
|
||||
if not self.plugin_author:
|
||||
author_info = self.manifest_data.get("author", {})
|
||||
if isinstance(author_info, dict):
|
||||
self.plugin_author = author_info.get("name", "")
|
||||
else:
|
||||
self.plugin_author = str(author_info)
|
||||
self.plugin_name = self.manifest_data.get("name", "").replace(" ", "_").lower()
|
||||
|
||||
def _get_author_name(self) -> str:
|
||||
"""从manifest获取作者名称"""
|
||||
author_info = self.get_manifest_info("author", {})
|
||||
if isinstance(author_info, dict):
|
||||
return author_info.get("name", "")
|
||||
else:
|
||||
return str(author_info) if author_info else ""
|
||||
|
||||
def _validate_manifest(self):
|
||||
"""验证manifest文件格式(使用强化的验证器)"""
|
||||
@@ -178,12 +182,15 @@ class BasePlugin(ABC):
|
||||
logger.debug(f"{self.log_prefix} 插件名称未定义,无法生成默认manifest")
|
||||
return
|
||||
|
||||
# 从plugin_name生成友好的显示名称
|
||||
display_name = self.plugin_name.replace("_", " ").title()
|
||||
|
||||
default_manifest = {
|
||||
"manifest_version": 1,
|
||||
"name": self.plugin_name,
|
||||
"version": self.plugin_version,
|
||||
"description": self.plugin_description or "插件描述",
|
||||
"author": {"name": self.plugin_author or "Unknown", "url": ""},
|
||||
"name": display_name,
|
||||
"version": "1.0.0",
|
||||
"description": "插件描述",
|
||||
"author": {"name": "Unknown", "url": ""},
|
||||
"license": "MIT",
|
||||
"host_application": {"min_version": "1.0.0", "max_version": "4.0.0"},
|
||||
"keywords": [],
|
||||
|
||||
@@ -166,13 +166,12 @@ class PluginManager:
|
||||
|
||||
# 获取组件统计信息
|
||||
stats = component_registry.get_registry_stats()
|
||||
action_count = stats.get("action_components", 0)
|
||||
command_count = stats.get("command_components", 0)
|
||||
total_components = stats.get("total_components", 0)
|
||||
|
||||
# 📋 显示插件加载总览
|
||||
if total_registered > 0:
|
||||
action_count = stats.get("action_components", 0)
|
||||
command_count = stats.get("command_components", 0)
|
||||
total_components = stats.get("total_components", 0)
|
||||
|
||||
logger.info("🎉 插件系统加载完成!")
|
||||
logger.info(
|
||||
f"📊 总览: {total_registered}个插件, {total_components}个组件 (Action: {action_count}, Command: {command_count})"
|
||||
|
||||
@@ -344,11 +344,8 @@ class CoreActionsPlugin(BasePlugin):
|
||||
注意:插件基本信息优先从_manifest.json文件中读取
|
||||
"""
|
||||
|
||||
# 插件基本信息(作为fallback,优先从manifest读取)
|
||||
plugin_name = "core_actions"
|
||||
plugin_description = "系统核心动作插件,提供基础聊天交互功能"
|
||||
plugin_version = "1.0.0"
|
||||
plugin_author = "MaiBot团队"
|
||||
# 插件基本信息
|
||||
plugin_name = "core_actions" # 内部标识符
|
||||
enable_plugin = True
|
||||
config_file_name = "config.toml"
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"manifest_version": 1,
|
||||
"name": "豆包图片生成插件 (Doubao Image Generator)",
|
||||
"version": "1.2.0",
|
||||
"version": "2.0.0",
|
||||
"description": "基于火山引擎豆包模型的AI图片生成插件,支持智能LLM判定、高质量图片生成、结果缓存和多尺寸支持。",
|
||||
"author": {
|
||||
"name": "MaiBot团队",
|
||||
|
||||
@@ -399,10 +399,7 @@ class DoubaoImagePlugin(BasePlugin):
|
||||
"""
|
||||
|
||||
# 插件基本信息
|
||||
plugin_name = "doubao_pic_plugin"
|
||||
plugin_description = "基于火山引擎豆包模型的AI图片生成插件"
|
||||
plugin_version = "2.0.0"
|
||||
plugin_author = "MaiBot开发团队"
|
||||
plugin_name = "doubao_pic_plugin" # 内部标识符
|
||||
enable_plugin = True
|
||||
config_file_name = "config.toml"
|
||||
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
{
|
||||
"manifest_version": 1,
|
||||
"name": "mute_plugin",
|
||||
"name": "群聊禁言管理插件 (Mute Plugin)",
|
||||
"version": "2.0.0",
|
||||
"description": "群聊禁言管理插件,提供智能禁言功能",
|
||||
"author": {
|
||||
"name": "MaiBot开发团队",
|
||||
"url": ""
|
||||
"url": "https://github.com/MaiM-with-u"
|
||||
},
|
||||
"license": "GPL-v3.0-or-later",
|
||||
"host_application": {
|
||||
"min_version": "0.8.0",
|
||||
"max_version": "0.8.0"
|
||||
},
|
||||
"keywords": [],
|
||||
"categories": [],
|
||||
"keywords": ["mute", "ban", "moderation", "admin", "management", "group"],
|
||||
"categories": ["Moderation", "Group Management", "Admin Tools"],
|
||||
"default_locale": "zh-CN",
|
||||
"locales_path": "_locales"
|
||||
}
|
||||
@@ -357,10 +357,7 @@ class MutePlugin(BasePlugin):
|
||||
"""
|
||||
|
||||
# 插件基本信息
|
||||
plugin_name = "mute_plugin"
|
||||
plugin_description = "群聊禁言管理插件,提供智能禁言功能"
|
||||
plugin_version = "2.0.0"
|
||||
plugin_author = "MaiBot开发团队"
|
||||
plugin_name = "mute_plugin" # 内部标识符
|
||||
enable_plugin = True
|
||||
config_file_name = "config.toml"
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"manifest_version": 1,
|
||||
"name": "文本转语音插件 (Text-to-Speech)",
|
||||
"version": "1.1.0",
|
||||
"version": "0.1.0",
|
||||
"description": "将文本转换为语音进行播放的插件,支持多种语音模式和智能语音输出场景判断。",
|
||||
"author": {
|
||||
"name": "MaiBot团队",
|
||||
|
||||
@@ -101,10 +101,7 @@ class TTSPlugin(BasePlugin):
|
||||
"""
|
||||
|
||||
# 插件基本信息
|
||||
plugin_name = "tts_plugin"
|
||||
plugin_description = "文字转语音插件"
|
||||
plugin_version = "0.1.0"
|
||||
plugin_author = "MaiBot开发团队"
|
||||
plugin_name = "tts_plugin" # 内部标识符
|
||||
enable_plugin = True
|
||||
config_file_name = "config.toml"
|
||||
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
{
|
||||
"manifest_version": 1,
|
||||
"name": "vtb_plugin",
|
||||
"name": "虚拟主播情感表达插件 (VTB Plugin)",
|
||||
"version": "0.1.0",
|
||||
"description": "虚拟主播情感表达插件",
|
||||
"author": {
|
||||
"name": "MaiBot开发团队",
|
||||
"url": ""
|
||||
"url": "https://github.com/MaiM-with-u"
|
||||
},
|
||||
"license": "GPL-v3.0-or-later",
|
||||
"host_application": {
|
||||
"min_version": "0.8.0",
|
||||
"max_version": "0.8.0"
|
||||
},
|
||||
"keywords": [],
|
||||
"categories": [],
|
||||
"keywords": ["vtb", "vtuber", "emotion", "expression", "virtual", "streamer"],
|
||||
"categories": ["Entertainment", "Virtual Assistant", "Emotion"],
|
||||
"default_locale": "zh-CN",
|
||||
"locales_path": "_locales"
|
||||
}
|
||||
@@ -107,10 +107,7 @@ class VTBPlugin(BasePlugin):
|
||||
"""
|
||||
|
||||
# 插件基本信息
|
||||
plugin_name = "vtb_plugin"
|
||||
plugin_description = "虚拟主播情感表达插件"
|
||||
plugin_version = "0.1.0"
|
||||
plugin_author = "MaiBot开发团队"
|
||||
plugin_name = "vtb_plugin" # 内部标识符
|
||||
enable_plugin = True
|
||||
config_file_name = "config.toml"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user