合并BaseEventPlugin到BasePlugin,重写了components_registry,修正了统计输出

This commit is contained in:
UnCLAS-Prommer
2025-07-19 19:16:42 +08:00
parent 8468784e86
commit 8d20134cbb
14 changed files with 233 additions and 299 deletions

View File

@@ -7,15 +7,13 @@ from src.plugin_system import (
ComponentInfo,
ActionActivationType,
ConfigField,
BaseEventPlugin,
BaseEventHandler,
EventType,
MaiMessages,
)
from src.plugin_system.base.component_types import MaiMessages
# ===== Action组件 =====
class HelloAction(BaseAction):
"""问候Action - 简单的问候动作"""
@@ -86,7 +84,7 @@ class TimeCommand(BaseCommand):
import datetime
# 获取当前时间
time_format = self.get_config("time.format", "%Y-%m-%d %H:%M:%S")
time_format: str = self.get_config("time.format", "%Y-%m-%d %H:%M:%S") # type: ignore
now = datetime.datetime.now()
time_str = now.strftime(time_format)
@@ -140,6 +138,7 @@ class HelloWorldPlugin(BasePlugin):
"enable_emoji": ConfigField(type=bool, default=True, description="是否启用表情符号"),
},
"time": {"format": ConfigField(type=str, default="%Y-%m-%d %H:%M:%S", description="时间显示格式")},
"print_message": {"enabled": ConfigField(type=bool, default=True, description="是否启用打印")},
}
def get_plugin_components(self) -> List[Tuple[ComponentInfo, Type]]:
@@ -147,26 +146,27 @@ class HelloWorldPlugin(BasePlugin):
(HelloAction.get_action_info(), HelloAction),
(ByeAction.get_action_info(), ByeAction), # 添加告别Action
(TimeCommand.get_command_info(), TimeCommand),
(PrintMessage.get_handler_info(), PrintMessage),
]
@register_plugin
class HelloWorldEventPlugin(BaseEventPlugin):
"""Hello World事件插件 - 处理问候和告别事件"""
# @register_plugin
# class HelloWorldEventPlugin(BaseEPlugin):
# """Hello World事件插件 - 处理问候和告别事件"""
plugin_name = "hello_world_event_plugin"
enable_plugin = False
dependencies = []
python_dependencies = []
config_file_name = "event_config.toml"
config_schema = {
"plugin": {
"name": ConfigField(type=str, default="hello_world_event_plugin", description="插件名称"),
"version": ConfigField(type=str, default="1.0.0", description="插件版本"),
"enabled": ConfigField(type=bool, default=True, description="是否启用插件"),
},
}
# plugin_name = "hello_world_event_plugin"
# enable_plugin = False
# dependencies = []
# python_dependencies = []
# config_file_name = "event_config.toml"
def get_plugin_components(self) -> List[Tuple[ComponentInfo, Type]]:
return [(PrintMessage.get_handler_info(), PrintMessage)]
# config_schema = {
# "plugin": {
# "name": ConfigField(type=str, default="hello_world_event_plugin", description="插件名称"),
# "version": ConfigField(type=str, default="1.0.0", description="插件版本"),
# "enabled": ConfigField(type=bool, default=True, description="是否启用插件"),
# },
# }
# def get_plugin_components(self) -> List[Tuple[ComponentInfo, Type]]:
# return [(PrintMessage.get_handler_info(), PrintMessage)]