nonebot-plugin-dancefengbot 2026.12.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- nonebot_plugin_dancefengbot-2026.12.3/PKG-INFO +120 -0
- nonebot_plugin_dancefengbot-2026.12.3/README.md +102 -0
- nonebot_plugin_dancefengbot-2026.12.3/pyproject.toml +140 -0
- nonebot_plugin_dancefengbot-2026.12.3/src/nonebot_plugin_dancefengbot/__init__.py +225 -0
- nonebot_plugin_dancefengbot-2026.12.3/src/nonebot_plugin_dancefengbot/api/__init__.py +19 -0
- nonebot_plugin_dancefengbot-2026.12.3/src/nonebot_plugin_dancefengbot/api/ladder.py +60 -0
- nonebot_plugin_dancefengbot-2026.12.3/src/nonebot_plugin_dancefengbot/api/lv_ratio_history.py +61 -0
- nonebot_plugin_dancefengbot-2026.12.3/src/nonebot_plugin_dancefengbot/api/machine.py +102 -0
- nonebot_plugin_dancefengbot-2026.12.3/src/nonebot_plugin_dancefengbot/api/maker.py +200 -0
- nonebot_plugin_dancefengbot-2026.12.3/src/nonebot_plugin_dancefengbot/api/phone_login.py +89 -0
- nonebot_plugin_dancefengbot-2026.12.3/src/nonebot_plugin_dancefengbot/api/player_music.py +25 -0
- nonebot_plugin_dancefengbot-2026.12.3/src/nonebot_plugin_dancefengbot/assets.py +201 -0
- nonebot_plugin_dancefengbot-2026.12.3/src/nonebot_plugin_dancefengbot/command_list.py +82 -0
- nonebot_plugin_dancefengbot-2026.12.3/src/nonebot_plugin_dancefengbot/commands/__init__.py +5 -0
- nonebot_plugin_dancefengbot-2026.12.3/src/nonebot_plugin_dancefengbot/commands/creator.py +332 -0
- nonebot_plugin_dancefengbot-2026.12.3/src/nonebot_plugin_dancefengbot/commands/info_ratio.py +272 -0
- nonebot_plugin_dancefengbot-2026.12.3/src/nonebot_plugin_dancefengbot/commands/login.py +223 -0
- nonebot_plugin_dancefengbot-2026.12.3/src/nonebot_plugin_dancefengbot/commands/misc.py +295 -0
- nonebot_plugin_dancefengbot-2026.12.3/src/nonebot_plugin_dancefengbot/commands/server_status.py +30 -0
- nonebot_plugin_dancefengbot-2026.12.3/src/nonebot_plugin_dancefengbot/config.py +228 -0
- nonebot_plugin_dancefengbot-2026.12.3/src/nonebot_plugin_dancefengbot/curfew.py +344 -0
- nonebot_plugin_dancefengbot-2026.12.3/src/nonebot_plugin_dancefengbot/deps.py +155 -0
- nonebot_plugin_dancefengbot-2026.12.3/src/nonebot_plugin_dancefengbot/image/__init__.py +21 -0
- nonebot_plugin_dancefengbot-2026.12.3/src/nonebot_plugin_dancefengbot/image/common.py +210 -0
- nonebot_plugin_dancefengbot-2026.12.3/src/nonebot_plugin_dancefengbot/image/drawer.py +150 -0
- nonebot_plugin_dancefengbot-2026.12.3/src/nonebot_plugin_dancefengbot/image/effect.py +41 -0
- nonebot_plugin_dancefengbot-2026.12.3/src/nonebot_plugin_dancefengbot/image/level_scores.py +58 -0
- nonebot_plugin_dancefengbot-2026.12.3/src/nonebot_plugin_dancefengbot/image/user_info.py +111 -0
- nonebot_plugin_dancefengbot-2026.12.3/src/nonebot_plugin_dancefengbot/image/user_ratio.py +61 -0
- nonebot_plugin_dancefengbot-2026.12.3/src/nonebot_plugin_dancefengbot/image/user_ratio_ap30.py +44 -0
- nonebot_plugin_dancefengbot-2026.12.3/src/nonebot_plugin_dancefengbot/image/user_ratio_b30.py +44 -0
- nonebot_plugin_dancefengbot-2026.12.3/src/nonebot_plugin_dancefengbot/info/__init__.py +17 -0
- nonebot_plugin_dancefengbot-2026.12.3/src/nonebot_plugin_dancefengbot/info/account.py +39 -0
- nonebot_plugin_dancefengbot-2026.12.3/src/nonebot_plugin_dancefengbot/info/reply_item.py +69 -0
- nonebot_plugin_dancefengbot-2026.12.3/src/nonebot_plugin_dancefengbot/info/server_status.py +362 -0
- nonebot_plugin_dancefengbot-2026.12.3/src/nonebot_plugin_dancefengbot/info/song_score.py +66 -0
- nonebot_plugin_dancefengbot-2026.12.3/src/nonebot_plugin_dancefengbot/info/status.py +11 -0
- nonebot_plugin_dancefengbot-2026.12.3/src/nonebot_plugin_dancefengbot/info/user.py +154 -0
- nonebot_plugin_dancefengbot-2026.12.3/src/nonebot_plugin_dancefengbot/music/__init__.py +41 -0
- nonebot_plugin_dancefengbot-2026.12.3/src/nonebot_plugin_dancefengbot/music/cover.py +242 -0
- nonebot_plugin_dancefengbot-2026.12.3/src/nonebot_plugin_dancefengbot/music/cover_update.py +226 -0
- nonebot_plugin_dancefengbot-2026.12.3/src/nonebot_plugin_dancefengbot/music/model.py +10 -0
- nonebot_plugin_dancefengbot-2026.12.3/src/nonebot_plugin_dancefengbot/music/util.py +92 -0
- nonebot_plugin_dancefengbot-2026.12.3/src/nonebot_plugin_dancefengbot/ratio/__init__.py +35 -0
- nonebot_plugin_dancefengbot-2026.12.3/src/nonebot_plugin_dancefengbot/ratio/acc_grade.py +23 -0
- nonebot_plugin_dancefengbot-2026.12.3/src/nonebot_plugin_dancefengbot/ratio/calculator.py +178 -0
- nonebot_plugin_dancefengbot-2026.12.3/src/nonebot_plugin_dancefengbot/ratio/rank_music.py +32 -0
- nonebot_plugin_dancefengbot-2026.12.3/src/nonebot_plugin_dancefengbot/ratio/recent_music.py +57 -0
- nonebot_plugin_dancefengbot-2026.12.3/src/nonebot_plugin_dancefengbot/ratio/recorded.py +47 -0
- nonebot_plugin_dancefengbot-2026.12.3/src/nonebot_plugin_dancefengbot/store.py +41 -0
- nonebot_plugin_dancefengbot-2026.12.3/src/nonebot_plugin_dancefengbot/token/__init__.py +6 -0
- nonebot_plugin_dancefengbot-2026.12.3/src/nonebot_plugin_dancefengbot/token/builder.py +140 -0
- nonebot_plugin_dancefengbot-2026.12.3/src/nonebot_plugin_dancefengbot/token/token.py +120 -0
- nonebot_plugin_dancefengbot-2026.12.3/src/nonebot_plugin_dancefengbot/utils/__init__.py +1 -0
- nonebot_plugin_dancefengbot-2026.12.3/src/nonebot_plugin_dancefengbot/utils/crypto.py +55 -0
- nonebot_plugin_dancefengbot-2026.12.3/src/nonebot_plugin_dancefengbot/utils/fonts.py +61 -0
- nonebot_plugin_dancefengbot-2026.12.3/src/nonebot_plugin_dancefengbot/utils/http.py +286 -0
- nonebot_plugin_dancefengbot-2026.12.3/src/nonebot_plugin_dancefengbot/utils/logger.py +557 -0
- nonebot_plugin_dancefengbot-2026.12.3/src/nonebot_plugin_dancefengbot/utils/tencent.py +109 -0
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
|
+
Name: nonebot-plugin-dancefengbot
|
|
3
|
+
Version: 2026.12.3
|
|
4
|
+
Summary: 为舞立方玩家提供高效便捷的数据查询服务
|
|
5
|
+
Author: DanceFengBot
|
|
6
|
+
Author-email: DanceFengBot <dancefengbot@users.noreply.github.com>
|
|
7
|
+
Requires-Dist: nonebot2[aiohttp,fastapi,httpx]>=2.5.0
|
|
8
|
+
Requires-Dist: nonebot-adapter-onebot>=2.4.6
|
|
9
|
+
Requires-Dist: nonebot-plugin-apscheduler>=0.5.0
|
|
10
|
+
Requires-Dist: pillow>=10.0.0
|
|
11
|
+
Requires-Dist: pyyaml>=6.0
|
|
12
|
+
Requires-Dist: pycryptodome>=3.20.0
|
|
13
|
+
Requires-Python: >=3.11, <4.0
|
|
14
|
+
Project-URL: Homepage, https://github.com/DanceFengBot/nonebot-plugin-dancefengbot
|
|
15
|
+
Project-URL: Issues, https://github.com/DanceFengBot/nonebot-plugin-dancefengbot/issues
|
|
16
|
+
Project-URL: Repository, https://github.com/DanceFengBot/nonebot-plugin-dancefengbot
|
|
17
|
+
Description-Content-Type: text/markdown
|
|
18
|
+
|
|
19
|
+
<div align="center">
|
|
20
|
+
<a href="https://v2.nonebot.dev/store">
|
|
21
|
+
<img src="https://raw.githubusercontent.com/fllesser/nonebot-plugin-template/refs/heads/resource/.docs/NoneBotPlugin.svg" width="310" alt="logo"></a>
|
|
22
|
+
|
|
23
|
+
## ✨ {plugin-name} ✨
|
|
24
|
+
[](./LICENSE)
|
|
25
|
+
[](https://pypi.python.org/pypi/nonebot-plugin-dancefengbot)
|
|
26
|
+
[](https://www.python.org)
|
|
27
|
+
[](https://github.com/astral-sh/uv)
|
|
28
|
+
<br/>
|
|
29
|
+
[](https://github.com/astral-sh/ruff)
|
|
30
|
+
[](https://results.pre-commit.ci/latest/github/{owner}/{plugin-name}/master)
|
|
31
|
+
|
|
32
|
+
</div>
|
|
33
|
+
|
|
34
|
+
## 📖 介绍
|
|
35
|
+
|
|
36
|
+
这里是插件的详细介绍部分
|
|
37
|
+
|
|
38
|
+
## 💿 安装
|
|
39
|
+
|
|
40
|
+
<details open>
|
|
41
|
+
<summary>使用 nb-cli 安装</summary>
|
|
42
|
+
在 nonebot2 项目的根目录下打开命令行, 输入以下指令即可安装
|
|
43
|
+
|
|
44
|
+
nb plugin install nonebot-plugin-dancefengbot --upgrade
|
|
45
|
+
使用 **pypi** 源安装
|
|
46
|
+
|
|
47
|
+
nb plugin install nonebot-plugin-dancefengbot --upgrade -i "https://pypi.org/simple"
|
|
48
|
+
使用**清华源**安装
|
|
49
|
+
|
|
50
|
+
nb plugin install nonebot-plugin-dancefengbot --upgrade -i "https://pypi.tuna.tsinghua.edu.cn/simple"
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
</details>
|
|
54
|
+
|
|
55
|
+
<details>
|
|
56
|
+
<summary>使用包管理器安装</summary>
|
|
57
|
+
在 nonebot2 项目的插件目录下, 打开命令行, 根据你使用的包管理器, 输入相应的安装命令
|
|
58
|
+
|
|
59
|
+
<details open>
|
|
60
|
+
<summary>uv</summary>
|
|
61
|
+
|
|
62
|
+
uv add nonebot-plugin-dancefengbot
|
|
63
|
+
安装仓库 master 分支
|
|
64
|
+
|
|
65
|
+
uv add git+https://github.com/DanceFengBot/nonebot-plugin-dancefengbot@master
|
|
66
|
+
</details>
|
|
67
|
+
|
|
68
|
+
<details>
|
|
69
|
+
<summary>pdm</summary>
|
|
70
|
+
|
|
71
|
+
pdm add nonebot-plugin-dancefengbot
|
|
72
|
+
安装仓库 master 分支
|
|
73
|
+
|
|
74
|
+
pdm add git+https://github.com/DanceFengBot/nonebot-plugin-dancefengbot@master
|
|
75
|
+
</details>
|
|
76
|
+
<details>
|
|
77
|
+
<summary>poetry</summary>
|
|
78
|
+
|
|
79
|
+
poetry add nonebot-plugin-dancefengbot
|
|
80
|
+
安装仓库 master 分支
|
|
81
|
+
|
|
82
|
+
poetry add git+https://github.com/DanceFengBot/nonebot-plugin-dancefengbot@master
|
|
83
|
+
</details>
|
|
84
|
+
|
|
85
|
+
打开 nonebot2 项目根目录下的 `pyproject.toml` 文件, 在 `[tool.nonebot]` 部分追加写入
|
|
86
|
+
|
|
87
|
+
plugins = ["nonebot_plugin_dancefengbot"]
|
|
88
|
+
|
|
89
|
+
</details>
|
|
90
|
+
|
|
91
|
+
<details>
|
|
92
|
+
<summary>使用 nbr 安装(使用 uv 管理依赖可用)</summary>
|
|
93
|
+
|
|
94
|
+
[nbr](https://github.com/fllesser/nbr) 是一个基于 uv 的 nb-cli,可以方便地管理 nonebot2
|
|
95
|
+
|
|
96
|
+
nbr plugin install nonebot-plugin-dancefengbot
|
|
97
|
+
使用 **pypi** 源安装
|
|
98
|
+
|
|
99
|
+
nbr plugin install nonebot-plugin-dancefengbot -i "https://pypi.org/simple"
|
|
100
|
+
使用**清华源**安装
|
|
101
|
+
|
|
102
|
+
nbr plugin install nonebot-plugin-dancefengbot -i "https://pypi.tuna.tsinghua.edu.cn/simple"
|
|
103
|
+
|
|
104
|
+
</details>
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
## ⚙️ 配置
|
|
108
|
+
|
|
109
|
+
在 nonebot2 项目的`.env`文件中添加下表中的必填配置
|
|
110
|
+
|
|
111
|
+
| 配置项 | 必填 | 默认值 | 说明 |
|
|
112
|
+
| :-----: | :---: | :----: | :------: |
|
|
113
|
+
| 配置项1 | 是 | 无 | 配置说明 |
|
|
114
|
+
| 配置项2 | 否 | 无 | 配置说明 |
|
|
115
|
+
|
|
116
|
+
## 🎉 使用
|
|
117
|
+
### 指令表
|
|
118
|
+
详见https://www.kdocs.cn/l/ccLRaUCuNMX0。
|
|
119
|
+
### 🎨 效果图
|
|
120
|
+
如果有效果图的话
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
<a href="https://v2.nonebot.dev/store">
|
|
3
|
+
<img src="https://raw.githubusercontent.com/fllesser/nonebot-plugin-template/refs/heads/resource/.docs/NoneBotPlugin.svg" width="310" alt="logo"></a>
|
|
4
|
+
|
|
5
|
+
## ✨ {plugin-name} ✨
|
|
6
|
+
[](./LICENSE)
|
|
7
|
+
[](https://pypi.python.org/pypi/nonebot-plugin-dancefengbot)
|
|
8
|
+
[](https://www.python.org)
|
|
9
|
+
[](https://github.com/astral-sh/uv)
|
|
10
|
+
<br/>
|
|
11
|
+
[](https://github.com/astral-sh/ruff)
|
|
12
|
+
[](https://results.pre-commit.ci/latest/github/{owner}/{plugin-name}/master)
|
|
13
|
+
|
|
14
|
+
</div>
|
|
15
|
+
|
|
16
|
+
## 📖 介绍
|
|
17
|
+
|
|
18
|
+
这里是插件的详细介绍部分
|
|
19
|
+
|
|
20
|
+
## 💿 安装
|
|
21
|
+
|
|
22
|
+
<details open>
|
|
23
|
+
<summary>使用 nb-cli 安装</summary>
|
|
24
|
+
在 nonebot2 项目的根目录下打开命令行, 输入以下指令即可安装
|
|
25
|
+
|
|
26
|
+
nb plugin install nonebot-plugin-dancefengbot --upgrade
|
|
27
|
+
使用 **pypi** 源安装
|
|
28
|
+
|
|
29
|
+
nb plugin install nonebot-plugin-dancefengbot --upgrade -i "https://pypi.org/simple"
|
|
30
|
+
使用**清华源**安装
|
|
31
|
+
|
|
32
|
+
nb plugin install nonebot-plugin-dancefengbot --upgrade -i "https://pypi.tuna.tsinghua.edu.cn/simple"
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
</details>
|
|
36
|
+
|
|
37
|
+
<details>
|
|
38
|
+
<summary>使用包管理器安装</summary>
|
|
39
|
+
在 nonebot2 项目的插件目录下, 打开命令行, 根据你使用的包管理器, 输入相应的安装命令
|
|
40
|
+
|
|
41
|
+
<details open>
|
|
42
|
+
<summary>uv</summary>
|
|
43
|
+
|
|
44
|
+
uv add nonebot-plugin-dancefengbot
|
|
45
|
+
安装仓库 master 分支
|
|
46
|
+
|
|
47
|
+
uv add git+https://github.com/DanceFengBot/nonebot-plugin-dancefengbot@master
|
|
48
|
+
</details>
|
|
49
|
+
|
|
50
|
+
<details>
|
|
51
|
+
<summary>pdm</summary>
|
|
52
|
+
|
|
53
|
+
pdm add nonebot-plugin-dancefengbot
|
|
54
|
+
安装仓库 master 分支
|
|
55
|
+
|
|
56
|
+
pdm add git+https://github.com/DanceFengBot/nonebot-plugin-dancefengbot@master
|
|
57
|
+
</details>
|
|
58
|
+
<details>
|
|
59
|
+
<summary>poetry</summary>
|
|
60
|
+
|
|
61
|
+
poetry add nonebot-plugin-dancefengbot
|
|
62
|
+
安装仓库 master 分支
|
|
63
|
+
|
|
64
|
+
poetry add git+https://github.com/DanceFengBot/nonebot-plugin-dancefengbot@master
|
|
65
|
+
</details>
|
|
66
|
+
|
|
67
|
+
打开 nonebot2 项目根目录下的 `pyproject.toml` 文件, 在 `[tool.nonebot]` 部分追加写入
|
|
68
|
+
|
|
69
|
+
plugins = ["nonebot_plugin_dancefengbot"]
|
|
70
|
+
|
|
71
|
+
</details>
|
|
72
|
+
|
|
73
|
+
<details>
|
|
74
|
+
<summary>使用 nbr 安装(使用 uv 管理依赖可用)</summary>
|
|
75
|
+
|
|
76
|
+
[nbr](https://github.com/fllesser/nbr) 是一个基于 uv 的 nb-cli,可以方便地管理 nonebot2
|
|
77
|
+
|
|
78
|
+
nbr plugin install nonebot-plugin-dancefengbot
|
|
79
|
+
使用 **pypi** 源安装
|
|
80
|
+
|
|
81
|
+
nbr plugin install nonebot-plugin-dancefengbot -i "https://pypi.org/simple"
|
|
82
|
+
使用**清华源**安装
|
|
83
|
+
|
|
84
|
+
nbr plugin install nonebot-plugin-dancefengbot -i "https://pypi.tuna.tsinghua.edu.cn/simple"
|
|
85
|
+
|
|
86
|
+
</details>
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
## ⚙️ 配置
|
|
90
|
+
|
|
91
|
+
在 nonebot2 项目的`.env`文件中添加下表中的必填配置
|
|
92
|
+
|
|
93
|
+
| 配置项 | 必填 | 默认值 | 说明 |
|
|
94
|
+
| :-----: | :---: | :----: | :------: |
|
|
95
|
+
| 配置项1 | 是 | 无 | 配置说明 |
|
|
96
|
+
| 配置项2 | 否 | 无 | 配置说明 |
|
|
97
|
+
|
|
98
|
+
## 🎉 使用
|
|
99
|
+
### 指令表
|
|
100
|
+
详见https://www.kdocs.cn/l/ccLRaUCuNMX0。
|
|
101
|
+
### 🎨 效果图
|
|
102
|
+
如果有效果图的话
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "nonebot-plugin-dancefengbot"
|
|
3
|
+
version = "2026.12.3"
|
|
4
|
+
description = "为舞立方玩家提供高效便捷的数据查询服务"
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
requires-python = ">=3.11, <4.0"
|
|
7
|
+
authors = [{ name = "DanceFengBot", email = "dancefengbot@users.noreply.github.com" }]
|
|
8
|
+
dependencies = [
|
|
9
|
+
"nonebot2[aiohttp,fastapi,httpx]>=2.5.0",
|
|
10
|
+
"nonebot-adapter-onebot>=2.4.6",
|
|
11
|
+
"nonebot-plugin-apscheduler>=0.5.0",
|
|
12
|
+
"Pillow>=10.0.0",
|
|
13
|
+
"PyYAML>=6.0",
|
|
14
|
+
"pycryptodome>=3.20.0"
|
|
15
|
+
]
|
|
16
|
+
|
|
17
|
+
[project.urls]
|
|
18
|
+
Homepage = "https://github.com/DanceFengBot/nonebot-plugin-dancefengbot"
|
|
19
|
+
Issues = "https://github.com/DanceFengBot/nonebot-plugin-dancefengbot/issues"
|
|
20
|
+
Repository = "https://github.com/DanceFengBot/nonebot-plugin-dancefengbot"
|
|
21
|
+
|
|
22
|
+
[dependency-groups]
|
|
23
|
+
dev = [
|
|
24
|
+
"bump-my-version>=1.2.7",
|
|
25
|
+
"nonebot2[fastapi]>=2.5.0,<3.0.0",
|
|
26
|
+
"poethepoet>=0.42.1",
|
|
27
|
+
"ruff>=0.15.2,<1.0.0",
|
|
28
|
+
{ include-group = "test" },
|
|
29
|
+
]
|
|
30
|
+
test = [
|
|
31
|
+
"nonebot-adapter-onebot>=2.4.6,<3.0.0",
|
|
32
|
+
"nonebot2[fastapi]>=2.5.0,<3.0.0",
|
|
33
|
+
"nonebug>=0.4.4,<1.0.0",
|
|
34
|
+
"pytest>=9.0.2,<10.0.0",
|
|
35
|
+
"poethepoet>=0.42.1",
|
|
36
|
+
"pytest-asyncio>=1.3.0,<1.4.0",
|
|
37
|
+
"pytest-cov>=7.0.0",
|
|
38
|
+
"pytest-xdist>=3.8.0,<4.0.0",
|
|
39
|
+
]
|
|
40
|
+
|
|
41
|
+
[build-system]
|
|
42
|
+
requires = ["uv_build>=0.10.0,<0.11.0"]
|
|
43
|
+
build-backend = "uv_build"
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
[tool.bumpversion]
|
|
47
|
+
current_version = "2026.12.1"
|
|
48
|
+
commit = true
|
|
49
|
+
message = "release: bump vesion from {current_version} to {new_version}"
|
|
50
|
+
tag = true
|
|
51
|
+
|
|
52
|
+
[[tool.bumpversion.files]]
|
|
53
|
+
filename = "uv.lock"
|
|
54
|
+
search = "name = \"nonebot-plugin-dancefengbot\"\nversion = \"{current_version}\""
|
|
55
|
+
replace = "name = \"nonebot-plugin-dancefengbot\"\nversion = \"{new_version}\""
|
|
56
|
+
|
|
57
|
+
[tool.coverage.report]
|
|
58
|
+
exclude_lines = [
|
|
59
|
+
"raise NotImplementedError",
|
|
60
|
+
"if TYPE_CHECKING:",
|
|
61
|
+
"@overload",
|
|
62
|
+
"except ImportError:",
|
|
63
|
+
]
|
|
64
|
+
|
|
65
|
+
[tool.nonebot]
|
|
66
|
+
plugins = ["nonebot_plugin_dancefengbot"]
|
|
67
|
+
|
|
68
|
+
[tool.poe.tasks]
|
|
69
|
+
test = "pytest --cov=src --cov-report xml --junitxml=./junit.xml -n auto"
|
|
70
|
+
bump = "bump-my-version bump"
|
|
71
|
+
show-bump = "bump-my-version show-bump"
|
|
72
|
+
|
|
73
|
+
[tool.pyright]
|
|
74
|
+
pythonVersion = "3.11"
|
|
75
|
+
venvPath = "."
|
|
76
|
+
venv = ".venv"
|
|
77
|
+
pythonPlatform = "All"
|
|
78
|
+
defineConstant = { PYDANTIC_V2 = true }
|
|
79
|
+
executionEnvironments = [
|
|
80
|
+
{ root = "./tests", extraPaths = [
|
|
81
|
+
"./src",
|
|
82
|
+
] },
|
|
83
|
+
{ root = "./src" },
|
|
84
|
+
]
|
|
85
|
+
typeCheckingMode = "standard"
|
|
86
|
+
disableBytesTypePromotions = true
|
|
87
|
+
|
|
88
|
+
[tool.pytest]
|
|
89
|
+
addopts = [
|
|
90
|
+
"--import-mode=prepend", # 导入模式
|
|
91
|
+
"--strict-markers", # 严格标记模式
|
|
92
|
+
"--tb=short", # 简短的错误回溯
|
|
93
|
+
"-ra", # 显示所有测试结果摘要
|
|
94
|
+
"-s", # 显示打印信息
|
|
95
|
+
"-v", # 详细输出
|
|
96
|
+
]
|
|
97
|
+
pythonpath = ["src"]
|
|
98
|
+
asyncio_mode = "auto"
|
|
99
|
+
asyncio_default_fixture_loop_scope = "session"
|
|
100
|
+
|
|
101
|
+
[tool.ruff]
|
|
102
|
+
line-length = 120
|
|
103
|
+
|
|
104
|
+
[tool.ruff.format]
|
|
105
|
+
line-ending = "lf"
|
|
106
|
+
|
|
107
|
+
[tool.ruff.lint]
|
|
108
|
+
select = [
|
|
109
|
+
"F", # Pyflakes
|
|
110
|
+
"W", # pycodestyle warnings
|
|
111
|
+
"E", # pycodestyle errors
|
|
112
|
+
"I", # isort
|
|
113
|
+
"UP", # pyupgrade
|
|
114
|
+
"ASYNC", # flake8-async
|
|
115
|
+
"C4", # flake8-comprehensions
|
|
116
|
+
"T10", # flake8-debugger
|
|
117
|
+
"T20", # flake8-print
|
|
118
|
+
"PYI", # flake8-pyi
|
|
119
|
+
"PT", # flake8-pytest-style
|
|
120
|
+
"Q", # flake8-quotes
|
|
121
|
+
"TID", # flake8-tidy-imports
|
|
122
|
+
"RUF", # Ruff-specific rules
|
|
123
|
+
]
|
|
124
|
+
ignore = [
|
|
125
|
+
"E402", # module-import-not-at-top-of-file
|
|
126
|
+
"UP037", # quoted-annotation
|
|
127
|
+
"RUF001", # ambiguous-unicode-character-string
|
|
128
|
+
"RUF002", # ambiguous-unicode-character-docstring
|
|
129
|
+
"RUF003", # ambiguous-unicode-character-comment
|
|
130
|
+
"W191", # indentation contains tabs
|
|
131
|
+
"TID252", # relative-import
|
|
132
|
+
]
|
|
133
|
+
|
|
134
|
+
[tool.ruff.lint.isort]
|
|
135
|
+
length-sort = true
|
|
136
|
+
known-first-party = ["tests/*"]
|
|
137
|
+
extra-standard-library = ["typing_extensions"]
|
|
138
|
+
|
|
139
|
+
[tool.ruff.lint.pyupgrade]
|
|
140
|
+
keep-runtime-typing = true
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
"""DanceFengBot — 舞立方 QQ 机器人(NoneBot2 + OneBot V11)。
|
|
2
|
+
|
|
3
|
+
对应 Java 版 DanceFengBot 的入口:负责加载 Token、定时刷新 Token,
|
|
4
|
+
并注册所有命令事件响应器。
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
import time
|
|
10
|
+
import asyncio
|
|
11
|
+
|
|
12
|
+
from nonebot import get_driver, on_request
|
|
13
|
+
from nonebot.plugin import PluginMetadata
|
|
14
|
+
from nonebot.adapters.onebot.v11 import Bot, FriendRequestEvent
|
|
15
|
+
|
|
16
|
+
__version__ = "2026.12.1"
|
|
17
|
+
|
|
18
|
+
__plugin_meta__ = PluginMetadata(
|
|
19
|
+
name="舞小枫",
|
|
20
|
+
description="舞立方查询、战力分析、创作者工具与扫码登录的 NoneBot2 插件",
|
|
21
|
+
usage="私聊发送「登录」扫码绑定账号;发送「菜单」查看全部指令。",
|
|
22
|
+
type="application",
|
|
23
|
+
homepage="https://github.com/DanceFengBot/DanceFengBot-Python",
|
|
24
|
+
supported_adapters={"~onebot.v11"},
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
# 导入 curfew 即注册全局的宵禁拦截与回复延迟(对所有功能生效)
|
|
28
|
+
from . import store, curfew
|
|
29
|
+
from .deps import clear_cache
|
|
30
|
+
from .utils import logger
|
|
31
|
+
from .commands import misc, login, info_ratio # noqa: F401 # 注册命令
|
|
32
|
+
|
|
33
|
+
# 黑名单 / 白名单:导入即加载配置文件并注册全局拦截器
|
|
34
|
+
# from . import access_list as _access_list # 需在日志初始化之后导入
|
|
35
|
+
|
|
36
|
+
driver = get_driver()
|
|
37
|
+
|
|
38
|
+
# 记录插件加载起点,用于在启动完成时报告启动耗时
|
|
39
|
+
_PLUGIN_LOAD_START = time.perf_counter()
|
|
40
|
+
_STARTED = False
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def _format_address(host: str, port: int) -> str:
|
|
44
|
+
"""格式化监听地址(IPv6 需要加方括号)。"""
|
|
45
|
+
host = str(host or "127.0.0.1")
|
|
46
|
+
shown = f"[{host}]" if ":" in host else host
|
|
47
|
+
return f"{shown}:{port}"
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def _describe_connect_paths() -> list[str]:
|
|
51
|
+
"""从驱动的 ASGI 应用路由中找出 WebSocket 连接路径。"""
|
|
52
|
+
paths: list[str] = []
|
|
53
|
+
try:
|
|
54
|
+
app = getattr(driver, "server_app", None)
|
|
55
|
+
for route in getattr(app, "routes", []):
|
|
56
|
+
path = getattr(route, "path", "")
|
|
57
|
+
if isinstance(path, str) and path.endswith("/ws"):
|
|
58
|
+
paths.append(path)
|
|
59
|
+
except Exception: # 探测失败不影响启动
|
|
60
|
+
return []
|
|
61
|
+
return paths
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def _log_startup_ready() -> None:
|
|
65
|
+
"""打印“已开始监听”的明确信息。
|
|
66
|
+
|
|
67
|
+
NoneBot 使用 loguru,而 uvicorn 自身的日志经 ``LoguruHandler`` 转发时受限,
|
|
68
|
+
控制台里通常看不到 "Uvicorn running on ..." 这类提示,容易误判为启动卡死。
|
|
69
|
+
这里在启动钩子结束时给出可核对的信息:监听地址、WS 路径与启动耗时。
|
|
70
|
+
"""
|
|
71
|
+
host = getattr(driver.config, "host", None) or "127.0.0.1"
|
|
72
|
+
port = getattr(driver.config, "port", None) or 0
|
|
73
|
+
address = _format_address(host, port)
|
|
74
|
+
elapsed = time.perf_counter() - _PLUGIN_LOAD_START
|
|
75
|
+
|
|
76
|
+
lines = [
|
|
77
|
+
"=" * 50,
|
|
78
|
+
" DanceFengBot 启动完成,服务已开始监听",
|
|
79
|
+
f" 监听地址:{address}(启动耗时 {elapsed:.2f}s)",
|
|
80
|
+
]
|
|
81
|
+
paths = _describe_connect_paths()
|
|
82
|
+
if paths:
|
|
83
|
+
lines.append(f" OneBot 连接路径:{'、'.join(paths)}")
|
|
84
|
+
lines.append(f" 例:ws://{address}{paths[0]}")
|
|
85
|
+
lines.append(" 若此处长时间无后续日志:说明服务已在跑,等待 OneBot 端连接即可")
|
|
86
|
+
lines.append("=" * 50)
|
|
87
|
+
for line in lines:
|
|
88
|
+
logger.info(line)
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
# ---------------------------------------------------------------- Token 刷新任务
|
|
92
|
+
def refresh_all_tokens() -> None:
|
|
93
|
+
"""刷新全部 Token 并落盘(对应 Java 端 RefreshTokenJob)。"""
|
|
94
|
+
total = len(store.user_tokens_map)
|
|
95
|
+
logger.info(f"[定时任务] 开始刷新全部 Token,共 {total} 条")
|
|
96
|
+
valid = 0
|
|
97
|
+
for qq, token in list(store.user_tokens_map.items()):
|
|
98
|
+
try:
|
|
99
|
+
if token.refresh():
|
|
100
|
+
valid += 1
|
|
101
|
+
else:
|
|
102
|
+
logger.warning(f"[定时任务] QQ={qq} 的 Token 刷新失败")
|
|
103
|
+
except Exception:
|
|
104
|
+
logger.exception(f"[定时任务] QQ={qq} 刷新 token 异常")
|
|
105
|
+
store.save_tokens()
|
|
106
|
+
logger.info(f"#读取共{total}个token,有效token共{valid}个")
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
def _setup_scheduler() -> None:
|
|
110
|
+
"""使用 nonebot-plugin-apscheduler 注册每日 Token 刷新、缓存清理与封面更新任务。"""
|
|
111
|
+
try:
|
|
112
|
+
from nonebot import require
|
|
113
|
+
|
|
114
|
+
require("nonebot_plugin_apscheduler")
|
|
115
|
+
from nonebot_plugin_apscheduler import scheduler
|
|
116
|
+
|
|
117
|
+
scheduler.add_job(
|
|
118
|
+
refresh_all_tokens,
|
|
119
|
+
"cron",
|
|
120
|
+
hour=3,
|
|
121
|
+
minute=10,
|
|
122
|
+
id="dance_feng_bot_refresh_tokens",
|
|
123
|
+
replace_existing=True,
|
|
124
|
+
)
|
|
125
|
+
logger.debug("[定时任务] 已注册每日 03:10 的 Token 刷新任务")
|
|
126
|
+
|
|
127
|
+
# 图片缓存只服务当天的消息发送,每天 0:00 清空 DcConfig/cache
|
|
128
|
+
scheduler.add_job(
|
|
129
|
+
clear_cache,
|
|
130
|
+
"cron",
|
|
131
|
+
hour=0,
|
|
132
|
+
minute=0,
|
|
133
|
+
id="dance_feng_bot_clear_image_cache",
|
|
134
|
+
replace_existing=True,
|
|
135
|
+
)
|
|
136
|
+
logger.debug("[定时任务] 已注册每日 00:00 的图片缓存清理任务")
|
|
137
|
+
|
|
138
|
+
# 官方曲目封面:每天 03:00 拉取最新封面清单,只补缺失的封面
|
|
139
|
+
from .music import run_scheduled_update
|
|
140
|
+
|
|
141
|
+
scheduler.add_job(
|
|
142
|
+
run_scheduled_update,
|
|
143
|
+
"cron",
|
|
144
|
+
hour=3,
|
|
145
|
+
minute=0,
|
|
146
|
+
id="dance_feng_bot_update_official_covers",
|
|
147
|
+
replace_existing=True,
|
|
148
|
+
)
|
|
149
|
+
logger.debug("[定时任务] 已注册每日 03:00 的官方曲目封面更新任务")
|
|
150
|
+
except Exception:
|
|
151
|
+
logger.warning("nonebot_plugin_apscheduler 不可用,已跳过每日自动刷新 Token、图片缓存清理与官方曲目封面更新")
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
# ---------------------------------------------------------------- 生命周期
|
|
155
|
+
@driver.on_startup
|
|
156
|
+
async def _on_startup() -> None:
|
|
157
|
+
global _STARTED
|
|
158
|
+
logger.info("[启动] 开始加载本地 Token 文件")
|
|
159
|
+
store.user_tokens_map = store.load_tokens(False)
|
|
160
|
+
logger.info(f"刷新加载成功!共{len(store.user_tokens_map)}条")
|
|
161
|
+
# 停机期间错过 0:00 清理时,启动后补一次(仅清掉非当天的图片缓存)
|
|
162
|
+
await asyncio.to_thread(clear_cache, keep_current_day=True)
|
|
163
|
+
# _start_access_list()
|
|
164
|
+
logger.info(f"[宵禁] {curfew.describe()}")
|
|
165
|
+
_log_startup_ready()
|
|
166
|
+
_STARTED = True
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
@driver.on_shutdown
|
|
170
|
+
async def _on_shutdown() -> None:
|
|
171
|
+
logger.info("[关闭] 正在保存 Token")
|
|
172
|
+
n = store.save_tokens()
|
|
173
|
+
logger.info(f"保存成功!共{n}条")
|
|
174
|
+
logger.info("[关闭] 机器人已停止,可以安全退出")
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
_setup_scheduler()
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
# ---------------------------------------------------------------- 连接状态提示
|
|
181
|
+
# 对应 OneBot 实现(如 go-cqhttp / LLOneBot)连接与断开,便于确认机器人是否真正在线
|
|
182
|
+
try:
|
|
183
|
+
from nonebot.internal.driver import Driver as _AnyDriver
|
|
184
|
+
except Exception: # 内部模块路径变化时退化为不注册连接钩子
|
|
185
|
+
_AnyDriver = None # type: ignore[assignment]
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
if _AnyDriver is not None:
|
|
189
|
+
|
|
190
|
+
@_AnyDriver.on_bot_connect
|
|
191
|
+
async def _on_bot_connected(bot: Bot) -> None:
|
|
192
|
+
logger.info(
|
|
193
|
+
f"[连接] OneBot 已接入:self_id={bot.self_id},适配器={bot.adapter.get_name()},现在可以正常收发消息"
|
|
194
|
+
)
|
|
195
|
+
if not _STARTED:
|
|
196
|
+
logger.warning("[连接] 收到 OneBot 连接,但启动流程尚未完成")
|
|
197
|
+
|
|
198
|
+
@_AnyDriver.on_bot_disconnect
|
|
199
|
+
async def _on_bot_disconnected(bot: Bot) -> None:
|
|
200
|
+
logger.warning(f"[连接] OneBot 已断开:self_id={bot.self_id},请确认 OneBot 端进程是否仍在运行")
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
# ---------------------------------------------------------------- 加好友自动同意
|
|
204
|
+
friend_request = on_request(priority=1, block=False)
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
@friend_request.handle()
|
|
208
|
+
async def _friend_request(event: FriendRequestEvent, bot: Bot) -> None:
|
|
209
|
+
# 加好友按私聊处理:只看 users 中的 QQ 号
|
|
210
|
+
# allowed, reason = _access_list.check_target(
|
|
211
|
+
# group_id=None, user_id=event.user_id, sender_id=event.user_id
|
|
212
|
+
# )
|
|
213
|
+
# if not allowed:
|
|
214
|
+
# logger.info(f"[加好友] 名单拦截,已忽略 QQ={event.user_id} 的好友请求:{reason}")
|
|
215
|
+
# return
|
|
216
|
+
logger.info(f"[加好友] 收到 QQ={event.user_id} 的好友请求,自动同意")
|
|
217
|
+
await event.approve(bot)
|
|
218
|
+
try:
|
|
219
|
+
await bot.send_private_msg(
|
|
220
|
+
user_id=event.user_id,
|
|
221
|
+
message="🥰呐~ 现在我们是好朋友啦!\n请发送“help”查看功能哦!",
|
|
222
|
+
)
|
|
223
|
+
logger.debug(f"[加好友] 已向 QQ={event.user_id} 发送欢迎语")
|
|
224
|
+
except Exception:
|
|
225
|
+
logger.exception("发送加好友欢迎语失败")
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"""舞立方 HTTP API 封装。"""
|
|
2
|
+
|
|
3
|
+
from .maker import MakerInfo, PublishedMusic, generate_music_code
|
|
4
|
+
from .ladder import Ladder
|
|
5
|
+
from .machine import Machine
|
|
6
|
+
from .phone_login import PhoneLoginBuilder
|
|
7
|
+
from .player_music import gain_music_by_code
|
|
8
|
+
from .lv_ratio_history import LvRatioHistory
|
|
9
|
+
|
|
10
|
+
__all__ = [
|
|
11
|
+
"Ladder",
|
|
12
|
+
"LvRatioHistory",
|
|
13
|
+
"Machine",
|
|
14
|
+
"MakerInfo",
|
|
15
|
+
"PhoneLoginBuilder",
|
|
16
|
+
"PublishedMusic",
|
|
17
|
+
"gain_music_by_code",
|
|
18
|
+
"generate_music_code",
|
|
19
|
+
]
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"""全民赛季(天梯)信息,对应 Java 端 ``com.DanceCube.api.Ladder``。"""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from ..token import Token
|
|
6
|
+
from ..utils import logger
|
|
7
|
+
from ..utils.http import http_get
|
|
8
|
+
|
|
9
|
+
_URL = "https://dancedemo.shenghuayule.com/Dance/api/Match/GetQuanMinSeasons"
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class Ladder:
|
|
13
|
+
def __init__(self) -> None:
|
|
14
|
+
self.match_define_id = 0
|
|
15
|
+
self.match_name = ""
|
|
16
|
+
self.start_time = ""
|
|
17
|
+
self.stop_time = ""
|
|
18
|
+
self.match_time_text = ""
|
|
19
|
+
self.level_point = 0
|
|
20
|
+
self.level_grade = 0
|
|
21
|
+
self.is_last = False
|
|
22
|
+
self.is_current = False
|
|
23
|
+
self.is_topest = False
|
|
24
|
+
|
|
25
|
+
@staticmethod
|
|
26
|
+
def get(token: Token) -> list["Ladder"]:
|
|
27
|
+
resp = http_get(
|
|
28
|
+
_URL,
|
|
29
|
+
headers={"Authorization": token.bearer_token},
|
|
30
|
+
context="天梯赛季",
|
|
31
|
+
)
|
|
32
|
+
if resp is None:
|
|
33
|
+
logger.warning("[天梯赛季] 请求失败,返回空列表")
|
|
34
|
+
return []
|
|
35
|
+
try:
|
|
36
|
+
arr = resp.json()
|
|
37
|
+
except Exception as exc:
|
|
38
|
+
logger.error(f"[天梯赛季] 响应解析失败:{exc}")
|
|
39
|
+
return []
|
|
40
|
+
result: list[Ladder] = []
|
|
41
|
+
for e in arr:
|
|
42
|
+
ladder = Ladder()
|
|
43
|
+
ladder.match_define_id = e.get("MatchDefineId", 0)
|
|
44
|
+
ladder.match_name = e.get("MatchName", "")
|
|
45
|
+
ladder.start_time = e.get("StartTime", "")
|
|
46
|
+
ladder.stop_time = e.get("StopTime", "")
|
|
47
|
+
ladder.match_time_text = e.get("MatchTimeText", "")
|
|
48
|
+
ladder.level_point = e.get("LevelPoint", 0)
|
|
49
|
+
ladder.level_grade = e.get("LevelGrade", 0)
|
|
50
|
+
ladder.is_last = e.get("IsLast", False)
|
|
51
|
+
ladder.is_current = e.get("IsCurrent", False)
|
|
52
|
+
ladder.is_topest = e.get("IsTopest", False)
|
|
53
|
+
result.append(ladder)
|
|
54
|
+
current = next((x for x in result if x.is_current), None)
|
|
55
|
+
logger.debug(
|
|
56
|
+
f"[天梯赛季] 共 {len(result)} 个赛季,"
|
|
57
|
+
f"当前赛季={current.match_name if current else '无'},"
|
|
58
|
+
f"段位={current.level_grade if current else '-'}"
|
|
59
|
+
)
|
|
60
|
+
return result
|