新增 MaiBot 对话适配插件并补充 192.168.2.240 部署说明

This commit is contained in:
liuwei
2026-04-29 09:04:09 +08:00
parent ec29bc7551
commit d22e380c4e
5 changed files with 712 additions and 0 deletions

View File

@@ -0,0 +1,180 @@
# 192.168.2.240 部署 MaiBot 清单
这份文档用于把 `MaiBot` 部署到 `192.168.2.240`,供 `plugins/maibot_adapter` 调用。
## 当前状态
我已经在 `abot` 里新增了 `maibot_adapter` 插件,但当前还没有这台服务器的 SSH 凭据。
如果你把 SSH 用户名/密码,或者私钥登录方式给我,我就可以直接按这份清单远程执行。
## 目标
部署完成后,`abot` 将使用以下接口访问 MaiBot
1. `POST /api/webui/auth/verify`
2. `GET /api/webui/ws-token`
3. `WS /ws?token=...`
因此最终需要保证:
1. `http://192.168.2.240:8001/api/webui/health` 可访问
2. 你手里有一个可用的 `MaiBot WebUI token`
3. `plugins/maibot_adapter/config.toml` 中填入同一个 `server_url``access_token`
## 推荐部署方式
当前优先建议“宿主机 Python 直跑”:
1. 部署简单,方便先打通插件联调
2. 日志更容易直接看
3. 后面稳定后再考虑改成 Docker Compose
## 服务器执行步骤
以下命令默认按 Linux 服务器写。
### 1. 安装基础依赖
```bash
sudo apt update
sudo apt install -y git python3 python3-venv python3-pip
```
### 2. 拉取 MaiBot
```bash
cd /opt
sudo git clone https://github.com/Mai-with-u/MaiBot.git
sudo chown -R $USER:$USER /opt/MaiBot
cd /opt/MaiBot
```
### 3. 创建虚拟环境并安装依赖
```bash
python3 -m venv .venv
source .venv/bin/activate
python -m pip install --upgrade pip
pip install -e .
```
如果 `pip install -e .` 遇到单个依赖下载慢,可以切换镜像源再执行。
### 4. 首次启动
```bash
source /opt/MaiBot/.venv/bin/activate
cd /opt/MaiBot
python bot.py
```
说明:
1. `bot.py` 是 MaiBot 主入口
2. 首次启动时通常需要你按它自己的配置流程完成基础设置
3. WebUI 默认监听端口通常是 `8001`
### 5. 验证健康状态
本机执行:
```bash
curl http://127.0.0.1:8001/api/webui/health
```
局域网执行:
```bash
curl http://192.168.2.240:8001/api/webui/health
```
期待返回:
```json
{"status":"healthy","service":"MaiBot WebUI"}
```
### 6. 获取 WebUI token
这一步有两种方式:
1. 按 MaiBot 首次配置流程,在 WebUI 中设置 token
2. 如果已经有现成 token直接记下来给 `maibot_adapter` 使用
最终你需要把 token 填到:
`plugins/maibot_adapter/config.toml`
```toml
server_url = "http://192.168.2.240:8001"
access_token = "你的MaiBotToken"
```
### 7. 建议做成 systemd 服务
创建 `/etc/systemd/system/maibot.service`
```ini
[Unit]
Description=MaiBot Service
After=network.target
[Service]
Type=simple
User=root
WorkingDirectory=/opt/MaiBot
ExecStart=/opt/MaiBot/.venv/bin/python /opt/MaiBot/bot.py
Restart=always
RestartSec=5
Environment=PYTHONUNBUFFERED=1
[Install]
WantedBy=multi-user.target
```
启用并启动:
```bash
sudo systemctl daemon-reload
sudo systemctl enable maibot
sudo systemctl start maibot
sudo systemctl status maibot
```
看日志:
```bash
sudo journalctl -u maibot -f
```
## 与 abot 对接
部署好后,回到 `abot`
1. 编辑 `plugins/maibot_adapter/config.toml`
2. 填入:
- `server_url = "http://192.168.2.240:8001"`
- `access_token = "你的MaiBotToken"`
3. 重启 `abot` 或热加载插件
测试指令:
```text
麦麦 你好
```
或者在群里直接:
```text
@机器人 你好
```
## 备注
如果你后面希望:
1. `ai_auto_response` 也复用 MaiBot
2. 做自动插话而不是只做命令对话
3. 做会话长驻、减少每次重新认证和建连成本
下一步就可以把 `maibot_adapter` 再往“共享长连接 + 自动回复桥”方向升级。