nonebot-plugin-varolant 1.0.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.
Files changed (30) hide show
  1. nonebot_plugin_varolant-1.0.0/LICENSE +21 -0
  2. nonebot_plugin_varolant-1.0.0/PKG-INFO +256 -0
  3. nonebot_plugin_varolant-1.0.0/README.md +207 -0
  4. nonebot_plugin_varolant-1.0.0/nonebot_plugin_varolant/__init__.py +137 -0
  5. nonebot_plugin_varolant-1.0.0/nonebot_plugin_varolant/config.py +82 -0
  6. nonebot_plugin_varolant-1.0.0/nonebot_plugin_varolant/const.py +106 -0
  7. nonebot_plugin_varolant-1.0.0/nonebot_plugin_varolant/core/database.py +586 -0
  8. nonebot_plugin_varolant-1.0.0/nonebot_plugin_varolant/core/gameinfo.py +234 -0
  9. nonebot_plugin_varolant-1.0.0/nonebot_plugin_varolant/core/monitor.py +146 -0
  10. nonebot_plugin_varolant-1.0.0/nonebot_plugin_varolant/core/mval.py +448 -0
  11. nonebot_plugin_varolant-1.0.0/nonebot_plugin_varolant/core/names.py +219 -0
  12. nonebot_plugin_varolant-1.0.0/nonebot_plugin_varolant/core/qq_login.py +709 -0
  13. nonebot_plugin_varolant-1.0.0/nonebot_plugin_varolant/core/render.py +1916 -0
  14. nonebot_plugin_varolant-1.0.0/nonebot_plugin_varolant/core/store.py +233 -0
  15. nonebot_plugin_varolant-1.0.0/nonebot_plugin_varolant/core/switch.py +73 -0
  16. nonebot_plugin_varolant-1.0.0/nonebot_plugin_varolant/core/wechat_login.py +263 -0
  17. nonebot_plugin_varolant-1.0.0/nonebot_plugin_varolant/core/wegame.py +451 -0
  18. nonebot_plugin_varolant-1.0.0/nonebot_plugin_varolant/core/wegame_login.py +201 -0
  19. nonebot_plugin_varolant-1.0.0/nonebot_plugin_varolant/fontFamily.ttf +0 -0
  20. nonebot_plugin_varolant-1.0.0/nonebot_plugin_varolant/matchers/__init__.py +6 -0
  21. nonebot_plugin_varolant-1.0.0/nonebot_plugin_varolant/matchers/account.py +89 -0
  22. nonebot_plugin_varolant-1.0.0/nonebot_plugin_varolant/matchers/monitor.py +118 -0
  23. nonebot_plugin_varolant-1.0.0/nonebot_plugin_varolant/matchers/shop.py +99 -0
  24. nonebot_plugin_varolant-1.0.0/nonebot_plugin_varolant/matchers/stats.py +623 -0
  25. nonebot_plugin_varolant-1.0.0/nonebot_plugin_varolant/matchers/switch.py +57 -0
  26. nonebot_plugin_varolant-1.0.0/nonebot_plugin_varolant/matchers/val.py +277 -0
  27. nonebot_plugin_varolant-1.0.0/nonebot_plugin_varolant/paths.py +67 -0
  28. nonebot_plugin_varolant-1.0.0/pyproject.toml +64 -0
  29. nonebot_plugin_varolant-1.0.0/tests/test_battle_state.py +198 -0
  30. nonebot_plugin_varolant-1.0.0/tests/test_wegame_auth.py +364 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 val_shop contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,256 @@
1
+ Metadata-Version: 2.1
2
+ Name: nonebot-plugin-varolant
3
+ Version: 1.0.0
4
+ Summary: 面向 QQ 群的 NoneBot2 国服无畏契约助手:每日商店、皮肤监控与战绩卡片
5
+ Keywords: nonebot,nonebot2,onebot,qq,valorant,无畏契约,每日商店
6
+ Author-Email: luoye520ww <100058663+luoye520ww@users.noreply.github.com>
7
+ License: MIT License
8
+
9
+ Copyright (c) 2026 val_shop contributors
10
+
11
+ Permission is hereby granted, free of charge, to any person obtaining a copy
12
+ of this software and associated documentation files (the "Software"), to deal
13
+ in the Software without restriction, including without limitation the rights
14
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15
+ copies of the Software, and to permit persons to whom the Software is
16
+ furnished to do so, subject to the following conditions:
17
+
18
+ The above copyright notice and this permission notice shall be included in all
19
+ copies or substantial portions of the Software.
20
+
21
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27
+ SOFTWARE.
28
+
29
+ Classifier: Development Status :: 5 - Production/Stable
30
+ Classifier: License :: OSI Approved :: MIT License
31
+ Classifier: Operating System :: OS Independent
32
+ Classifier: Programming Language :: Python :: 3
33
+ Classifier: Programming Language :: Python :: 3.10
34
+ Classifier: Programming Language :: Python :: 3.11
35
+ Classifier: Programming Language :: Python :: 3.12
36
+ Classifier: Programming Language :: Python :: 3.13
37
+ Classifier: Topic :: Communications :: Chat
38
+ Project-URL: Homepage, https://github.com/luoye520ww/nonebot-plugin-varolant
39
+ Project-URL: Repository, https://github.com/luoye520ww/nonebot-plugin-varolant
40
+ Project-URL: Issues, https://github.com/luoye520ww/nonebot-plugin-varolant/issues
41
+ Requires-Python: >=3.10
42
+ Requires-Dist: nonebot2[fastapi]>=2.2.0
43
+ Requires-Dist: nonebot-adapter-onebot>=2.4.0
44
+ Requires-Dist: nonebot-plugin-apscheduler>=0.3.0
45
+ Requires-Dist: nonebot-plugin-localstore>=0.7.4
46
+ Requires-Dist: aiohttp>=3.8.0
47
+ Requires-Dist: pillow>=10.0.0
48
+ Description-Content-Type: text/markdown
49
+
50
+ <div align="center">
51
+
52
+ # nonebot-plugin-varolant
53
+
54
+ _面向 QQ 群的 NoneBot2 无畏契约助手_
55
+
56
+ [![PyPI](https://img.shields.io/pypi/v/nonebot-plugin-varolant.svg)](https://pypi.org/project/nonebot-plugin-varolant/)
57
+ [![Python](https://img.shields.io/badge/python-3.10%2B-blue.svg)](https://www.python.org/)
58
+ [![NoneBot2](https://img.shields.io/badge/NoneBot2-2.2.0%2B-d85f5f.svg)](https://nonebot.dev/)
59
+ [![OneBot V11](https://img.shields.io/badge/adapter-OneBot_V11-black.svg)](https://onebot.dev/)
60
+ [![Server](https://img.shields.io/badge/无畏契约-仅支持国服-e44c5c.svg)](#功能)
61
+ [![License](https://img.shields.io/github/license/luoye520ww/nonebot-plugin-varolant.svg)](LICENSE)
62
+
63
+ 每日商店 · 双方 10 人详情 · 武器数据 · 战绩卡片 · QQ 群开关
64
+
65
+ </div>
66
+
67
+ ## 功能
68
+
69
+ `nonebot-plugin-varolant` 是一个适用于 QQ 群和私聊的 NoneBot2 国服无畏契约插件。战绩功能使用 WeGame 微信扫码登录;每日商店使用独立的掌瓦 App 登录,两套登录态互不影响。
70
+
71
+ - `瓦登录` 默认登录 WeGame,获取更完整的国服战绩数据
72
+ - `瓦app登录` 登录掌瓦 App,仅供每日商店与商店监控
73
+ - 每日商店支持一个 QQ 绑定多个游戏账号并随时切换
74
+ - 查询自己或已绑定群友的每日商店
75
+ - 监控指定皮肤,上架后定时私聊提醒
76
+ - 查询近期战绩、当前/最近单场双方 10 人、赛季战报、地图、英雄池、开黑和武器击杀
77
+ - Pillow 绘制中文卡片,使用腾讯资源接口补齐特工头像、地图预览与武器素材,资源获取失败时自动降级
78
+ - 群聊默认关闭,由群主、管理员或超级用户按群启用
79
+
80
+ > [!IMPORTANT]
81
+ > 插件当前仅支持 **国服无畏契约** 与 **OneBot V11**,需要 Python 3.10 及以上版本。群聊默认不响应业务命令,安装后请先由管理员发送 `/s 开启瓦`。
82
+
83
+ ## 效果图
84
+
85
+ <details>
86
+ <summary>查看帮助图</summary>
87
+
88
+ ![帮助图](https://raw.githubusercontent.com/luoye520ww/nonebot-plugin-varolant/main/docs/images/help.jpg)
89
+
90
+ </details>
91
+
92
+ <details>
93
+ <summary>查看双方 10 人单场详情</summary>
94
+
95
+ ![双方 10 人详情](https://raw.githubusercontent.com/luoye520ww/nonebot-plugin-varolant/main/docs/images/battle-detail.jpg)
96
+
97
+ </details>
98
+
99
+ <details>
100
+ <summary>查看武器击杀卡片</summary>
101
+
102
+ ![武器击杀](https://raw.githubusercontent.com/luoye520ww/nonebot-plugin-varolant/main/docs/images/weapons.jpg)
103
+
104
+ </details>
105
+
106
+ <details>
107
+ <summary>查看近期战绩卡片</summary>
108
+
109
+ ![近期战绩](https://raw.githubusercontent.com/luoye520ww/nonebot-plugin-varolant/main/docs/images/stats.jpg)
110
+
111
+ </details>
112
+
113
+ ## 安装
114
+
115
+ ### 使用 nb-cli
116
+
117
+ ```bash
118
+ nb plugin install nonebot-plugin-varolant
119
+ ```
120
+
121
+ ### 使用 pip
122
+
123
+ ```bash
124
+ pip install nonebot-plugin-varolant
125
+ ```
126
+
127
+ 安装后确认宿主项目加载了 `nonebot_plugin_varolant`。使用 nb-cli 安装时会自动写入插件加载配置;手动安装可在宿主项目的 `pyproject.toml` 中加入:
128
+
129
+ ```toml
130
+ [tool.nonebot]
131
+ plugins = ["nonebot_plugin_varolant"]
132
+ ```
133
+
134
+ ### 使用源码
135
+
136
+ ```bash
137
+ git clone https://github.com/luoye520ww/nonebot-plugin-varolant.git
138
+ cd nonebot-plugin-varolant
139
+ pip install -e .
140
+ ```
141
+
142
+ ## 配置
143
+
144
+ 插件无需添加额外 `.env` 配置,安装并加载后即可使用。每日监控时间为北京时间
145
+ `08:01`;时区、通知机器人及登录回调均由插件自动处理。
146
+
147
+ ## 指令
148
+
149
+ 所有“瓦”前缀指令均可将“瓦”替换为“无畏契约”,例如 `无畏契约 战报`。指令无需 `/` 前缀。
150
+
151
+ ### 账号
152
+
153
+ | 指令 | 说明 |
154
+ | --- | --- |
155
+ | `瓦登录` | 使用微信扫码登录 WeGame,供全部战绩功能使用 |
156
+ | `瓦登录 清除` | 仅清除 WeGame 战绩登录态 |
157
+ | `瓦 登录状态` | 查看 WeGame 角色、最近刷新、下次刷新、验活结果和是否需要重新扫码 |
158
+ | `瓦app登录` | 按默认方式登录掌瓦 App,仅供每日商店使用 |
159
+ | `瓦app登录 qq` / `瓦app登录 wx` | 指定 QQ 或微信登录掌瓦 App |
160
+ | `瓦app登录 清除` | 清除全部掌瓦 App 商店账号 |
161
+ | `瓦 账号` | 查看掌瓦 App 每日商店账号列表 |
162
+ | `瓦 切换账号 <序号或昵称>` | 切换每日商店账号 |
163
+ | `瓦 删除账号 <序号或昵称>` | 删除指定每日商店账号 |
164
+ | `瓦 帮助` / `瓦登录 帮助` | 查看完整帮助图 |
165
+
166
+ ### 每日商店与监控
167
+
168
+ | 指令 | 说明 |
169
+ | --- | --- |
170
+ | `每日商店` | 查看自己的今日商店 |
171
+ | `每日商店 @某人` | 查看已绑定群友的今日商店 |
172
+ | `商店监控 添加 "皮肤 武器"` | 添加监控项 |
173
+ | `商店监控 删除 "皮肤 武器"` | 删除监控项 |
174
+ | `商店监控 列表` | 查看全部监控项 |
175
+ | `商店监控 查询` | 立即查询一次 |
176
+ | `商店监控 开启` / `商店监控 关闭` | 开关每日自动监控 |
177
+
178
+ ### 战绩
179
+
180
+ | 指令 | 说明 |
181
+ | --- | --- |
182
+ | `瓦 查战绩` / `瓦 战绩` | 查看自己的近期战绩 |
183
+ | `瓦 查战绩 <昵称#ID>` | 从本人近期 10 局双方名单定位;完整历史受限时展示可访问的共同对局 |
184
+ | `瓦 队友` / `瓦 队友战绩` | 优先获取当前对局,展示双方 10 人、逐回合结果、换边、对局时间与单场数据;未识别到则展示最近一局 |
185
+ | `瓦 战报` | 当前赛季 KDA、胜率、ACS、KAST 和常用特工 |
186
+ | `瓦 地图` | 近期 50 场地图胜率、KDA、ACS 和常用特工 |
187
+ | `瓦 英雄池` / `瓦 英雄` | 近期 50 场特工聚合 TOP8 |
188
+ | `瓦 开黑` | 近期组队队友排行 |
189
+ | `瓦 击杀` | 总赛季各武器击杀、场均击杀、爆头率、最远击杀与总伤害 |
190
+
191
+ ### QQ 群开关
192
+
193
+ 以下指令仅限群主、群管理员或 NoneBot 超级用户:
194
+
195
+ | 指令 | 说明 |
196
+ | --- | --- |
197
+ | `/s 开启瓦` | 在当前群启用插件 |
198
+ | `/s 关闭瓦` | 在当前群停用插件 |
199
+ | `/s 瓦` | 查看当前群开关状态 |
200
+
201
+ `开启/关闭` 也可写作 `启用/停用/on/off`,插件名也可写作 `无畏契约/valorant/val`。私聊始终可用。
202
+
203
+ 插件的交互消息均会引用回复触发该指令的消息,便于在群聊中对应查询结果。
204
+
205
+ ## 数据与隐私
206
+
207
+ - 账号数据通过 `nonebot-plugin-localstore` 保存在插件数据目录,写入时使用临时文件原子替换。
208
+ - 群白名单保存在同一插件数据目录的 `switch.json`。
209
+ - 二维码、特工头像、地图预览和武器素材保存在插件缓存目录,可在机器人停止后清理并自动重建。
210
+ - WeGame 登录态仅用于战绩接口;掌瓦 App 登录态仅用于每日商店接口。
211
+ - WeGame 登录会保存腾讯登录响应中的刷新周期,业务请求会按周期预刷新,后台每 5 分钟扫描到期账号;并发查询只执行一次票据轮换,新票据验活成功后才写入。
212
+ - 掌瓦 App 与 WeGame 使用独立认证状态;掌瓦登录回包含刷新凭证时,插件会依次刷新商店票据、临时票据和第三方令牌,再以每日商店接口验活。
213
+ - 自动续期受腾讯上游凭证总有效期限制。机器人连续离线超过有效期或上游主动撤销登录后,需要重新扫码。
214
+ - 插件不会在日志中输出 access token、tgp_ticket 或登录回调参数。
215
+ - 战绩登录失效后重新发送 `瓦登录`;每日商店登录失效后重新发送 `瓦app登录`。
216
+
217
+ > [!NOTE]
218
+ > WeGame 战绩接口使用内部 Subject 查询玩家,当前未发现官方公开的“昵称#ID → Subject”接口。因此“查别人战绩”会从本人近期 10 局的双方名单定位;`瓦队友` 的当前对局识别属于实战探测路径,开局数据是否即时同步需要以机器人实际回包为准。
219
+
220
+ ## 常见问题
221
+
222
+ ### 群里发送指令没有反应
223
+
224
+ 群聊默认关闭。请确认群主、管理员或超级用户已经发送 `/s 开启瓦`,并确认 OneBot V11 协议端与机器人连接正常。
225
+
226
+ ### 每日监控没有推送
227
+
228
+ 确认已经添加监控项并发送 `商店监控 开启`。插件会自动选择当前在线机器人发送私聊通知。
229
+
230
+ ### 图片中的官方素材没有显示
231
+
232
+ 插件会从腾讯静态资源地址获取特工头像、武器图标和地图预览图。网络不可用时会自动使用色块兜底,不影响指令主体功能。
233
+
234
+ ## 更新说明
235
+
236
+ ### v1.0.0
237
+
238
+ 首个公开发行版本:
239
+
240
+ - WeGame 微信扫码登录;掌瓦 App 商店登录与多账号管理
241
+ - 每日商店查询和皮肤上架监控
242
+ - 近期战绩、双方 10 人单场详情、战报、地图、英雄池、开黑和武器击杀卡片
243
+ - QQ 群白名单开关及管理权限检查
244
+ - 完整中文帮助图、配置模板和 NoneBot2 插件元数据
245
+
246
+ ## 免责声明
247
+
248
+ 本项目为非官方社区工具,与 Riot Games、腾讯、WeGame 无从属或合作关系。
249
+
250
+ 项目仅用于学习、研究和个人数据展示。请遵守游戏、平台和相关服务条款,不要用于骚扰、作弊、绕过访问控制或侵犯他人隐私。
251
+
252
+ 本项目只展示官方接口返回的公开资料和公开 IP 属地,不提取、不展示玩家真实 IP。
253
+
254
+ ## License
255
+
256
+ 本项目使用 [MIT License](LICENSE) 开源。
@@ -0,0 +1,207 @@
1
+ <div align="center">
2
+
3
+ # nonebot-plugin-varolant
4
+
5
+ _面向 QQ 群的 NoneBot2 无畏契约助手_
6
+
7
+ [![PyPI](https://img.shields.io/pypi/v/nonebot-plugin-varolant.svg)](https://pypi.org/project/nonebot-plugin-varolant/)
8
+ [![Python](https://img.shields.io/badge/python-3.10%2B-blue.svg)](https://www.python.org/)
9
+ [![NoneBot2](https://img.shields.io/badge/NoneBot2-2.2.0%2B-d85f5f.svg)](https://nonebot.dev/)
10
+ [![OneBot V11](https://img.shields.io/badge/adapter-OneBot_V11-black.svg)](https://onebot.dev/)
11
+ [![Server](https://img.shields.io/badge/无畏契约-仅支持国服-e44c5c.svg)](#功能)
12
+ [![License](https://img.shields.io/github/license/luoye520ww/nonebot-plugin-varolant.svg)](LICENSE)
13
+
14
+ 每日商店 · 双方 10 人详情 · 武器数据 · 战绩卡片 · QQ 群开关
15
+
16
+ </div>
17
+
18
+ ## 功能
19
+
20
+ `nonebot-plugin-varolant` 是一个适用于 QQ 群和私聊的 NoneBot2 国服无畏契约插件。战绩功能使用 WeGame 微信扫码登录;每日商店使用独立的掌瓦 App 登录,两套登录态互不影响。
21
+
22
+ - `瓦登录` 默认登录 WeGame,获取更完整的国服战绩数据
23
+ - `瓦app登录` 登录掌瓦 App,仅供每日商店与商店监控
24
+ - 每日商店支持一个 QQ 绑定多个游戏账号并随时切换
25
+ - 查询自己或已绑定群友的每日商店
26
+ - 监控指定皮肤,上架后定时私聊提醒
27
+ - 查询近期战绩、当前/最近单场双方 10 人、赛季战报、地图、英雄池、开黑和武器击杀
28
+ - Pillow 绘制中文卡片,使用腾讯资源接口补齐特工头像、地图预览与武器素材,资源获取失败时自动降级
29
+ - 群聊默认关闭,由群主、管理员或超级用户按群启用
30
+
31
+ > [!IMPORTANT]
32
+ > 插件当前仅支持 **国服无畏契约** 与 **OneBot V11**,需要 Python 3.10 及以上版本。群聊默认不响应业务命令,安装后请先由管理员发送 `/s 开启瓦`。
33
+
34
+ ## 效果图
35
+
36
+ <details>
37
+ <summary>查看帮助图</summary>
38
+
39
+ ![帮助图](https://raw.githubusercontent.com/luoye520ww/nonebot-plugin-varolant/main/docs/images/help.jpg)
40
+
41
+ </details>
42
+
43
+ <details>
44
+ <summary>查看双方 10 人单场详情</summary>
45
+
46
+ ![双方 10 人详情](https://raw.githubusercontent.com/luoye520ww/nonebot-plugin-varolant/main/docs/images/battle-detail.jpg)
47
+
48
+ </details>
49
+
50
+ <details>
51
+ <summary>查看武器击杀卡片</summary>
52
+
53
+ ![武器击杀](https://raw.githubusercontent.com/luoye520ww/nonebot-plugin-varolant/main/docs/images/weapons.jpg)
54
+
55
+ </details>
56
+
57
+ <details>
58
+ <summary>查看近期战绩卡片</summary>
59
+
60
+ ![近期战绩](https://raw.githubusercontent.com/luoye520ww/nonebot-plugin-varolant/main/docs/images/stats.jpg)
61
+
62
+ </details>
63
+
64
+ ## 安装
65
+
66
+ ### 使用 nb-cli
67
+
68
+ ```bash
69
+ nb plugin install nonebot-plugin-varolant
70
+ ```
71
+
72
+ ### 使用 pip
73
+
74
+ ```bash
75
+ pip install nonebot-plugin-varolant
76
+ ```
77
+
78
+ 安装后确认宿主项目加载了 `nonebot_plugin_varolant`。使用 nb-cli 安装时会自动写入插件加载配置;手动安装可在宿主项目的 `pyproject.toml` 中加入:
79
+
80
+ ```toml
81
+ [tool.nonebot]
82
+ plugins = ["nonebot_plugin_varolant"]
83
+ ```
84
+
85
+ ### 使用源码
86
+
87
+ ```bash
88
+ git clone https://github.com/luoye520ww/nonebot-plugin-varolant.git
89
+ cd nonebot-plugin-varolant
90
+ pip install -e .
91
+ ```
92
+
93
+ ## 配置
94
+
95
+ 插件无需添加额外 `.env` 配置,安装并加载后即可使用。每日监控时间为北京时间
96
+ `08:01`;时区、通知机器人及登录回调均由插件自动处理。
97
+
98
+ ## 指令
99
+
100
+ 所有“瓦”前缀指令均可将“瓦”替换为“无畏契约”,例如 `无畏契约 战报`。指令无需 `/` 前缀。
101
+
102
+ ### 账号
103
+
104
+ | 指令 | 说明 |
105
+ | --- | --- |
106
+ | `瓦登录` | 使用微信扫码登录 WeGame,供全部战绩功能使用 |
107
+ | `瓦登录 清除` | 仅清除 WeGame 战绩登录态 |
108
+ | `瓦 登录状态` | 查看 WeGame 角色、最近刷新、下次刷新、验活结果和是否需要重新扫码 |
109
+ | `瓦app登录` | 按默认方式登录掌瓦 App,仅供每日商店使用 |
110
+ | `瓦app登录 qq` / `瓦app登录 wx` | 指定 QQ 或微信登录掌瓦 App |
111
+ | `瓦app登录 清除` | 清除全部掌瓦 App 商店账号 |
112
+ | `瓦 账号` | 查看掌瓦 App 每日商店账号列表 |
113
+ | `瓦 切换账号 <序号或昵称>` | 切换每日商店账号 |
114
+ | `瓦 删除账号 <序号或昵称>` | 删除指定每日商店账号 |
115
+ | `瓦 帮助` / `瓦登录 帮助` | 查看完整帮助图 |
116
+
117
+ ### 每日商店与监控
118
+
119
+ | 指令 | 说明 |
120
+ | --- | --- |
121
+ | `每日商店` | 查看自己的今日商店 |
122
+ | `每日商店 @某人` | 查看已绑定群友的今日商店 |
123
+ | `商店监控 添加 "皮肤 武器"` | 添加监控项 |
124
+ | `商店监控 删除 "皮肤 武器"` | 删除监控项 |
125
+ | `商店监控 列表` | 查看全部监控项 |
126
+ | `商店监控 查询` | 立即查询一次 |
127
+ | `商店监控 开启` / `商店监控 关闭` | 开关每日自动监控 |
128
+
129
+ ### 战绩
130
+
131
+ | 指令 | 说明 |
132
+ | --- | --- |
133
+ | `瓦 查战绩` / `瓦 战绩` | 查看自己的近期战绩 |
134
+ | `瓦 查战绩 <昵称#ID>` | 从本人近期 10 局双方名单定位;完整历史受限时展示可访问的共同对局 |
135
+ | `瓦 队友` / `瓦 队友战绩` | 优先获取当前对局,展示双方 10 人、逐回合结果、换边、对局时间与单场数据;未识别到则展示最近一局 |
136
+ | `瓦 战报` | 当前赛季 KDA、胜率、ACS、KAST 和常用特工 |
137
+ | `瓦 地图` | 近期 50 场地图胜率、KDA、ACS 和常用特工 |
138
+ | `瓦 英雄池` / `瓦 英雄` | 近期 50 场特工聚合 TOP8 |
139
+ | `瓦 开黑` | 近期组队队友排行 |
140
+ | `瓦 击杀` | 总赛季各武器击杀、场均击杀、爆头率、最远击杀与总伤害 |
141
+
142
+ ### QQ 群开关
143
+
144
+ 以下指令仅限群主、群管理员或 NoneBot 超级用户:
145
+
146
+ | 指令 | 说明 |
147
+ | --- | --- |
148
+ | `/s 开启瓦` | 在当前群启用插件 |
149
+ | `/s 关闭瓦` | 在当前群停用插件 |
150
+ | `/s 瓦` | 查看当前群开关状态 |
151
+
152
+ `开启/关闭` 也可写作 `启用/停用/on/off`,插件名也可写作 `无畏契约/valorant/val`。私聊始终可用。
153
+
154
+ 插件的交互消息均会引用回复触发该指令的消息,便于在群聊中对应查询结果。
155
+
156
+ ## 数据与隐私
157
+
158
+ - 账号数据通过 `nonebot-plugin-localstore` 保存在插件数据目录,写入时使用临时文件原子替换。
159
+ - 群白名单保存在同一插件数据目录的 `switch.json`。
160
+ - 二维码、特工头像、地图预览和武器素材保存在插件缓存目录,可在机器人停止后清理并自动重建。
161
+ - WeGame 登录态仅用于战绩接口;掌瓦 App 登录态仅用于每日商店接口。
162
+ - WeGame 登录会保存腾讯登录响应中的刷新周期,业务请求会按周期预刷新,后台每 5 分钟扫描到期账号;并发查询只执行一次票据轮换,新票据验活成功后才写入。
163
+ - 掌瓦 App 与 WeGame 使用独立认证状态;掌瓦登录回包含刷新凭证时,插件会依次刷新商店票据、临时票据和第三方令牌,再以每日商店接口验活。
164
+ - 自动续期受腾讯上游凭证总有效期限制。机器人连续离线超过有效期或上游主动撤销登录后,需要重新扫码。
165
+ - 插件不会在日志中输出 access token、tgp_ticket 或登录回调参数。
166
+ - 战绩登录失效后重新发送 `瓦登录`;每日商店登录失效后重新发送 `瓦app登录`。
167
+
168
+ > [!NOTE]
169
+ > WeGame 战绩接口使用内部 Subject 查询玩家,当前未发现官方公开的“昵称#ID → Subject”接口。因此“查别人战绩”会从本人近期 10 局的双方名单定位;`瓦队友` 的当前对局识别属于实战探测路径,开局数据是否即时同步需要以机器人实际回包为准。
170
+
171
+ ## 常见问题
172
+
173
+ ### 群里发送指令没有反应
174
+
175
+ 群聊默认关闭。请确认群主、管理员或超级用户已经发送 `/s 开启瓦`,并确认 OneBot V11 协议端与机器人连接正常。
176
+
177
+ ### 每日监控没有推送
178
+
179
+ 确认已经添加监控项并发送 `商店监控 开启`。插件会自动选择当前在线机器人发送私聊通知。
180
+
181
+ ### 图片中的官方素材没有显示
182
+
183
+ 插件会从腾讯静态资源地址获取特工头像、武器图标和地图预览图。网络不可用时会自动使用色块兜底,不影响指令主体功能。
184
+
185
+ ## 更新说明
186
+
187
+ ### v1.0.0
188
+
189
+ 首个公开发行版本:
190
+
191
+ - WeGame 微信扫码登录;掌瓦 App 商店登录与多账号管理
192
+ - 每日商店查询和皮肤上架监控
193
+ - 近期战绩、双方 10 人单场详情、战报、地图、英雄池、开黑和武器击杀卡片
194
+ - QQ 群白名单开关及管理权限检查
195
+ - 完整中文帮助图、配置模板和 NoneBot2 插件元数据
196
+
197
+ ## 免责声明
198
+
199
+ 本项目为非官方社区工具,与 Riot Games、腾讯、WeGame 无从属或合作关系。
200
+
201
+ 项目仅用于学习、研究和个人数据展示。请遵守游戏、平台和相关服务条款,不要用于骚扰、作弊、绕过访问控制或侵犯他人隐私。
202
+
203
+ 本项目只展示官方接口返回的公开资料和公开 IP 属地,不提取、不展示玩家真实 IP。
204
+
205
+ ## License
206
+
207
+ 本项目使用 [MIT License](LICENSE) 开源。
@@ -0,0 +1,137 @@
1
+ import asyncio
2
+
3
+ from nonebot import get_driver, get_plugin_config, require
4
+ from nonebot.log import logger
5
+ from nonebot.plugin import PluginMetadata
6
+
7
+ from .config import Config
8
+
9
+ __plugin_meta__ = PluginMetadata(
10
+ name="无畏契约助手",
11
+ description="面向 QQ 群的国服无畏契约每日商店、皮肤监控与战绩卡片插件",
12
+ usage="发送「瓦 帮助」查看完整指令图",
13
+ type="application",
14
+ homepage="https://github.com/luoye520ww/nonebot-plugin-varolant",
15
+ config=Config,
16
+ supported_adapters={"~onebot.v11"},
17
+ )
18
+
19
+ require("nonebot_plugin_apscheduler")
20
+
21
+ from nonebot_plugin_apscheduler import scheduler # noqa: E402
22
+
23
+ from .core import database, monitor, mval, wegame # noqa: E402
24
+
25
+ plugin_config = get_plugin_config(Config)
26
+
27
+ _MONITOR_JOB_ID = "varolant_daily_monitor"
28
+ _WEGAME_REFRESH_JOB_ID = "varolant_wegame_refresh"
29
+ _APP_REFRESH_JOB_ID = "varolant_app_refresh"
30
+
31
+
32
+ async def _refresh_wegame_sessions() -> None:
33
+ refreshed = 0
34
+ for user_id, cfg in await database.list_wegame_configs(due_only=True):
35
+ async def save(updated: dict, uid: str = user_id) -> bool:
36
+ return await database.save_wegame_config(uid, updated)
37
+
38
+ client = wegame.get_client(cfg, save, user_id)
39
+ try:
40
+ if await client.refresh_ticket():
41
+ refreshed += 1
42
+ except Exception as e:
43
+ logger.warning(f"WeGame 登录态保活失败: {type(e).__name__}: {e}")
44
+ finally:
45
+ await client.close()
46
+ if refreshed:
47
+ logger.debug(f"WeGame 登录态保活完成: {refreshed} 个账号")
48
+
49
+
50
+ async def _refresh_app_sessions() -> None:
51
+ refreshed = 0
52
+ for user_id, cfg in await database.list_app_configs(due_only=True):
53
+ try:
54
+ if await mval.refresh_app_account(user_id, cfg):
55
+ refreshed += 1
56
+ except Exception as e:
57
+ logger.warning(f"掌瓦 App 登录态保活失败: {type(e).__name__}: {e}")
58
+ if refreshed:
59
+ logger.debug(f"掌瓦 App 登录态保活完成: {refreshed} 个账号")
60
+
61
+
62
+ def _setup_scheduler() -> None:
63
+ """按配置把每日监控挂到 apscheduler。"""
64
+ hour, minute = 8, 1
65
+ try:
66
+ hour_s, minute_s = str(plugin_config.monitor_time or "08:01").split(":", 1)
67
+ hour, minute = int(hour_s), int(minute_s)
68
+ if not (0 <= hour <= 23 and 0 <= minute <= 59):
69
+ raise ValueError
70
+ except (ValueError, AttributeError):
71
+ logger.warning(
72
+ f"monitor_time 配置无效: {plugin_config.monitor_time},回退为 08:01"
73
+ )
74
+ hour, minute = 8, 1
75
+ plugin_config.monitor_time = "08:01"
76
+
77
+ from apscheduler.triggers.cron import CronTrigger
78
+
79
+ tz_name = plugin_config.timezone or "Asia/Shanghai"
80
+ try:
81
+ trigger = CronTrigger(hour=hour, minute=minute, timezone=tz_name)
82
+ except Exception:
83
+ logger.warning(f"timezone 配置无效: {tz_name},回退为 Asia/Shanghai")
84
+ tz_name = "Asia/Shanghai"
85
+ plugin_config.timezone = tz_name
86
+ trigger = CronTrigger(hour=hour, minute=minute, timezone="Asia/Shanghai")
87
+
88
+ scheduler.add_job(
89
+ monitor.daily_auto_check,
90
+ trigger=trigger,
91
+ args=[plugin_config],
92
+ id=_MONITOR_JOB_ID,
93
+ replace_existing=True,
94
+ misfire_grace_time=300,
95
+ )
96
+ scheduler.add_job(
97
+ _refresh_wegame_sessions,
98
+ "interval",
99
+ minutes=5,
100
+ id=_WEGAME_REFRESH_JOB_ID,
101
+ replace_existing=True,
102
+ coalesce=True,
103
+ max_instances=1,
104
+ )
105
+ scheduler.add_job(
106
+ _refresh_app_sessions,
107
+ "interval",
108
+ minutes=5,
109
+ id=_APP_REFRESH_JOB_ID,
110
+ replace_existing=True,
111
+ coalesce=True,
112
+ max_instances=1,
113
+ )
114
+ logger.info(f"每日商店监控任务已注册: 每天 {hour:02d}:{minute:02d} ({tz_name})")
115
+
116
+ driver = get_driver()
117
+
118
+
119
+ @driver.on_startup
120
+ async def _on_startup():
121
+ await database.init_db()
122
+ _setup_scheduler()
123
+ asyncio.create_task(_refresh_wegame_sessions())
124
+ asyncio.create_task(_refresh_app_sessions())
125
+
126
+
127
+ @driver.on_shutdown
128
+ async def _on_shutdown():
129
+ if scheduler.get_job(_MONITOR_JOB_ID):
130
+ scheduler.remove_job(_MONITOR_JOB_ID)
131
+ if scheduler.get_job(_WEGAME_REFRESH_JOB_ID):
132
+ scheduler.remove_job(_WEGAME_REFRESH_JOB_ID)
133
+ if scheduler.get_job(_APP_REFRESH_JOB_ID):
134
+ scheduler.remove_job(_APP_REFRESH_JOB_ID)
135
+ await mval.close_all()
136
+
137
+ from . import matchers # noqa: E402,F401 导入即注册所有命令