nonebot-plugin-bugu 0.2.0__tar.gz → 0.3.0__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_bugu-0.2.0 → nonebot_plugin_bugu-0.3.0}/PKG-INFO +8 -47
- {nonebot_plugin_bugu-0.2.0 → nonebot_plugin_bugu-0.3.0}/README.md +6 -45
- {nonebot_plugin_bugu-0.2.0 → nonebot_plugin_bugu-0.3.0}/nonebot_plugin_bugu/__init__.py +2 -3
- {nonebot_plugin_bugu-0.2.0 → nonebot_plugin_bugu-0.3.0}/nonebot_plugin_bugu/commands.py +5 -21
- {nonebot_plugin_bugu-0.2.0 → nonebot_plugin_bugu-0.3.0}/nonebot_plugin_bugu/config.py +0 -4
- {nonebot_plugin_bugu-0.2.0 → nonebot_plugin_bugu-0.3.0}/nonebot_plugin_bugu/draw.py +0 -25
- {nonebot_plugin_bugu-0.2.0 → nonebot_plugin_bugu-0.3.0}/nonebot_plugin_bugu/features/common.py +1 -32
- {nonebot_plugin_bugu-0.2.0 → nonebot_plugin_bugu-0.3.0}/nonebot_plugin_bugu/features/flowers/data.py +0 -3
- {nonebot_plugin_bugu-0.2.0 → nonebot_plugin_bugu-0.3.0}/nonebot_plugin_bugu/features/flowers/render.py +0 -8
- {nonebot_plugin_bugu-0.2.0 → nonebot_plugin_bugu-0.3.0}/nonebot_plugin_bugu/features/flowers/reply.py +0 -2
- {nonebot_plugin_bugu-0.2.0 → nonebot_plugin_bugu-0.3.0}/nonebot_plugin_bugu/features/neighbors/render.py +0 -1
- {nonebot_plugin_bugu-0.2.0 → nonebot_plugin_bugu-0.3.0}/nonebot_plugin_bugu/features/recipes/render.py +0 -16
- {nonebot_plugin_bugu-0.2.0 → nonebot_plugin_bugu-0.3.0}/nonebot_plugin_bugu/features/recipes/reply.py +0 -2
- {nonebot_plugin_bugu-0.2.0 → nonebot_plugin_bugu-0.3.0}/nonebot_plugin_bugu/features/starsea/render.py +5 -24
- {nonebot_plugin_bugu-0.2.0 → nonebot_plugin_bugu-0.3.0}/nonebot_plugin_bugu/features/starsea/reply.py +8 -33
- {nonebot_plugin_bugu-0.2.0 → nonebot_plugin_bugu-0.3.0}/nonebot_plugin_bugu/runtime.py +5 -35
- {nonebot_plugin_bugu-0.2.0 → nonebot_plugin_bugu-0.3.0}/pyproject.toml +2 -2
- nonebot_plugin_bugu-0.2.0/nonebot_plugin_bugu/collection.py +0 -166
- nonebot_plugin_bugu-0.2.0/nonebot_plugin_bugu/features/collection.py +0 -247
- {nonebot_plugin_bugu-0.2.0 → nonebot_plugin_bugu-0.3.0}/LICENSE +0 -0
- {nonebot_plugin_bugu-0.2.0 → nonebot_plugin_bugu-0.3.0}/nonebot_plugin_bugu/api.py +0 -0
- {nonebot_plugin_bugu-0.2.0 → nonebot_plugin_bugu-0.3.0}/nonebot_plugin_bugu/features/__init__.py +0 -0
- {nonebot_plugin_bugu-0.2.0 → nonebot_plugin_bugu-0.3.0}/nonebot_plugin_bugu/features/flowers/__init__.py +0 -0
- {nonebot_plugin_bugu-0.2.0 → nonebot_plugin_bugu-0.3.0}/nonebot_plugin_bugu/features/neighbors/__init__.py +0 -0
- {nonebot_plugin_bugu-0.2.0 → nonebot_plugin_bugu-0.3.0}/nonebot_plugin_bugu/features/neighbors/data.py +0 -0
- {nonebot_plugin_bugu-0.2.0 → nonebot_plugin_bugu-0.3.0}/nonebot_plugin_bugu/features/neighbors/reply.py +0 -0
- {nonebot_plugin_bugu-0.2.0 → nonebot_plugin_bugu-0.3.0}/nonebot_plugin_bugu/features/recipes/__init__.py +0 -0
- {nonebot_plugin_bugu-0.2.0 → nonebot_plugin_bugu-0.3.0}/nonebot_plugin_bugu/features/recipes/data.py +0 -0
- {nonebot_plugin_bugu-0.2.0 → nonebot_plugin_bugu-0.3.0}/nonebot_plugin_bugu/features/recipes/search.py +0 -0
- {nonebot_plugin_bugu-0.2.0 → nonebot_plugin_bugu-0.3.0}/nonebot_plugin_bugu/features/starsea/__init__.py +0 -0
- {nonebot_plugin_bugu-0.2.0 → nonebot_plugin_bugu-0.3.0}/nonebot_plugin_bugu/features/starsea/data.py +0 -0
- {nonebot_plugin_bugu-0.2.0 → nonebot_plugin_bugu-0.3.0}/nonebot_plugin_bugu/features/starsea/search.py +0 -0
- {nonebot_plugin_bugu-0.2.0 → nonebot_plugin_bugu-0.3.0}/nonebot_plugin_bugu/fonts.py +0 -0
- {nonebot_plugin_bugu-0.2.0 → nonebot_plugin_bugu-0.3.0}/nonebot_plugin_bugu/values.py +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: nonebot-plugin-bugu
|
|
3
|
-
Version: 0.
|
|
4
|
-
Summary:
|
|
3
|
+
Version: 0.3.0
|
|
4
|
+
Summary: 布谷工具箱(星布谷地小助手):菜谱、星海地图、友邻备忘与鲜花培育
|
|
5
5
|
License-Expression: MIT
|
|
6
6
|
License-File: LICENSE
|
|
7
7
|
Keywords: nonebot,nonebot2,onebot,bugu,starsea,recipe,星布谷地,星海地图,菜谱
|
|
@@ -28,6 +28,7 @@ Description-Content-Type: text/markdown
|
|
|
28
28
|
|
|
29
29
|
# nonebot-plugin-bugu
|
|
30
30
|
|
|
31
|
+
[](https://pypi.org/project/nonebot-plugin-bugu/)
|
|
31
32
|
[](LICENSE)
|
|
32
33
|
[](pyproject.toml)
|
|
33
34
|
[](https://nonebot.dev)
|
|
@@ -40,7 +41,6 @@ Description-Content-Type: text/markdown
|
|
|
40
41
|
| 🗺 **星海地图** | 3 张地图 43 个点位,底图自动编号 + 图例;点位详情是带品质色的图标墙;还能按物种反查「在哪几个岛」 |
|
|
41
42
|
| 🧑🤝🧑 **友邻备忘** | 10 位友邻的立绘、资料、介绍和喜爱 / 好感 / 反感 / 关于词条与友邻能力 |
|
|
42
43
|
| 🌷 **鲜花培育** | 13 个品种 87 种花色的杂交配方表 + 花色图鉴(品质、颜色、产地) |
|
|
43
|
-
| ✅ **收集进度** | 按 QQ 号记录已收集的物种 / 鲜花 / 菜谱,卡片上直接打勾,进度只存在本机 |
|
|
44
44
|
|
|
45
45
|

|
|
46
46
|
|
|
@@ -56,28 +56,18 @@ Description-Content-Type: text/markdown
|
|
|
56
56
|
|
|
57
57
|
需要 Python 3.9+ 和 NoneBot2(OneBot V11 适配器)。
|
|
58
58
|
|
|
59
|
-
### 从源码安装(当前可用)
|
|
60
|
-
|
|
61
59
|
```bash
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
poetry
|
|
60
|
+
nb plugin install nonebot-plugin-bugu # nb-cli
|
|
61
|
+
pip install nonebot-plugin-bugu # pip
|
|
62
|
+
poetry add nonebot-plugin-bugu # poetry
|
|
65
63
|
```
|
|
66
64
|
|
|
67
|
-
|
|
65
|
+
也可以直接从源码装:
|
|
68
66
|
|
|
69
67
|
```bash
|
|
70
68
|
pip install git+https://github.com/TonyLiangP2010405/nonebot-plugin-bugu
|
|
71
69
|
```
|
|
72
70
|
|
|
73
|
-
### 发布到 PyPI 后
|
|
74
|
-
|
|
75
|
-
```bash
|
|
76
|
-
nb plugin install nonebot-plugin-bugu # nb-cli
|
|
77
|
-
pip install nonebot-plugin-bugu # pip
|
|
78
|
-
poetry add nonebot-plugin-bugu # poetry
|
|
79
|
-
```
|
|
80
|
-
|
|
81
71
|
加载方式:
|
|
82
72
|
|
|
83
73
|
```python
|
|
@@ -108,7 +98,6 @@ nonebot.load_plugin("nonebot_plugin_bugu")
|
|
|
108
98
|
| `BUGU_FONT_INDEX` | `0` | 字体索引(`.ttc` 集合文件用) |
|
|
109
99
|
| `BUGU_BOLD_FONT_PATH` | `(空)` | 粗体字体路径,留空用常规体加描边模拟 |
|
|
110
100
|
| `BUGU_BOLD_FONT_INDEX` | `0` | 粗体字体索引 |
|
|
111
|
-
| `BUGU_COLLECTION_PATH` | `(空)` | 收集进度文件路径,留空用 localstore 的 data 目录 |
|
|
112
101
|
|
|
113
102
|
### 关于字体
|
|
114
103
|
|
|
@@ -136,7 +125,6 @@ nonebot.load_plugin("nonebot_plugin_bugu")
|
|
|
136
125
|
| `/星海查 <物种 / 大类>` | 所有人 | 跨区域搜索 |
|
|
137
126
|
| `/友邻 [名字] [分区]` | 所有人 | 友邻名单 / 档案卡;分区可填 喜爱 / 好感 / 反感 / 关于 / 介绍 |
|
|
138
127
|
| `/鲜花 [品种 / 花名]` | 所有人 | 品种列表 / 培育配方卡 / 单朵花详情 |
|
|
139
|
-
| `/收藏 [名字 / 类型]` | 所有人 | 标记收集进度 |
|
|
140
128
|
| `/布谷刷新` | 超级用户 | 强制刷新四个模块的数据并清空图片缓存 |
|
|
141
129
|
|
|
142
130
|
### 菜谱搜索
|
|
@@ -175,26 +163,6 @@ nonebot.load_plugin("nonebot_plugin_bugu")
|
|
|
175
163
|
/鲜花 黄百合 → 单朵花:品质、颜色、产地、由谁培育、能培育出什么
|
|
176
164
|
```
|
|
177
165
|
|
|
178
|
-
## 收集进度
|
|
179
|
-
|
|
180
|
-
站点自己的「我已获得 / 我已解锁」要邮箱 + 密码登录才能同步。
|
|
181
|
-
**在 bot 里保存用户的站点密码是不合适的**,所以插件做了一份本机进度:
|
|
182
|
-
|
|
183
|
-
- 按 QQ 号分开,存在 `localstore` 的 data 目录(`collection.json`)
|
|
184
|
-
- 三类进度互不影响:星海物种、鲜花、菜谱
|
|
185
|
-
- 标记后,点位卡片 / 鲜花卡片 / 菜谱卡片上会直接出现绿勾或「已解锁」
|
|
186
|
-
- 同名条目跨图鉴时(例如「紫罗兰」既是星海物种又是鲜花)会提示按类型再发一次:
|
|
187
|
-
|
|
188
|
-
```
|
|
189
|
-
/收藏 疆星步甲 → 切换星海物种
|
|
190
|
-
/收藏 鲜花 紫罗兰 → 指明类型
|
|
191
|
-
/收藏 星海 → 每个点位的收集进度
|
|
192
|
-
/收藏 鲜花 / 菜谱 → 分类进度
|
|
193
|
-
/收藏 清空 → 清空自己的进度
|
|
194
|
-
```
|
|
195
|
-
|
|
196
|
-
> 如果以后站点开放了 token 形式的公开进度接口,可以再考虑和站点账号打通。
|
|
197
|
-
|
|
198
166
|
## 数据来源
|
|
199
167
|
|
|
200
168
|
- 站点:<https://bugu.nsun200512.cc>
|
|
@@ -216,11 +184,6 @@ nonebot.load_plugin("nonebot_plugin_bugu")
|
|
|
216
184
|
四个接口都是按需拉取并缓存 6 小时,图片按 URL 缓存 30 天,正常使用打不了几发请求。
|
|
217
185
|
遇到 429 会提示「请求太频繁」,等一会儿再试。
|
|
218
186
|
|
|
219
|
-
**Q:为什么收集进度不能和网页同步?**
|
|
220
|
-
|
|
221
|
-
网页同步依赖账号密码,插件不保存用户密码。需要的只是「我收集了哪些」,
|
|
222
|
-
本机记录已经够用,也不会因为换 bot 环境而泄露账号。
|
|
223
|
-
|
|
224
187
|
## 开发
|
|
225
188
|
|
|
226
189
|
```bash
|
|
@@ -239,7 +202,6 @@ nonebot_plugin_bugu/
|
|
|
239
202
|
├── values.py # 字段兜底与通用小工具
|
|
240
203
|
├── draw.py # 共用绘制:画布、字体、折行、胶囊、页脚
|
|
241
204
|
├── fonts.py # 中文字体探测
|
|
242
|
-
├── collection.py # 收集进度存储(按 QQ 号)
|
|
243
205
|
├── runtime.py # 单例:客户端 / 字体 / 进度
|
|
244
206
|
├── commands.py # 命令注册与分发
|
|
245
207
|
└── features/
|
|
@@ -247,8 +209,7 @@ nonebot_plugin_bugu/
|
|
|
247
209
|
├── starsea/ # data / search / render / reply
|
|
248
210
|
├── recipes/ # data / search / render / reply
|
|
249
211
|
├── neighbors/ # data / render / reply
|
|
250
|
-
|
|
251
|
-
└── collection.py # 收藏命令逻辑
|
|
212
|
+
└── flowers/ # data / render / reply
|
|
252
213
|
```
|
|
253
214
|
|
|
254
215
|
## 许可证
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
# nonebot-plugin-bugu
|
|
2
2
|
|
|
3
|
+
[](https://pypi.org/project/nonebot-plugin-bugu/)
|
|
3
4
|
[](LICENSE)
|
|
4
5
|
[](pyproject.toml)
|
|
5
6
|
[](https://nonebot.dev)
|
|
@@ -12,7 +13,6 @@
|
|
|
12
13
|
| 🗺 **星海地图** | 3 张地图 43 个点位,底图自动编号 + 图例;点位详情是带品质色的图标墙;还能按物种反查「在哪几个岛」 |
|
|
13
14
|
| 🧑🤝🧑 **友邻备忘** | 10 位友邻的立绘、资料、介绍和喜爱 / 好感 / 反感 / 关于词条与友邻能力 |
|
|
14
15
|
| 🌷 **鲜花培育** | 13 个品种 87 种花色的杂交配方表 + 花色图鉴(品质、颜色、产地) |
|
|
15
|
-
| ✅ **收集进度** | 按 QQ 号记录已收集的物种 / 鲜花 / 菜谱,卡片上直接打勾,进度只存在本机 |
|
|
16
16
|
|
|
17
17
|

|
|
18
18
|
|
|
@@ -28,28 +28,18 @@
|
|
|
28
28
|
|
|
29
29
|
需要 Python 3.9+ 和 NoneBot2(OneBot V11 适配器)。
|
|
30
30
|
|
|
31
|
-
### 从源码安装(当前可用)
|
|
32
|
-
|
|
33
31
|
```bash
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
poetry
|
|
32
|
+
nb plugin install nonebot-plugin-bugu # nb-cli
|
|
33
|
+
pip install nonebot-plugin-bugu # pip
|
|
34
|
+
poetry add nonebot-plugin-bugu # poetry
|
|
37
35
|
```
|
|
38
36
|
|
|
39
|
-
|
|
37
|
+
也可以直接从源码装:
|
|
40
38
|
|
|
41
39
|
```bash
|
|
42
40
|
pip install git+https://github.com/TonyLiangP2010405/nonebot-plugin-bugu
|
|
43
41
|
```
|
|
44
42
|
|
|
45
|
-
### 发布到 PyPI 后
|
|
46
|
-
|
|
47
|
-
```bash
|
|
48
|
-
nb plugin install nonebot-plugin-bugu # nb-cli
|
|
49
|
-
pip install nonebot-plugin-bugu # pip
|
|
50
|
-
poetry add nonebot-plugin-bugu # poetry
|
|
51
|
-
```
|
|
52
|
-
|
|
53
43
|
加载方式:
|
|
54
44
|
|
|
55
45
|
```python
|
|
@@ -80,7 +70,6 @@ nonebot.load_plugin("nonebot_plugin_bugu")
|
|
|
80
70
|
| `BUGU_FONT_INDEX` | `0` | 字体索引(`.ttc` 集合文件用) |
|
|
81
71
|
| `BUGU_BOLD_FONT_PATH` | `(空)` | 粗体字体路径,留空用常规体加描边模拟 |
|
|
82
72
|
| `BUGU_BOLD_FONT_INDEX` | `0` | 粗体字体索引 |
|
|
83
|
-
| `BUGU_COLLECTION_PATH` | `(空)` | 收集进度文件路径,留空用 localstore 的 data 目录 |
|
|
84
73
|
|
|
85
74
|
### 关于字体
|
|
86
75
|
|
|
@@ -108,7 +97,6 @@ nonebot.load_plugin("nonebot_plugin_bugu")
|
|
|
108
97
|
| `/星海查 <物种 / 大类>` | 所有人 | 跨区域搜索 |
|
|
109
98
|
| `/友邻 [名字] [分区]` | 所有人 | 友邻名单 / 档案卡;分区可填 喜爱 / 好感 / 反感 / 关于 / 介绍 |
|
|
110
99
|
| `/鲜花 [品种 / 花名]` | 所有人 | 品种列表 / 培育配方卡 / 单朵花详情 |
|
|
111
|
-
| `/收藏 [名字 / 类型]` | 所有人 | 标记收集进度 |
|
|
112
100
|
| `/布谷刷新` | 超级用户 | 强制刷新四个模块的数据并清空图片缓存 |
|
|
113
101
|
|
|
114
102
|
### 菜谱搜索
|
|
@@ -147,26 +135,6 @@ nonebot.load_plugin("nonebot_plugin_bugu")
|
|
|
147
135
|
/鲜花 黄百合 → 单朵花:品质、颜色、产地、由谁培育、能培育出什么
|
|
148
136
|
```
|
|
149
137
|
|
|
150
|
-
## 收集进度
|
|
151
|
-
|
|
152
|
-
站点自己的「我已获得 / 我已解锁」要邮箱 + 密码登录才能同步。
|
|
153
|
-
**在 bot 里保存用户的站点密码是不合适的**,所以插件做了一份本机进度:
|
|
154
|
-
|
|
155
|
-
- 按 QQ 号分开,存在 `localstore` 的 data 目录(`collection.json`)
|
|
156
|
-
- 三类进度互不影响:星海物种、鲜花、菜谱
|
|
157
|
-
- 标记后,点位卡片 / 鲜花卡片 / 菜谱卡片上会直接出现绿勾或「已解锁」
|
|
158
|
-
- 同名条目跨图鉴时(例如「紫罗兰」既是星海物种又是鲜花)会提示按类型再发一次:
|
|
159
|
-
|
|
160
|
-
```
|
|
161
|
-
/收藏 疆星步甲 → 切换星海物种
|
|
162
|
-
/收藏 鲜花 紫罗兰 → 指明类型
|
|
163
|
-
/收藏 星海 → 每个点位的收集进度
|
|
164
|
-
/收藏 鲜花 / 菜谱 → 分类进度
|
|
165
|
-
/收藏 清空 → 清空自己的进度
|
|
166
|
-
```
|
|
167
|
-
|
|
168
|
-
> 如果以后站点开放了 token 形式的公开进度接口,可以再考虑和站点账号打通。
|
|
169
|
-
|
|
170
138
|
## 数据来源
|
|
171
139
|
|
|
172
140
|
- 站点:<https://bugu.nsun200512.cc>
|
|
@@ -188,11 +156,6 @@ nonebot.load_plugin("nonebot_plugin_bugu")
|
|
|
188
156
|
四个接口都是按需拉取并缓存 6 小时,图片按 URL 缓存 30 天,正常使用打不了几发请求。
|
|
189
157
|
遇到 429 会提示「请求太频繁」,等一会儿再试。
|
|
190
158
|
|
|
191
|
-
**Q:为什么收集进度不能和网页同步?**
|
|
192
|
-
|
|
193
|
-
网页同步依赖账号密码,插件不保存用户密码。需要的只是「我收集了哪些」,
|
|
194
|
-
本机记录已经够用,也不会因为换 bot 环境而泄露账号。
|
|
195
|
-
|
|
196
159
|
## 开发
|
|
197
160
|
|
|
198
161
|
```bash
|
|
@@ -211,7 +174,6 @@ nonebot_plugin_bugu/
|
|
|
211
174
|
├── values.py # 字段兜底与通用小工具
|
|
212
175
|
├── draw.py # 共用绘制:画布、字体、折行、胶囊、页脚
|
|
213
176
|
├── fonts.py # 中文字体探测
|
|
214
|
-
├── collection.py # 收集进度存储(按 QQ 号)
|
|
215
177
|
├── runtime.py # 单例:客户端 / 字体 / 进度
|
|
216
178
|
├── commands.py # 命令注册与分发
|
|
217
179
|
└── features/
|
|
@@ -219,8 +181,7 @@ nonebot_plugin_bugu/
|
|
|
219
181
|
├── starsea/ # data / search / render / reply
|
|
220
182
|
├── recipes/ # data / search / render / reply
|
|
221
183
|
├── neighbors/ # data / render / reply
|
|
222
|
-
|
|
223
|
-
└── collection.py # 收藏命令逻辑
|
|
184
|
+
└── flowers/ # data / render / reply
|
|
224
185
|
```
|
|
225
186
|
|
|
226
187
|
## 许可证
|
|
@@ -8,8 +8,8 @@ from .config import Config
|
|
|
8
8
|
__plugin_meta__ = PluginMetadata(
|
|
9
9
|
name="布谷工具箱",
|
|
10
10
|
description=(
|
|
11
|
-
"
|
|
12
|
-
"
|
|
11
|
+
"星布谷地小助手:菜谱查询、星海地图、友邻备忘、鲜花培育。"
|
|
12
|
+
"数据来自布谷工具箱"
|
|
13
13
|
),
|
|
14
14
|
usage=(
|
|
15
15
|
"/布谷 —— 查看全部指令\n"
|
|
@@ -17,7 +17,6 @@ __plugin_meta__ = PluginMetadata(
|
|
|
17
17
|
"/星海 <词> —— 星海智能查询;/星海地图 / /星海点位 / /星海查\n"
|
|
18
18
|
"/友邻 [名字] [喜爱/好感/反感/关于] —— 友邻档案\n"
|
|
19
19
|
"/鲜花 [品种 / 花名] —— 培育配方与花色\n"
|
|
20
|
-
"/收藏 [名字] —— 标记收集进度\n"
|
|
21
20
|
"/布谷刷新 —— 超管:刷新数据并清空图片缓存"
|
|
22
21
|
),
|
|
23
22
|
type="application",
|
|
@@ -16,14 +16,13 @@ from nonebot.params import CommandArg
|
|
|
16
16
|
from nonebot.permission import SUPERUSER
|
|
17
17
|
|
|
18
18
|
from .api import BuguError
|
|
19
|
-
from .features import collection as collection_feature
|
|
20
19
|
from .features.common import Reply, ReplyEnv, command_start
|
|
21
20
|
from .features.flowers import reply as flower_feature
|
|
22
21
|
from .features.neighbors import reply as neighbor_feature
|
|
23
22
|
from .features.recipes import reply as recipe_feature
|
|
24
23
|
from .features.starsea import reply as starsea_feature
|
|
25
24
|
from .fonts import FontError, FontSet
|
|
26
|
-
from .runtime import get_client, get_config, get_fonts
|
|
25
|
+
from .runtime import get_client, get_config, get_fonts
|
|
27
26
|
|
|
28
27
|
PRIORITY = 12
|
|
29
28
|
|
|
@@ -38,7 +37,6 @@ recipe = on_command("菜谱", priority=PRIORITY, block=True)
|
|
|
38
37
|
recipe_search = on_command("菜谱查", aliases={"菜谱搜索"}, priority=PRIORITY, block=True)
|
|
39
38
|
neighbor = on_command("友邻", aliases={"友邻备忘"}, priority=PRIORITY, block=True)
|
|
40
39
|
flower = on_command("鲜花", aliases={"花谱", "鲜花培育"}, priority=PRIORITY, block=True)
|
|
41
|
-
collection = on_command("收藏", aliases={"布谷收藏"}, priority=PRIORITY, block=True)
|
|
42
40
|
refresh = on_command("布谷刷新", priority=PRIORITY, block=True, permission=SUPERUSER)
|
|
43
41
|
|
|
44
42
|
|
|
@@ -66,18 +64,16 @@ class Cooldown:
|
|
|
66
64
|
_cooldown = Cooldown()
|
|
67
65
|
|
|
68
66
|
|
|
69
|
-
def _env(
|
|
67
|
+
def _env() -> ReplyEnv:
|
|
70
68
|
config = get_config()
|
|
71
69
|
client = get_client(config)
|
|
72
|
-
store = get_store(config)
|
|
73
70
|
fonts: Optional[FontSet] = None
|
|
74
71
|
if config.bugu_image_enabled:
|
|
75
72
|
try:
|
|
76
73
|
fonts = get_fonts(config)
|
|
77
74
|
except FontError as exc:
|
|
78
75
|
logger.warning(f"布谷工具箱没有可用字体,改为纯文字:{exc}")
|
|
79
|
-
|
|
80
|
-
return ReplyEnv(client=client, config=config, fonts=fonts, user_id=user_id, store=store)
|
|
76
|
+
return ReplyEnv(client=client, config=config, fonts=fonts)
|
|
81
77
|
|
|
82
78
|
|
|
83
79
|
def _as_segment(reply: Reply):
|
|
@@ -112,11 +108,6 @@ def help_text() -> str:
|
|
|
112
108
|
f" {start}鲜花 品种列表",
|
|
113
109
|
f" {start}鲜花 <品种 / 花名> 杂交配方与花色",
|
|
114
110
|
"",
|
|
115
|
-
"【收集进度】",
|
|
116
|
-
f" {start}收藏 总览",
|
|
117
|
-
f" {start}收藏 <名字> 标记 / 取消",
|
|
118
|
-
f" {start}收藏 星海 / 鲜花 / 菜谱 分类进度",
|
|
119
|
-
"",
|
|
120
111
|
"数据来源:布谷工具箱 bugu.nsun200512.cc",
|
|
121
112
|
]
|
|
122
113
|
)
|
|
@@ -134,12 +125,10 @@ async def _run(
|
|
|
134
125
|
matcher_name: str,
|
|
135
126
|
cooldown: bool = True,
|
|
136
127
|
) -> None:
|
|
137
|
-
env = _env(
|
|
138
|
-
if env.store is not None:
|
|
139
|
-
await env.store.ensure_loaded()
|
|
128
|
+
env = _env()
|
|
140
129
|
|
|
141
130
|
if cooldown and env.config.bugu_cooldown_seconds:
|
|
142
|
-
left = _cooldown.remaining(f"{
|
|
131
|
+
left = _cooldown.remaining(f"{event.get_user_id()}:{matcher_name}", env.config.bugu_cooldown_seconds)
|
|
143
132
|
if left > 0:
|
|
144
133
|
await matcher.finish(f"慢一点,{left:.0f} 秒后再试")
|
|
145
134
|
|
|
@@ -205,11 +194,6 @@ async def _handle_flower(event: MessageEvent, arg: Message = CommandArg()) -> No
|
|
|
205
194
|
await _run(flower, event, arg, flower_feature.reply_flowers, matcher_name="flower")
|
|
206
195
|
|
|
207
196
|
|
|
208
|
-
@collection.handle()
|
|
209
|
-
async def _handle_collection(event: MessageEvent, arg: Message = CommandArg()) -> None:
|
|
210
|
-
await _run(collection, event, arg, collection_feature.reply_collection, matcher_name="collection", cooldown=False)
|
|
211
|
-
|
|
212
|
-
|
|
213
197
|
@refresh.handle()
|
|
214
198
|
async def _handle_refresh() -> None:
|
|
215
199
|
config = get_config()
|
|
@@ -58,10 +58,6 @@ class Config(BaseModel):
|
|
|
58
58
|
default=0,
|
|
59
59
|
description="粗体字体文件内的索引(.ttc 集合文件用)",
|
|
60
60
|
)
|
|
61
|
-
bugu_collection_path: str = Field(
|
|
62
|
-
default="",
|
|
63
|
-
description="收集进度文件路径,留空用 nonebot-plugin-localstore 的 data 目录",
|
|
64
|
-
)
|
|
65
61
|
|
|
66
62
|
@field_validator("bugu_api_base")
|
|
67
63
|
@classmethod
|
|
@@ -38,7 +38,6 @@ BADGE_BLUE = (32, 52, 92)
|
|
|
38
38
|
BADGE_BLUE_LINE = (108, 148, 210)
|
|
39
39
|
TYPE_CHIP_INK = (42, 33, 24)
|
|
40
40
|
SPECIALTY_BLUE = (59, 130, 196)
|
|
41
|
-
GREEN = (76, 175, 98)
|
|
42
41
|
|
|
43
42
|
GRADE_COLORS = {
|
|
44
43
|
"S": (198, 158, 58),
|
|
@@ -314,30 +313,6 @@ def number_badge(
|
|
|
314
313
|
draw.text((cx, cy), str(number), font=font, fill=ink, anchor="mm")
|
|
315
314
|
|
|
316
315
|
|
|
317
|
-
def check_mark(
|
|
318
|
-
draw: ImageDraw.ImageDraw,
|
|
319
|
-
cx: float,
|
|
320
|
-
cy: float,
|
|
321
|
-
radius: int,
|
|
322
|
-
*,
|
|
323
|
-
fill=GREEN,
|
|
324
|
-
outline=(11, 16, 36),
|
|
325
|
-
) -> None:
|
|
326
|
-
"""右上角的绿色对勾(收集进度)。"""
|
|
327
|
-
draw.ellipse(
|
|
328
|
-
[cx - radius, cy - radius, cx + radius, cy + radius],
|
|
329
|
-
fill=fill,
|
|
330
|
-
outline=outline,
|
|
331
|
-
width=2,
|
|
332
|
-
)
|
|
333
|
-
r = radius * 0.5
|
|
334
|
-
draw.line(
|
|
335
|
-
[(cx - r * 0.8, cy + r * 0.1), (cx - r * 0.2, cy + r * 0.7), (cx + r, cy - r * 0.68)],
|
|
336
|
-
fill=(255, 255, 255),
|
|
337
|
-
width=max(2, radius // 5),
|
|
338
|
-
)
|
|
339
|
-
|
|
340
|
-
|
|
341
316
|
def icon_disc(
|
|
342
317
|
canvas: Image.Image,
|
|
343
318
|
draw: ImageDraw.ImageDraw,
|
{nonebot_plugin_bugu-0.2.0 → nonebot_plugin_bugu-0.3.0}/nonebot_plugin_bugu/features/common.py
RENAMED
|
@@ -4,13 +4,12 @@ from __future__ import annotations
|
|
|
4
4
|
|
|
5
5
|
import asyncio
|
|
6
6
|
from dataclasses import dataclass
|
|
7
|
-
from typing import Callable, Optional,
|
|
7
|
+
from typing import Callable, Optional, Union
|
|
8
8
|
|
|
9
9
|
import nonebot
|
|
10
10
|
from nonebot.log import logger
|
|
11
11
|
|
|
12
12
|
from ..api import BuguClient
|
|
13
|
-
from ..collection import KINDS, CollectionStore
|
|
14
13
|
from ..config import Config
|
|
15
14
|
from ..draw import DrawError
|
|
16
15
|
from ..fonts import FontError, FontSet
|
|
@@ -25,36 +24,6 @@ class ReplyEnv:
|
|
|
25
24
|
client: BuguClient
|
|
26
25
|
config: Config
|
|
27
26
|
fonts: Optional[FontSet]
|
|
28
|
-
user_id: str = ""
|
|
29
|
-
store: Optional[CollectionStore] = None
|
|
30
|
-
|
|
31
|
-
def collected(self, kind: str) -> Set[str]:
|
|
32
|
-
"""当前用户某一类的收集集合(没有登录态 / 没存过就是空集)。"""
|
|
33
|
-
if self.store is None or not self.user_id:
|
|
34
|
-
return set()
|
|
35
|
-
return self.store.items(self.user_id, kind)
|
|
36
|
-
|
|
37
|
-
def collected_ids(self, kind: str) -> Set[int]:
|
|
38
|
-
"""星海物种 / 菜谱的 key 是数字,这里直接转好。"""
|
|
39
|
-
out: Set[int] = set()
|
|
40
|
-
for value in self.collected(kind):
|
|
41
|
-
try:
|
|
42
|
-
out.add(int(value))
|
|
43
|
-
except (TypeError, ValueError):
|
|
44
|
-
continue
|
|
45
|
-
return out
|
|
46
|
-
|
|
47
|
-
@property
|
|
48
|
-
def collected_totals(self) -> dict:
|
|
49
|
-
"""各类进度条数(用于「收藏」概览)。"""
|
|
50
|
-
if self.store is None or not self.user_id:
|
|
51
|
-
return {}
|
|
52
|
-
return {kind: len(self.store.items(self.user_id, kind)) for kind in KINDS}
|
|
53
|
-
|
|
54
|
-
def is_collected(self, kind: str, key) -> bool:
|
|
55
|
-
if self.store is None or not self.user_id:
|
|
56
|
-
return False
|
|
57
|
-
return self.store.has(self.user_id, kind, key)
|
|
58
27
|
|
|
59
28
|
@property
|
|
60
29
|
def can_render(self) -> bool:
|
{nonebot_plugin_bugu-0.2.0 → nonebot_plugin_bugu-0.3.0}/nonebot_plugin_bugu/features/flowers/data.py
RENAMED
|
@@ -110,9 +110,6 @@ class FlowerBook:
|
|
|
110
110
|
def is_star_seed(self, species: str) -> bool:
|
|
111
111
|
return self.area_of(species).startswith("星海花种")
|
|
112
112
|
|
|
113
|
-
def collected_names(self, species: str) -> List[str]:
|
|
114
|
-
return [f.name for f in self.flowers_of(species)]
|
|
115
|
-
|
|
116
113
|
|
|
117
114
|
def parse_flowers(payload: Dict[str, Any], base: str) -> FlowerBook:
|
|
118
115
|
if not isinstance(payload, dict):
|
|
@@ -14,7 +14,6 @@ from ...draw import (
|
|
|
14
14
|
YELLOW,
|
|
15
15
|
Draw,
|
|
16
16
|
bold_text,
|
|
17
|
-
check_mark,
|
|
18
17
|
chip,
|
|
19
18
|
finish,
|
|
20
19
|
fit_text,
|
|
@@ -136,8 +135,6 @@ def _draw_tile(
|
|
|
136
135
|
cy: float,
|
|
137
136
|
radius: int,
|
|
138
137
|
fonts: FontSet,
|
|
139
|
-
*,
|
|
140
|
-
done: bool = False,
|
|
141
138
|
) -> None:
|
|
142
139
|
icon = open_image(icon_bytes, "鲜花图标")
|
|
143
140
|
icon_disc(
|
|
@@ -163,9 +160,6 @@ def _draw_tile(
|
|
|
163
160
|
)
|
|
164
161
|
draw.text((bx, by), flower.grade, font=fonts.get(13, True), fill=TYPE_CHIP_INK, anchor="mm")
|
|
165
162
|
|
|
166
|
-
if done:
|
|
167
|
-
check_mark(draw, cx + radius * 0.72, cy - radius * 0.72, 11)
|
|
168
|
-
|
|
169
163
|
font = fonts.get(15)
|
|
170
164
|
for i, line in enumerate(wrap_text(draw, flower.name, font, radius * 3, max_lines=1)):
|
|
171
165
|
draw.text((cx, cy + radius + 8 + i * 19), line, font=font, fill=CREAM, anchor="mt")
|
|
@@ -193,7 +187,6 @@ def render_flower_card(
|
|
|
193
187
|
*,
|
|
194
188
|
fonts: Optional[FontSet] = None,
|
|
195
189
|
width: int = 1040,
|
|
196
|
-
collected: Optional[set] = None,
|
|
197
190
|
) -> bytes:
|
|
198
191
|
require_pillow()
|
|
199
192
|
font_set = resolve_fontset(fonts)
|
|
@@ -288,7 +281,6 @@ def render_flower_card(
|
|
|
288
281
|
cy,
|
|
289
282
|
38,
|
|
290
283
|
font_set,
|
|
291
|
-
done=bool(collected and flower.name in collected),
|
|
292
284
|
)
|
|
293
285
|
|
|
294
286
|
return finish(
|
|
@@ -4,7 +4,6 @@ from __future__ import annotations
|
|
|
4
4
|
|
|
5
5
|
from typing import List
|
|
6
6
|
|
|
7
|
-
from ...collection import KIND_FLOWER
|
|
8
7
|
from ...values import grade_text
|
|
9
8
|
from ..common import Reply, ReplyEnv, render_card, usage
|
|
10
9
|
from .data import Flower, FlowerBook
|
|
@@ -89,7 +88,6 @@ async def _species_reply(book: FlowerBook, species: str, env: ReplyEnv) -> Reply
|
|
|
89
88
|
species,
|
|
90
89
|
{name: fetched.get(url) for name, url in url_map.items()},
|
|
91
90
|
fonts=env.fonts,
|
|
92
|
-
collected=env.collected(KIND_FLOWER) or None,
|
|
93
91
|
label="鲜花培育卡片",
|
|
94
92
|
)
|
|
95
93
|
return png if png is not None else species_text(book, species)
|
|
@@ -19,7 +19,6 @@ from ...draw import (
|
|
|
19
19
|
YELLOW,
|
|
20
20
|
Draw,
|
|
21
21
|
bold_text,
|
|
22
|
-
chip,
|
|
23
22
|
chip_row,
|
|
24
23
|
draw_paragraph,
|
|
25
24
|
finish,
|
|
@@ -142,7 +141,6 @@ def render_recipe_card(
|
|
|
142
141
|
*,
|
|
143
142
|
fonts: Optional[FontSet] = None,
|
|
144
143
|
width: int = 1000,
|
|
145
|
-
unlocked: bool = False,
|
|
146
144
|
) -> bytes:
|
|
147
145
|
require_pillow()
|
|
148
146
|
font_set = resolve_fontset(fonts)
|
|
@@ -183,20 +181,6 @@ def render_recipe_card(
|
|
|
183
181
|
anchor="mm",
|
|
184
182
|
)
|
|
185
183
|
|
|
186
|
-
if unlocked:
|
|
187
|
-
chip(
|
|
188
|
-
draw,
|
|
189
|
-
pad + 12,
|
|
190
|
-
pad + art - 42,
|
|
191
|
-
"已解锁",
|
|
192
|
-
font_set.get(14, True),
|
|
193
|
-
fill=(76, 175, 98),
|
|
194
|
-
ink=(255, 255, 255),
|
|
195
|
-
pad_x=12,
|
|
196
|
-
height=26,
|
|
197
|
-
radius=13,
|
|
198
|
-
)
|
|
199
|
-
|
|
200
184
|
avatar = open_image(images.get(recipe.neighbor.icon) if recipe.neighbor else None, "友邻头像")
|
|
201
185
|
if avatar is not None:
|
|
202
186
|
cx, cy, r = pad + art - 8, pad + art - 8, 26
|
|
@@ -5,7 +5,6 @@ from __future__ import annotations
|
|
|
5
5
|
import random
|
|
6
6
|
from typing import Dict, List, Sequence, Set, Tuple
|
|
7
7
|
|
|
8
|
-
from ...collection import KIND_RECIPE
|
|
9
8
|
from ...values import grade_text
|
|
10
9
|
from ..common import Reply, ReplyEnv, render_card, usage
|
|
11
10
|
from .data import Recipe, RecipeBook
|
|
@@ -161,7 +160,6 @@ async def _recipe_reply(book: RecipeBook, recipe: Recipe, env: ReplyEnv) -> Repl
|
|
|
161
160
|
recipe,
|
|
162
161
|
images,
|
|
163
162
|
fonts=env.fonts,
|
|
164
|
-
unlocked=env.is_collected(KIND_RECIPE, recipe.number),
|
|
165
163
|
label="菜谱卡片",
|
|
166
164
|
)
|
|
167
165
|
return png if png is not None else recipe_text(book, recipe)
|