Files
NeoBot/docs/getting-started.md

87 lines
1.7 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 模式启动
python -X jit main.py
```
如果你看到日志刷出来,最后显示 “连接成功!”,恭喜,你成功了!
现在,试着给你的机器人发个 `/help`看看会返回什么东西