Files
NeoBot/docs/getting-started.md
K2cr2O1 ff4a4d92a5 feat: 添加多线程架构支持并优化性能
实现线程管理器以支持高并发场景,添加GIL-free模式提升Python 3.14下的多线程性能
新增B站API集成和本地文件服务器功能,改进镜像插件支持GIF处理
更新文档说明多线程架构和GIL-free模式的使用方法
2026-03-01 16:01:51 +08:00

94 lines
2.1 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 快速上手
## 1. 你需要准备
* **Python 3.14**必须是这个版本JIT编译需要
* **Git**:拉取代码
* **Redis**:缓存和权限管理,需要单独安装
* **Docker** (可选)用于代码沙箱执行code_py插件
* **OneBot v11 客户端**:机器人本体,推荐用 [NapCatQQ](https://github.com/NapNeko/NapCatQQ)
## 2. 搭环境
### a. 克隆代码
```bash
git clone https://github.com/Fairy-Oracle-Sanctuary/NeoBot.git
cd NeoBot
```
### b. 创建虚拟环境
```bash
# Windows
python -m venv venv
.\venv\Scripts\activate
# Linux / macOS
python3.14 -m venv venv
source venv/bin/activate
```
看到命令行前面多了个 `(venv)`,就说明你进来了。
### c. 安装依赖
```bash
pip install -r requirements.txt
```
### d. 安装 Playwright 依赖
```bash
playwright install chromium
```
### e. 编译核心 (可选,但强烈建议)
想让你的代码更快?把它的核心代码编译成 C。
```bash
python setup_mypyc.py build_ext --inplace
```
*Windows 上可能需要装个 Visual Studio Build ToolsLinux 上需要 GCC。编译失败也别慌跳过就行JIT 也能保证不错的速度*
## 3. 第一次
### a. 修改配置
去根目录找 `config.toml`
```toml
[napcat_ws]
# 你的 OneBot 地址
# 我们用的是正向连接,也就是 Bot 主动去连 OneBot
uri = "ws://127.0.0.1:3001"
token = ""
[redis]
host = "127.0.0.1"
port = 6379
db = 0
```
`uri` 改成你自己的 OneBot 地址。
### b. 启动!
一切就绪
```bash
# 推荐开启 JIT + GIL-free 模式启动Python 3.14
python -X jit -X gil=0 main.py
```
**模式说明**
- `-X jit`:启用 JIT 编译提升运行时性能2-5 倍)
- `-X gil=0`:启用无全局锁模式,多线程真正并行执行(+300% CPU 密集型任务性能)
如果你看到日志刷出来,最后显示 "连接成功!",恭喜,你成功了!
现在,试着给你的机器人发个 `/help`看看会返回什么东西
**多前端支持**
如果需要同时连接多个 OneBot 实现(如多个 QQ 账号GIL-free 模式可以确保每个连接真正并行处理事件,不会相互阻塞。