|
1 | | -# MaiBot-Vtuber |
2 | | - |
3 | | -聊天机器人麦麦的[VTubeStudio](https://github.com/DenchiSoft/VTubeStudio)插件。其聊天核心为[麦麦Bot](https://github.com/MaiM-with-u/MaiBot),一款专注于 群组聊天 的赛博网友 QQ BOT。 |
4 | | - |
5 | | -## 项目结构 |
6 | | - |
7 | | -``` |
8 | | -. |
9 | | -├── src/ # 源代码目录 |
10 | | -│ ├── actuator/ # 执行器模块 |
11 | | -│ ├── neuro/ # 神经网络模块 |
12 | | -│ ├── sensor/ # 传感器模块 |
13 | | -│ └── utils/ # 工具函数模块 |
14 | | -├── main.py # 主程序入口 |
15 | | -└── requirements.txt # 项目依赖 |
| 1 | +# Amaidesu |
| 2 | + |
| 3 | +聊天机器人麦麦的[VTubeStudio](https:// |
| 4 | +github.com/DenchiSoft/VTubeStudio)适配器。 |
| 5 | +其聊天核心为[麦麦Bot](https://github.com/ |
| 6 | +MaiM-with-u/MaiBot),一款专注于 群组聊天 |
| 7 | +的赛博网友 QQ BOT。 |
| 8 | + |
| 9 | +## 架构概述 |
| 10 | + |
| 11 | +MaiBot-Vtuber 采用模块化设计,主要由以下几个核心组件构成: |
| 12 | + |
| 13 | +1. **VupNextCore**: 核心模块,负责与 MaiCore 的通信 |
| 14 | +2. **PluginManager**: 插件管理器,负责插件的加载和管理 |
| 15 | +3. **BasePlugin**: 插件基类,定义插件的基本接口 |
| 16 | +4. **插件系统**: 各种功能插件,如 TTS、STT、LLM 等 |
| 17 | + |
| 18 | +### 系统架构图 |
| 19 | + |
| 20 | +```mermaid |
| 21 | +graph TD |
| 22 | + A[VupNextCore] --> B[PluginManager] |
| 23 | + B --> C[BasePlugin] |
| 24 | + C --> D[ConsoleInput Plugin] |
| 25 | + C --> E[TTS Plugin] |
| 26 | + C --> F[STT Plugin] |
| 27 | + C --> G[LLM Plugin] |
| 28 | + C --> H[VTubeStudio Plugin] |
| 29 | + A --> I[MaiCore] |
| 30 | + A --> J[HTTP Server] |
16 | 31 | ``` |
17 | 32 |
|
18 | | -## 安装步骤 |
19 | | - |
20 | | -1. 克隆项目到本地: |
21 | | -```bash |
22 | | -git clone git@github.com:ChangingSelf/MaiBot-Vtuber.git |
23 | | -cd MaiBot-Vtuber |
| 33 | +### 消息处理时序图 |
| 34 | + |
| 35 | +```mermaid |
| 36 | +sequenceDiagram |
| 37 | + participant User |
| 38 | + participant ConsoleInput |
| 39 | + participant VupNextCore |
| 40 | + participant PluginManager |
| 41 | + participant Plugins |
| 42 | + participant MaiCore |
| 43 | +
|
| 44 | + User->>ConsoleInput: 输入消息 |
| 45 | + ConsoleInput->>VupNextCore: 发送消息 |
| 46 | + VupNextCore->>PluginManager: 分发消息 |
| 47 | + PluginManager->>Plugins: 处理消息 |
| 48 | + Plugins->>VupNextCore: 返回处理结果 |
| 49 | + VupNextCore->>MaiCore: 发送处理后的消息 |
| 50 | + MaiCore-->>VupNextCore: 返回响应 |
| 51 | + VupNextCore-->>Plugins: 分发响应 |
| 52 | + Plugins-->>VupNextCore: 处理响应 |
| 53 | + VupNextCore-->>ConsoleInput: 返回最终结果 |
| 54 | + ConsoleInput-->>User: 显示结果 |
24 | 55 | ``` |
25 | 56 |
|
26 | | -2. 创建并激活虚拟环境(推荐): |
27 | | -```bash |
28 | | -python -m venv venv |
29 | | -# Windows |
30 | | -.\venv\Scripts\activate |
31 | | -# Linux/Mac |
32 | | -source venv/bin/activate |
| 57 | +## 插件开发 |
| 58 | + |
| 59 | +插件开发需要继承 `BasePlugin` 类并实现必要的方法: |
| 60 | + |
| 61 | +```python |
| 62 | +from src.core.plugin_manager import BasePlugin |
| 63 | + |
| 64 | +class MyPlugin(BasePlugin): |
| 65 | + async def setup(self): |
| 66 | + # 注册消息处理器 |
| 67 | + await self.core.register_websocket_handler("text", self.handle_message) |
| 68 | + |
| 69 | + async def handle_message(self, message): |
| 70 | + # 处理消息 |
| 71 | + pass |
| 72 | + |
| 73 | + async def cleanup(self): |
| 74 | + # 清理资源 |
| 75 | + pass |
33 | 76 | ``` |
34 | 77 |
|
35 | | -3. 安装依赖: |
36 | | -```bash |
37 | | -pip install -r requirements.txt |
38 | | -``` |
39 | | - |
40 | | -4. 配置并启动麦麦 |
41 | | - |
42 | | -跟着[麦麦的安装文档](https://docs.mai-mai.org/manual/deployment/mmc_deploy.html),安装并运行麦麦。 |
43 | | - |
44 | | -5. 运行 |
| 78 | +## 安装与运行 |
45 | 79 |
|
46 | | -开启VtubeStudio,在选项中允许安装插件,接着运行主程序: |
47 | | - |
48 | | -```bash |
49 | | -python -m main |
50 | | -``` |
| 80 | +1. 克隆仓库 |
| 81 | +2. 安装依赖:`pip install -r requirements.txt` |
| 82 | +3. 复制 `config-template.toml` 为 `config.toml` 并配置 |
| 83 | +4. 运行:`python main.py` |
51 | 84 |
|
| 85 | +## 调试模式 |
52 | 86 |
|
53 | | -`vts_client.py`中是对连接VTubeStudio的pyvts库的封装,启动VTubeStudio之后,在设置中开启允许安装插件的选项,可使用如下命令运行这个文件进行简单测试: |
| 87 | +使用 `--debug` 参数启用调试日志: |
54 | 88 |
|
55 | 89 | ```bash |
56 | | -python -m src.actuator.vts_client |
| 90 | +python main.py --debug |
57 | 91 | ``` |
58 | 92 |
|
59 | | -会调用当前打开模型的第一个动画。 |
|
0 commit comments