855 协议版本-调整完毕内容

This commit is contained in:
liuwei
2025-04-30 13:22:33 +08:00
parent 869bce8a18
commit 454d084715
88 changed files with 1565 additions and 7816 deletions

View File

@@ -1,19 +1,20 @@
from typing import Dict, Any, Tuple, Optional, List
from plugin_common.plugin_interface import PluginInterface
class MessagePluginInterface(PluginInterface):
"""消息处理插件接口"""
@property
def command_prefix(self) -> Optional[str]:
"""命令前缀,如 '/'"""
return None
@property
def commands(self) -> List[str]:
"""支持的命令列表"""
return []
def can_process(self, message: Dict[str, Any]) -> bool:
"""
检查插件是否可以处理该消息
@@ -31,7 +32,7 @@ class MessagePluginInterface(PluginInterface):
command = content[len(self.command_prefix):].split()[0]
return command in self.commands
return False
def process_message(self, message: Dict[str, Any]) -> Tuple[bool, Optional[str]]:
"""
处理消息
@@ -44,4 +45,4 @@ class MessagePluginInterface(PluginInterface):
Returns:
(是否已处理, 处理结果)
"""
raise NotImplementedError("子类必须实现此方法")
raise NotImplementedError("子类必须实现此方法")

View File

@@ -1,7 +1,7 @@
import os
import toml
from abc import ABC, abstractmethod
import logging
from loguru import logger
from enum import Enum
from typing import Dict, Any, List, Optional, Tuple
@@ -63,7 +63,7 @@ class PluginInterface(ABC):
self._config = {}
self._plugin_path = ""
# 初始化日志记录器
self.LOG = logging.getLogger(f"Plugin.{self.name}")
self.LOG = logger
def load_config(self) -> bool:
"""
@@ -187,7 +187,7 @@ class PluginInterface(ABC):
"""
return False
def process_message(self, message: Dict[str, Any]) -> Tuple[bool, Optional[str]]:
async def process_message(self, message: Dict[str, Any]) -> Tuple[bool, Optional[str]]:
"""
处理消息

View File

@@ -1,10 +1,11 @@
import importlib
import inspect
import logging
import os
import sys
from typing import Dict, List, Any, Optional, Type, Tuple
from loguru import logger
from plugin_common.plugin_interface import PluginInterface, PluginStatus
from plugin_common.message_plugin_interface import MessagePluginInterface
from plugin_common.scheduled_plugin_interface import ScheduledPluginInterface
@@ -53,7 +54,7 @@ class PluginManager:
self.module_to_display = {} # 模块名到显示名的映射
self.system_context = {} # 系统上下文
self.LOG = logging.getLogger(__name__)
self.LOG = logger
# 确保插件目录存在
if not os.path.exists(self.plugin_dir):
os.makedirs(self.plugin_dir)