MaiBot-Vtuber 采用模块化设计,主要由以下几个核心组件构成:
- AmaidesuCore: 核心模块,负责与 MaiCore 的通信
- PluginManager: 插件管理器,负责插件的加载和管理
- BasePlugin: 插件基类,定义插件的基本接口
- 插件系统: 各种功能插件,如 TTS、STT、LLM 等
sequenceDiagram
participant User
participant ConsoleInput
participant AmaidesuCore
participant PluginManager
participant Plugins
participant MaiCore
User->>ConsoleInput: 输入消息
ConsoleInput->>AmaidesuCore: 发送消息
AmaidesuCore->>PluginManager: 分发消息
PluginManager->>Plugins: 处理消息
Plugins->>AmaidesuCore: 返回处理结果
AmaidesuCore->>MaiCore: 发送处理后的消息
MaiCore-->>AmaidesuCore: 返回响应
AmaidesuCore-->>Plugins: 分发响应
Plugins-->>AmaidesuCore: 处理响应
AmaidesuCore-->>ConsoleInput: 返回最终结果
ConsoleInput-->>User: 显示结果
插件开发需要继承 BasePlugin 类并实现必要的方法:
from src.core.plugin_manager import BasePlugin
class MyPlugin(BasePlugin):
async def setup(self):
# 注册消息处理器
await self.core.register_websocket_handler("text", self.handle_message)
async def handle_message(self, message):
# 处理消息
pass
async def cleanup(self):
# 清理资源
pass- 克隆仓库
- 安装依赖:
pip install -r requirements.txt - 复制
config-template.toml为config.toml并配置 - 运行:
python main.py
使用 --debug 参数启用调试日志:
python main.py --debug当你不方便部署麦麦时,可以用它启用一个ws服务端和一个控制台输入任务,便于模拟麦麦的回应来测试插件功能
使用方法:
python mock_maicore.py