Metadata-Version: 2.3
Name: nonebot-plugin-dancefengbot
Version: 2026.12.2.3
Summary: 为舞立方玩家提供高效便捷的数据查询服务
Author: DanceFengBot
Author-email: DanceFengBot <dancefengbot@users.noreply.github.com>
Requires-Dist: nonebot2[aiohttp,fastapi,httpx]>=2.5.0
Requires-Dist: nonebot-adapter-onebot>=2.4.6
Requires-Dist: nonebot-plugin-apscheduler>=0.5.0
Requires-Dist: pillow>=10.0.0
Requires-Dist: pyyaml>=6.0
Requires-Dist: pycryptodome>=3.20.0
Requires-Python: >=3.11, <4.0
Project-URL: Homepage, https://github.com/DanceFengBot/nonebot-plugin-dancefengbot
Project-URL: Issues, https://github.com/DanceFengBot/nonebot-plugin-dancefengbot/issues
Project-URL: Repository, https://github.com/DanceFengBot/nonebot-plugin-dancefengbot
Description-Content-Type: text/markdown


## ✨ nonebot-plugin-dancefengbot ✨
[![LICENSE](https://img.shields.io/github/license/DanceFengBot/nonebot-plugin-dancefengbot.svg)](./LICENSE)
[![pypi](https://img.shields.io/pypi/v/nonebot-plugin-dancefengbot.svg)](https://pypi.python.org/pypi/nonebot-plugin-dancefengbot)
[![python](https://img.shields.io/badge/python-3.10|3.11|3.12|3.13-blue.svg)](https://www.python.org)
[![uv](https://img.shields.io/badge/package%20manager-uv-black?style=flat-square&logo=uv)](https://github.com/astral-sh/uv)
[![ruff](https://img.shields.io/badge/code%20style-ruff-black?style=flat-square&logo=ruff)](https://github.com/astral-sh/ruff)
[![pre-commit](https://results.pre-commit.ci/badge/github/DanceFengBot/nonebot-plugin-dancefengbot/master.svg)](https://results.pre-commit.ci/latest/github/DanceFengBot/nonebot-plugin-dancefengbot/master)



## 📖 介绍

为舞立方玩家提供高效便捷的数据查询服务

## 💿 安装

<details open>
<summary>使用 nb-cli 安装</summary>
在 nonebot2 项目的根目录下打开命令行, 输入以下指令即可安装

    nb plugin install nonebot-plugin-dancefengbot --upgrade
使用 **pypi** 源安装

    nb plugin install nonebot-plugin-dancefengbot --upgrade -i "https://pypi.org/simple"
使用**清华源**安装

    nb plugin install nonebot-plugin-dancefengbot --upgrade -i "https://pypi.tuna.tsinghua.edu.cn/simple"


</details>

<details>
<summary>使用包管理器安装</summary>
在 nonebot2 项目的插件目录下, 打开命令行, 根据你使用的包管理器, 输入相应的安装命令

<details open>
<summary>uv</summary>

    uv add nonebot-plugin-dancefengbot
安装仓库 master 分支

    uv add git+https://github.com/DanceFengBot/nonebot-plugin-dancefengbot@master
</details>

<details>
<summary>pdm</summary>

    pdm add nonebot-plugin-dancefengbot
安装仓库 master 分支

    pdm add git+https://github.com/DanceFengBot/nonebot-plugin-dancefengbot@master
</details>
<details>
<summary>poetry</summary>

    poetry add nonebot-plugin-dancefengbot
安装仓库 master 分支

    poetry add git+https://github.com/DanceFengBot/nonebot-plugin-dancefengbot@master
</details>

打开 nonebot2 项目根目录下的 `pyproject.toml` 文件, 在 `[tool.nonebot]` 部分追加写入

    plugins = ["nonebot_plugin_dancefengbot"]

</details>

<details>
<summary>使用 nbr 安装(使用 uv 管理依赖可用)</summary>

[nbr](https://github.com/fllesser/nbr) 是一个基于 uv 的 nb-cli，可以方便地管理 nonebot2

    nbr plugin install nonebot-plugin-dancefengbot
使用 **pypi** 源安装

    nbr plugin install nonebot-plugin-dancefengbot -i "https://pypi.org/simple"
使用**清华源**安装

    nbr plugin install nonebot-plugin-dancefengbot -i "https://pypi.tuna.tsinghua.edu.cn/simple"

</details>


## ⚙️ 配置

插件的主要配置不在 `.env` 中，而是在机器人**运行目录**下的 `DcConfig/` 目录：

- 默认路径：启动机器人时当前工作目录下的 `DcConfig/`；
- 首次运行会自动创建目录、默认配置文件和 `DcConfig/README.md`；
- **已经存在的文件不会被覆盖**，可直接修改；
- 可以通过环境变量 `DCF_CONFIG_PATH` 指定其它目录。

### 配置文件一览

| 文件 / 目录 | 必填 | 默认值 | 说明 |
| --- | :---: | --- | --- |
| `ApiKeys.yml` | 否 | 空密钥 | 腾讯 OCR、高德地图 Key |
| `Curfew.json` | 否 | 23:00–07:00 宵禁，延迟 3–4 秒 | 宵禁时段与回复延迟 |
| `OfficialMusicIds.json` | 否（推荐） | `[]` | 官谱 ID 列表，可用 `#update all` 更新 |
| `UserTokens.json` | 否（自动生成） | `{}` | 用户登录 Token，登录后自动写入 |
| `UserCommands.json` | 否 | `{}` | 预留配置 |
| `WhiteList.json` / `BlackList.json` | 否 | 未启用、空名单 | 预留名单配置 |
| `TokenIds.json` | 已废弃 | 不再生成 | 旧版扫码登录 client_id，可删除 |
| `Images/`、`Fonts/` | 图片功能必填 | 自动下载 | 图片素材与字体 |
| `cache/` | 否（自动生成） | 空目录 | 图片缓存 |

### `ApiKeys.yml`

用于二维码识别和「查找舞立方」机台查询，**选填**；不填写不影响机器人启动，
只影响对应功能。

```yaml
# 腾讯 OCR SDK 密钥（二维码识别等功能需要）
tencentScannerKeys:
  secretId: ""
  secretKey: ""

# 高德地图 Web 服务 Key（「查找机台」需要）
gaodeMapKeys:
  apiKey: ""
```

| 字段 | 必填 | 默认值 | 说明 |
| --- | :---: | --- | --- |
| `tencentScannerKeys.secretId` | 否 | 空 | 腾讯云 SecretId |
| `tencentScannerKeys.secretKey` | 否 | 空 | 腾讯云 SecretKey |
| `gaodeMapKeys.apiKey` | 否 | 空 | 高德地图 Web 服务 Key |

### `Curfew.json`

控制宵禁时段和每条指令开始前的随机延迟，**选填**；文件缺失或损坏时使用默认值。
修改后会自动重新加载，无需重启。

```json
{
  "enabled": true,
  "ranges": [
    { "start": "23:00", "end": "07:00" }
  ],
  "delay": { "min": 3.0, "max": 4.0 },
  "admin_bypass": true
}
```

| 字段 | 必填 | 默认值 | 说明 |
| --- | :---: | --- | --- |
| `enabled` | 否 | `true` | 是否启用宵禁与延迟 |
| `ranges` | 否 | `23:00–07:00` | 不回复消息的时段，支持跨天和多段；空数组表示不宵禁 |
| `delay.min` | 否 | `3.0` | 随机延迟下限（秒） |
| `delay.max` | 否 | `4.0` | 随机延迟上限（秒），最大生效 120 秒 |
| `admin_bypass` | 否 | `true` | 管理员在宵禁时段是否仍可使用命令 |

### `OfficialMusicIds.json`

舞立方官谱 `MusicID` 的 JSON 数组，默认 `[]`。为空时所有歌曲都会被当作非官谱，
「自制」标记可能不准确。管理员可发送以下命令重新拉取：

```text
#update official
#update all
```

### 图片与字体素材

首次运行检测到关键素材缺失时，会自动下载
[`DanceFengBot/dfb-miscellaneous`](https://github.com/DanceFengBot/dfb-miscellaneous)
的 ZIP：

1. 先尝试 GitHub 直连；
2. 失败后依次尝试 `ghfast.top`、`gh-proxy.com`、`ghproxy.net` 镜像；
3. 只解压 `Fonts/`、`Images/`，不覆盖已有文件；
4. 素材约 80 MB，日志每 10 MB 输出一次下载进度。

全部下载源失败时，日志会输出每个源的具体错误，并生成
`DcConfig/ASSETS_DOWNLOAD_FAILED.txt`，其中包含手动下载步骤；机器人仍可启动，
文字功能可用，图片功能暂不可用。

如果不希望自动下载，可设置：

```bash
export DCF_SKIP_ASSETS_DOWNLOAD=1
```

### 其它文件

- `UserTokens.json`：登录后自动写入，包含 `accessToken` / `refreshToken`，
  属于敏感数据，请勿公开分享并定期备份；删除它等同于让用户退出登录。
- `WhiteList.json` / `BlackList.json` / `UserCommands.json`：预留配置，默认不启用。
- `TokenIds.json`：旧版二维码登录使用，现已废弃，不再读取或生成。

### 环境变量

| 变量 | 默认值 | 说明 |
| --- | --- | --- |
| `DCF_CONFIG_PATH` | `./DcConfig` | 指定 DcConfig 目录 |
| `DCF_SKIP_ASSETS_DOWNLOAD` | 未设置 | 设为 `1` / `true` 时跳过图片/字体自动下载 |
| `DANCEFENG_DEBUG` | 启用 | 设为 `0` 关闭插件调试输出 |
| `DANCEFENG_LOG_LEVEL` | `DEBUG` | 插件控制台日志级别 |
| `DANCEFENG_LOG_DIR` | `./logs` | 日志目录；设为 `0` 关闭文件日志 |

### NoneBot 配置

- `SUPERUSERS`：管理员 QQ 号列表，插件管理员命令会识别该配置；
- `COMMAND_START`：命令前缀，建议保留默认值。

## 🎉 使用
### 指令表
详见https://www.kdocs.cn/l/ccLRaUCuNMX0。
### 🎨 效果图

<br>
<img src="https://raw.githubusercontent.com/DanceFengBot/nonebot-plugin-dancefengbot/refs/heads/master/docs/mydc.png" alt="mydc" style="zoom:90%;" /><img src="https://raw.githubusercontent.com/DanceFengBot/nonebot-plugin-dancefengbot/refs/heads/master/docs/myrt.png" alt="myrt" style="zoom:30%;" />