nonebot-plugin-group-market 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.
Files changed (49) hide show
  1. nonebot_plugin_group_market-0.3.0/LICENSE +43 -0
  2. nonebot_plugin_group_market-0.3.0/PKG-INFO +216 -0
  3. nonebot_plugin_group_market-0.3.0/README.md +185 -0
  4. nonebot_plugin_group_market-0.3.0/nonebot_plugin_group_market/__init__.py +43 -0
  5. nonebot_plugin_group_market-0.3.0/nonebot_plugin_group_market/commands.py +39 -0
  6. nonebot_plugin_group_market-0.3.0/nonebot_plugin_group_market/commands_achievement.py +137 -0
  7. nonebot_plugin_group_market-0.3.0/nonebot_plugin_group_market/commands_admin.py +146 -0
  8. nonebot_plugin_group_market-0.3.0/nonebot_plugin_group_market/commands_arena.py +143 -0
  9. nonebot_plugin_group_market-0.3.0/nonebot_plugin_group_market/commands_bank.py +319 -0
  10. nonebot_plugin_group_market-0.3.0/nonebot_plugin_group_market/commands_bounty.py +260 -0
  11. nonebot_plugin_group_market-0.3.0/nonebot_plugin_group_market/commands_buyback.py +92 -0
  12. nonebot_plugin_group_market-0.3.0/nonebot_plugin_group_market/commands_dailytask.py +154 -0
  13. nonebot_plugin_group_market-0.3.0/nonebot_plugin_group_market/commands_help.py +83 -0
  14. nonebot_plugin_group_market-0.3.0/nonebot_plugin_group_market/commands_level.py +87 -0
  15. nonebot_plugin_group_market-0.3.0/nonebot_plugin_group_market/commands_profile.py +134 -0
  16. nonebot_plugin_group_market-0.3.0/nonebot_plugin_group_market/commands_purchase.py +115 -0
  17. nonebot_plugin_group_market-0.3.0/nonebot_plugin_group_market/commands_randomevent.py +61 -0
  18. nonebot_plugin_group_market-0.3.0/nonebot_plugin_group_market/commands_ranking.py +186 -0
  19. nonebot_plugin_group_market-0.3.0/nonebot_plugin_group_market/commands_rankings.py +56 -0
  20. nonebot_plugin_group_market-0.3.0/nonebot_plugin_group_market/commands_rob.py +88 -0
  21. nonebot_plugin_group_market-0.3.0/nonebot_plugin_group_market/commands_season.py +184 -0
  22. nonebot_plugin_group_market-0.3.0/nonebot_plugin_group_market/commands_shop.py +270 -0
  23. nonebot_plugin_group_market-0.3.0/nonebot_plugin_group_market/commands_signin.py +124 -0
  24. nonebot_plugin_group_market-0.3.0/nonebot_plugin_group_market/commands_slave.py +102 -0
  25. nonebot_plugin_group_market-0.3.0/nonebot_plugin_group_market/commands_title.py +128 -0
  26. nonebot_plugin_group_market-0.3.0/nonebot_plugin_group_market/commands_train.py +134 -0
  27. nonebot_plugin_group_market-0.3.0/nonebot_plugin_group_market/commands_update.py +17 -0
  28. nonebot_plugin_group_market-0.3.0/nonebot_plugin_group_market/commands_weekly.py +128 -0
  29. nonebot_plugin_group_market-0.3.0/nonebot_plugin_group_market/commands_work.py +98 -0
  30. nonebot_plugin_group_market-0.3.0/nonebot_plugin_group_market/config.py +105 -0
  31. nonebot_plugin_group_market-0.3.0/nonebot_plugin_group_market/exit_handler.py +27 -0
  32. nonebot_plugin_group_market-0.3.0/nonebot_plugin_group_market/extension/__init__.py +6 -0
  33. nonebot_plugin_group_market-0.3.0/nonebot_plugin_group_market/extension/anti_spam.py +367 -0
  34. nonebot_plugin_group_market-0.3.0/nonebot_plugin_group_market/extension/config.py +142 -0
  35. nonebot_plugin_group_market-0.3.0/nonebot_plugin_group_market/extension/group_storage.py +167 -0
  36. nonebot_plugin_group_market-0.3.0/nonebot_plugin_group_market/extension/utils.py +254 -0
  37. nonebot_plugin_group_market-0.3.0/nonebot_plugin_group_market/models.py +69 -0
  38. nonebot_plugin_group_market-0.3.0/nonebot_plugin_group_market/storage.py +299 -0
  39. nonebot_plugin_group_market-0.3.0/nonebot_plugin_group_market/utils.py +39 -0
  40. nonebot_plugin_group_market-0.3.0/nonebot_plugin_group_market/weekly_reset_task.py +175 -0
  41. nonebot_plugin_group_market-0.3.0/nonebot_plugin_group_market.egg-info/PKG-INFO +216 -0
  42. nonebot_plugin_group_market-0.3.0/nonebot_plugin_group_market.egg-info/SOURCES.txt +47 -0
  43. nonebot_plugin_group_market-0.3.0/nonebot_plugin_group_market.egg-info/dependency_links.txt +1 -0
  44. nonebot_plugin_group_market-0.3.0/nonebot_plugin_group_market.egg-info/entry_points.txt +2 -0
  45. nonebot_plugin_group_market-0.3.0/nonebot_plugin_group_market.egg-info/requires.txt +9 -0
  46. nonebot_plugin_group_market-0.3.0/nonebot_plugin_group_market.egg-info/top_level.txt +1 -0
  47. nonebot_plugin_group_market-0.3.0/pyproject.toml +50 -0
  48. nonebot_plugin_group_market-0.3.0/setup.cfg +4 -0
  49. nonebot_plugin_group_market-0.3.0/tests/test_import.py +40 -0
@@ -0,0 +1,43 @@
1
+ 木兰宽松许可证,第2版
2
+
3
+ 木兰宽松许可证,第2版
4
+
5
+ 2025 https://github.com/TonyLiangP2010405/nonebot-plugin-slave-market
6
+
7
+ 您对“软件”的复制、使用、修改及分发受木兰宽松许可证,第2版(“本许可证”)的如下条款的约束:
8
+
9
+ 0. 定义
10
+
11
+ “软件”是指由“贡献”构成的许可在“本许可证”下的程序和相关文档的集合。
12
+
13
+ “贡献”是指由任一“贡献者”许可在“本许可证”下的受版权法保护的作品。
14
+
15
+ “贡献者”是指将受版权法保护的作品许可在“本许可证”下的自然人或“法人实体”。
16
+
17
+ “法人实体”是指提交贡献的机构以及由该机构控制、受该机构控制或与之共同控制的机构,此定义中的“控制”是指:(i) 通过合同或其他方式,直接或间接地指导或管理该实体的权力,或 (ii) 拥有该实体百分之五十(50%)或以上已发行股份的权力,或 (iii) 拥有该实体的实益所有权。
18
+
19
+ “对应源代码”是指生成、安装和(对于可执行作品)运行目标代码的所有源代码,包括修改该软件所需的脚本,但不包括该软件作为单独作品分发的任何源代码或库、该软件作为编译环境的一部分使用的任何源代码或库,或该软件使用的操作系统或虚拟机。
20
+
21
+ 1. 授予版权许可
22
+
23
+ 每个贡献者根据本许可证的条款,授予您永久性的、全球性的、免费的、非独占的、不可撤销的版权许可,以复制、使用、修改、分发其贡献,无论是修改或未修改的,无论是源代码形式还是目标代码形式。
24
+
25
+ 2. 授予专利许可
26
+
27
+ 每个贡献者根据本许可证的条款,授予您永久性的、全球性的、免费的、非独占的、不可撤销的(根据本条规定撤销除外)专利许可,以制作、让其制作、使用、销售、许诺销售、进口和以其他方式转移其贡献,该许可仅适用于该贡献者可授权的那些专利权利要求,且仅因该贡献者单独或联合其贡献而导致该贡献者或其贡献被许可的软件被指控侵权。如果您对任何实体提起专利诉讼(包括诉讼中的交叉索赔或反诉),主张该软件本身(不包括您可能添加的任何代码)侵犯了专利,则本许可证授予您的与该软件相关的任何专利许可自您提起该诉讼之日起终止。
28
+
29
+ 3. 无商标许可
30
+
31
+ 本许可证不授予您使用任何贡献者的商品名称、商标、服务标记或产品名称的权利,但您在使用该贡献者的贡献时必须遵守适用法律关于归属的要求。
32
+
33
+ 4. 免责声明
34
+
35
+ 在适用法律允许的最大范围内,本软件按“原样”提供,无任何明示或暗示的保证,包括但不限于对适销性、特定用途适用性或不侵权的保证。在任何情况下,任何贡献者或版权持有者均不对因使用本软件而产生的任何索赔、损害或其他责任负责,无论是在合同诉讼、侵权诉讼或其他诉讼中。
36
+
37
+ 5. 分发
38
+
39
+ 您可以在不同的条款下分发本软件的副本,无论是修改还是未修改的,只要您满足本许可证的所有条款。
40
+
41
+ 6. 贡献提交
42
+
43
+ 除非您明确声明,否则您提交给贡献者的任何贡献均视为在本许可证下许可,不附加任何额外条款或条件。但是,如果您向贡献者提交了贡献,且您明确声明了与该贡献相关的许可证,则该许可证适用于您的贡献。
@@ -0,0 +1,216 @@
1
+ Metadata-Version: 2.4
2
+ Name: nonebot-plugin-group-market
3
+ Version: 0.3.0
4
+ Summary: 适用于 QQ 群聊的群友市场经济小游戏,包含打工、购买群友、训练、决斗、银行、排行榜、每日任务、等级、成就、防刷屏等玩法。
5
+ Author: Tony
6
+ License: Mulan PSL v2
7
+ Project-URL: Homepage, https://github.com/TonyLiangP2010405/nonebot-plugin-group-market
8
+ Project-URL: Repository, https://github.com/TonyLiangP2010405/nonebot-plugin-group-market
9
+ Keywords: nonebot,nonebot2,plugin,group-game,market,qq-group
10
+ Classifier: Development Status :: 4 - Beta
11
+ Classifier: License :: OSI Approved :: Mulan Permissive Software License v2 (MulanPSL-2.0)
12
+ Classifier: Operating System :: OS Independent
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.10
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Topic :: Communications :: Chat
18
+ Requires-Python: >=3.10
19
+ Description-Content-Type: text/markdown
20
+ License-File: LICENSE
21
+ Requires-Dist: nonebot2>=2.2.0
22
+ Requires-Dist: nonebot-adapter-onebot>=2.0.0
23
+ Requires-Dist: nonebot-plugin-apscheduler>=0.5.0
24
+ Requires-Dist: nonebot-plugin-localstore>=0.7.0
25
+ Requires-Dist: pydantic>=2.0.0
26
+ Requires-Dist: pydantic-settings>=2.0.0
27
+ Requires-Dist: PyYAML>=6.0
28
+ Requires-Dist: aiofiles>=23.0.0
29
+ Requires-Dist: typing-extensions>=4.0.0
30
+ Dynamic: license-file
31
+
32
+ <div align="center">
33
+
34
+ # ✨ 群友市场 ✨
35
+
36
+ <a href="https://v2.nonebot.dev/store">
37
+ <img src="https://raw.githubusercontent.com/A-kirami/nonebot-plugin-template/resources/NoneBotPlugin.svg" width="300" height="120" alt="NoneBotPluginText">
38
+ </a>
39
+
40
+ [![pypi](https://img.shields.io/pypi/v/nonebot-plugin-group-market.svg)](https://pypi.python.org/pypi/nonebot-plugin-group-market)
41
+ [![python](https://img.shields.io/badge/python-3.10+-blue.svg)](https://www.python.org/)
42
+ [![license](https://img.shields.io/badge/license-MulanPSL--2.0-green.svg)](./LICENSE)
43
+
44
+ </div>
45
+
46
+ 适用于 **QQ 群聊** 的 NoneBot2 群友市场经济小游戏,包含打工、购买群友、训练、决斗、银行、排行榜、每日任务、等级、成就、防刷屏等玩法。
47
+
48
+ > 从 Yunzai-Bot V3 插件 [Slave-Market](https://gitee.com/Tloml-Starry/Slave-Market) 移植并大幅扩展而来。
49
+
50
+ ---
51
+
52
+ ## 📦 安装
53
+
54
+ ### 使用 nb-cli 安装(推荐)
55
+
56
+ 在 nonebot2 项目的根目录下打开命令行,输入:
57
+
58
+ ```bash
59
+ nb plugin install nonebot-plugin-group-market
60
+ ```
61
+
62
+ ### 使用包管理器安装
63
+
64
+ ```bash
65
+ pip install nonebot-plugin-group-market
66
+ ```
67
+
68
+ 然后在 `pyproject.toml` 的 `[tool.nonebot]` 部分追加:
69
+
70
+ ```toml
71
+ plugins = ["nonebot_plugin_group_market"]
72
+ ```
73
+
74
+ ---
75
+
76
+ ## 🎮 功能
77
+
78
+ ### 核心玩法
79
+ - 💰 **打工** — 赚取金币
80
+ - 🧑‍🌾 **购买群友** — 将群友收为"奴隶"(游戏内称呼,可自定义)
81
+ - ⚔️ **训练** — 提升奴隶身价
82
+ - ⚔️ **决斗** — 奴隶之间决斗
83
+ - 🏆 **排位赛** — 段位系统(青铜→钻石)
84
+ - 🏦 **银行** — 存款/取款/升级/利息/转账
85
+ - 📊 **排行榜** — 金币榜/身价榜
86
+
87
+ ### 扩展玩法 (v0.2.0+)
88
+ - ✅ **签到系统** — 连续签到奖励,7/30天里程碑
89
+ - ⭐ **等级经验** — 50级上限,打工/训练/决斗获经验
90
+ - 🏅 **成就系统** — 20+ 成就可解锁
91
+ - 📋 **每日任务** — 每天3个随机任务
92
+ - 📊 **个人信息面板** — 综合数据一览
93
+ - 🛒 **道具商店** — 6种道具可购买/使用/赠送
94
+ - 📢 **随机事件** — 每天一个群事件影响玩法
95
+ - 👑 **称号系统** — 8个称号,部分带属性加成
96
+ - 🎯 **悬赏系统** — 发布/领取/取消悬赏
97
+ - 🏆 **赛季系统** — 周/月赛季排名与奖励
98
+
99
+ ### 防刷屏保护 (v0.3.0+)
100
+ - ⏳ **多层冷却** — 用户级+群全局冷却
101
+ - 🛡️ **洪水保护** — 60秒内命令过多自动锁定
102
+ - 🔇 **安静模式** — 冷却期间重复触发静默处理
103
+ - 📉 **查询限流** — 排行榜/信息面板等也有冷却
104
+
105
+ ---
106
+
107
+ ## 📝 使用说明
108
+
109
+ 在群聊中发送以下指令(默认以 `#` 为前缀):
110
+
111
+ ### 经济玩法
112
+
113
+ | 指令 | 说明 |
114
+ |------|------|
115
+ | `#打工` | 赚取金币(冷却20分钟) |
116
+ | `#购买群友 @用户` | 购买群友(冷却30分钟) |
117
+ | `#我的奴隶` | 查看自己的奴隶 |
118
+ | `#放生奴隶 @用户` | 放生奴隶 |
119
+ | `#训练 @用户` | 训练奴隶(冷却45分钟) |
120
+ | `#决斗 @用户1 @用户2` | 奴隶决斗(冷却30分钟) |
121
+ | `#排位赛` | 查看排位信息 |
122
+ | `#参加排位赛 @用户` | 参加排位(冷却30分钟) |
123
+
124
+ ### 银行系统
125
+
126
+ | 指令 | 说明 |
127
+ |------|------|
128
+ | `#存款 数量` | 银行存款 |
129
+ | `#取款 数量` | 银行取款 |
130
+ | `#升级信用` | 升级银行等级 |
131
+ | `#银行信息` | 查看银行详情 |
132
+ | `#领取利息` | 领取银行利息 |
133
+ | `#转账 数量 @用户` | 向他人转账 |
134
+
135
+ ### 扩展玩法
136
+
137
+ | 指令 | 说明 |
138
+ |------|------|
139
+ | `#签到` / `#打卡` | 每日签到 |
140
+ | `#我的等级` | 查看等级经验 |
141
+ | `#我的成就` | 查看成就 |
142
+ | `#每日任务` | 查看今日任务 |
143
+ | `#领取任务奖励` | 领取任务奖励 |
144
+ | `#我的信息` | 个人信息面板 |
145
+ | `#商店` | 道具商店 |
146
+ | `#购买道具 道具名` | 购买道具 |
147
+ | `#今日事件` | 查看今日群事件 |
148
+ | `#我的称号` | 查看称号 |
149
+ | `#悬赏列表` | 查看悬赏 |
150
+ | `#赛季信息` | 赛季信息 |
151
+ | `#赛季排行` | 赛季排名 |
152
+
153
+ ### 管理命令
154
+
155
+ | 指令 | 权限 | 说明 |
156
+ |------|------|------|
157
+ | `#游戏冷却状态` | 任何人 | 查看当前群防刷屏状态 |
158
+ | `#开启安静模式` | 管理员 | 冷却重复触发静默 |
159
+ | `#关闭安静模式` | 管理员 | 恢复提示 |
160
+ | `#开启防刷屏` | 管理员 | 启用防刷屏 |
161
+ | `#关闭防刷屏` | 管理员 | 禁用防刷屏 |
162
+
163
+ > 完整命令列表请发送 `#奴隶帮助` 或 `#群友市场帮助` 查看。
164
+
165
+ ---
166
+
167
+ ## ⚙️ 配置
168
+
169
+ 在 `.env` 文件中添加:
170
+
171
+ ```env
172
+ # 打工冷却(秒)
173
+ slavemarket__work__cooldown=1200
174
+
175
+ # 购买冷却(秒)
176
+ slavemarket__purchase__cooldown=1800
177
+
178
+ # 银行初始限额
179
+ slavemarket__bank__initialLimit=1000
180
+
181
+ # 每周重置开关
182
+ slavemarket__weeklyReset__enabled=true
183
+
184
+ # 防刷屏总开关
185
+ slavemarket__antiSpam__enabled=true
186
+
187
+ # 安静模式开关
188
+ slavemarket__antiSpam__quietMode__enabled=true
189
+
190
+ # 洪水保护:统计窗口(秒)
191
+ slavemarket__antiSpam__groupFloodProtection__windowSeconds=60
192
+
193
+ # 洪水保护:窗口内最大命令数
194
+ slavemarket__antiSpam__groupFloodProtection__maxCommands=20
195
+
196
+ # 洪水保护:锁定持续时间(秒)
197
+ slavemarket__antiSpam__groupFloodProtection__lockSeconds=300
198
+ ```
199
+
200
+ > 所有配置均有默认值,零配置即可运行。详细配置项见源码 `config.py`。
201
+
202
+ ---
203
+
204
+ ## 📋 更新日志
205
+
206
+ 见 [CHANGELOG.md](./CHANGELOG.md)
207
+
208
+ ---
209
+
210
+ ## 📄 许可证
211
+
212
+ 本项目使用 [木兰宽松许可证,第2版](./LICENSE) 开源。
213
+
214
+ ---
215
+
216
+ *若从旧版 `nonebot-plugin-slave-market` 迁移,旧数据完全兼容,详见 [PORTING_NOTES.md](./PORTING_NOTES.md)。*
@@ -0,0 +1,185 @@
1
+ <div align="center">
2
+
3
+ # ✨ 群友市场 ✨
4
+
5
+ <a href="https://v2.nonebot.dev/store">
6
+ <img src="https://raw.githubusercontent.com/A-kirami/nonebot-plugin-template/resources/NoneBotPlugin.svg" width="300" height="120" alt="NoneBotPluginText">
7
+ </a>
8
+
9
+ [![pypi](https://img.shields.io/pypi/v/nonebot-plugin-group-market.svg)](https://pypi.python.org/pypi/nonebot-plugin-group-market)
10
+ [![python](https://img.shields.io/badge/python-3.10+-blue.svg)](https://www.python.org/)
11
+ [![license](https://img.shields.io/badge/license-MulanPSL--2.0-green.svg)](./LICENSE)
12
+
13
+ </div>
14
+
15
+ 适用于 **QQ 群聊** 的 NoneBot2 群友市场经济小游戏,包含打工、购买群友、训练、决斗、银行、排行榜、每日任务、等级、成就、防刷屏等玩法。
16
+
17
+ > 从 Yunzai-Bot V3 插件 [Slave-Market](https://gitee.com/Tloml-Starry/Slave-Market) 移植并大幅扩展而来。
18
+
19
+ ---
20
+
21
+ ## 📦 安装
22
+
23
+ ### 使用 nb-cli 安装(推荐)
24
+
25
+ 在 nonebot2 项目的根目录下打开命令行,输入:
26
+
27
+ ```bash
28
+ nb plugin install nonebot-plugin-group-market
29
+ ```
30
+
31
+ ### 使用包管理器安装
32
+
33
+ ```bash
34
+ pip install nonebot-plugin-group-market
35
+ ```
36
+
37
+ 然后在 `pyproject.toml` 的 `[tool.nonebot]` 部分追加:
38
+
39
+ ```toml
40
+ plugins = ["nonebot_plugin_group_market"]
41
+ ```
42
+
43
+ ---
44
+
45
+ ## 🎮 功能
46
+
47
+ ### 核心玩法
48
+ - 💰 **打工** — 赚取金币
49
+ - 🧑‍🌾 **购买群友** — 将群友收为"奴隶"(游戏内称呼,可自定义)
50
+ - ⚔️ **训练** — 提升奴隶身价
51
+ - ⚔️ **决斗** — 奴隶之间决斗
52
+ - 🏆 **排位赛** — 段位系统(青铜→钻石)
53
+ - 🏦 **银行** — 存款/取款/升级/利息/转账
54
+ - 📊 **排行榜** — 金币榜/身价榜
55
+
56
+ ### 扩展玩法 (v0.2.0+)
57
+ - ✅ **签到系统** — 连续签到奖励,7/30天里程碑
58
+ - ⭐ **等级经验** — 50级上限,打工/训练/决斗获经验
59
+ - 🏅 **成就系统** — 20+ 成就可解锁
60
+ - 📋 **每日任务** — 每天3个随机任务
61
+ - 📊 **个人信息面板** — 综合数据一览
62
+ - 🛒 **道具商店** — 6种道具可购买/使用/赠送
63
+ - 📢 **随机事件** — 每天一个群事件影响玩法
64
+ - 👑 **称号系统** — 8个称号,部分带属性加成
65
+ - 🎯 **悬赏系统** — 发布/领取/取消悬赏
66
+ - 🏆 **赛季系统** — 周/月赛季排名与奖励
67
+
68
+ ### 防刷屏保护 (v0.3.0+)
69
+ - ⏳ **多层冷却** — 用户级+群全局冷却
70
+ - 🛡️ **洪水保护** — 60秒内命令过多自动锁定
71
+ - 🔇 **安静模式** — 冷却期间重复触发静默处理
72
+ - 📉 **查询限流** — 排行榜/信息面板等也有冷却
73
+
74
+ ---
75
+
76
+ ## 📝 使用说明
77
+
78
+ 在群聊中发送以下指令(默认以 `#` 为前缀):
79
+
80
+ ### 经济玩法
81
+
82
+ | 指令 | 说明 |
83
+ |------|------|
84
+ | `#打工` | 赚取金币(冷却20分钟) |
85
+ | `#购买群友 @用户` | 购买群友(冷却30分钟) |
86
+ | `#我的奴隶` | 查看自己的奴隶 |
87
+ | `#放生奴隶 @用户` | 放生奴隶 |
88
+ | `#训练 @用户` | 训练奴隶(冷却45分钟) |
89
+ | `#决斗 @用户1 @用户2` | 奴隶决斗(冷却30分钟) |
90
+ | `#排位赛` | 查看排位信息 |
91
+ | `#参加排位赛 @用户` | 参加排位(冷却30分钟) |
92
+
93
+ ### 银行系统
94
+
95
+ | 指令 | 说明 |
96
+ |------|------|
97
+ | `#存款 数量` | 银行存款 |
98
+ | `#取款 数量` | 银行取款 |
99
+ | `#升级信用` | 升级银行等级 |
100
+ | `#银行信息` | 查看银行详情 |
101
+ | `#领取利息` | 领取银行利息 |
102
+ | `#转账 数量 @用户` | 向他人转账 |
103
+
104
+ ### 扩展玩法
105
+
106
+ | 指令 | 说明 |
107
+ |------|------|
108
+ | `#签到` / `#打卡` | 每日签到 |
109
+ | `#我的等级` | 查看等级经验 |
110
+ | `#我的成就` | 查看成就 |
111
+ | `#每日任务` | 查看今日任务 |
112
+ | `#领取任务奖励` | 领取任务奖励 |
113
+ | `#我的信息` | 个人信息面板 |
114
+ | `#商店` | 道具商店 |
115
+ | `#购买道具 道具名` | 购买道具 |
116
+ | `#今日事件` | 查看今日群事件 |
117
+ | `#我的称号` | 查看称号 |
118
+ | `#悬赏列表` | 查看悬赏 |
119
+ | `#赛季信息` | 赛季信息 |
120
+ | `#赛季排行` | 赛季排名 |
121
+
122
+ ### 管理命令
123
+
124
+ | 指令 | 权限 | 说明 |
125
+ |------|------|------|
126
+ | `#游戏冷却状态` | 任何人 | 查看当前群防刷屏状态 |
127
+ | `#开启安静模式` | 管理员 | 冷却重复触发静默 |
128
+ | `#关闭安静模式` | 管理员 | 恢复提示 |
129
+ | `#开启防刷屏` | 管理员 | 启用防刷屏 |
130
+ | `#关闭防刷屏` | 管理员 | 禁用防刷屏 |
131
+
132
+ > 完整命令列表请发送 `#奴隶帮助` 或 `#群友市场帮助` 查看。
133
+
134
+ ---
135
+
136
+ ## ⚙️ 配置
137
+
138
+ 在 `.env` 文件中添加:
139
+
140
+ ```env
141
+ # 打工冷却(秒)
142
+ slavemarket__work__cooldown=1200
143
+
144
+ # 购买冷却(秒)
145
+ slavemarket__purchase__cooldown=1800
146
+
147
+ # 银行初始限额
148
+ slavemarket__bank__initialLimit=1000
149
+
150
+ # 每周重置开关
151
+ slavemarket__weeklyReset__enabled=true
152
+
153
+ # 防刷屏总开关
154
+ slavemarket__antiSpam__enabled=true
155
+
156
+ # 安静模式开关
157
+ slavemarket__antiSpam__quietMode__enabled=true
158
+
159
+ # 洪水保护:统计窗口(秒)
160
+ slavemarket__antiSpam__groupFloodProtection__windowSeconds=60
161
+
162
+ # 洪水保护:窗口内最大命令数
163
+ slavemarket__antiSpam__groupFloodProtection__maxCommands=20
164
+
165
+ # 洪水保护:锁定持续时间(秒)
166
+ slavemarket__antiSpam__groupFloodProtection__lockSeconds=300
167
+ ```
168
+
169
+ > 所有配置均有默认值,零配置即可运行。详细配置项见源码 `config.py`。
170
+
171
+ ---
172
+
173
+ ## 📋 更新日志
174
+
175
+ 见 [CHANGELOG.md](./CHANGELOG.md)
176
+
177
+ ---
178
+
179
+ ## 📄 许可证
180
+
181
+ 本项目使用 [木兰宽松许可证,第2版](./LICENSE) 开源。
182
+
183
+ ---
184
+
185
+ *若从旧版 `nonebot-plugin-slave-market` 迁移,旧数据完全兼容,详见 [PORTING_NOTES.md](./PORTING_NOTES.md)。*
@@ -0,0 +1,43 @@
1
+ """
2
+ NoneBot2 群友市场插件
3
+ License: Mulan PSL v2
4
+ """
5
+ from nonebot import require, logger, get_driver
6
+ from nonebot.plugin import PluginMetadata
7
+
8
+ require("nonebot_plugin_apscheduler")
9
+
10
+ from .config import plugin_config, Config
11
+ from .storage import init_storage
12
+ from .weekly_reset_task import start_weekly_reset_scheduler
13
+
14
+ __plugin_meta__ = PluginMetadata(
15
+ name="群友市场",
16
+ description="适用于 QQ 群聊的群友市场经济小游戏,包含打工、购买群友、训练、决斗、银行、排行榜、每日任务、等级、成就、防刷屏等玩法。",
17
+ usage=(
18
+ "发送 #群友市场帮助 或 #奴隶帮助 查看完整玩法说明。\n"
19
+ "核心命令: #打工 #购买群友 #训练 #决斗 #排位赛 #银行 #签到 #每日任务 #商店"
20
+ ),
21
+ type="application",
22
+ homepage="https://github.com/TonyLiangP2010405/nonebot-plugin-group-market",
23
+ config=Config,
24
+ supported_adapters={"~onebot.v11"},
25
+ )
26
+
27
+ # 导入扩展配置(确保先加载)
28
+ from . import extension
29
+
30
+ # 导入所有指令模块(触发注册)
31
+ from . import commands
32
+
33
+ driver = get_driver()
34
+
35
+ @driver.on_bot_connect
36
+ async def on_bot_connect():
37
+ logger.info("[GroupMarket] 群友市场插件加载中...")
38
+ await init_storage()
39
+ # 确保扩展群数据目录存在
40
+ from .extension.group_storage import _ensure_dir
41
+ _ensure_dir()
42
+ start_weekly_reset_scheduler()
43
+ logger.info("[GroupMarket] 插件已就绪!")
@@ -0,0 +1,39 @@
1
+ """指令入口 - 导入所有子模块触发注册"""
2
+ from nonebot import on_command, logger
3
+ from nonebot.adapters.onebot.v11 import Bot, Message, MessageEvent, GroupMessageEvent, MessageSegment
4
+ from nonebot.params import CommandArg
5
+ from nonebot.permission import SUPERUSER
6
+
7
+ # 基础帮助
8
+ from .commands_help import help_cmd
9
+ from .commands_work import work_cmd
10
+ from .commands_purchase import purchase_cmd
11
+ from .commands_slave import myslave_cmd, release_cmd
12
+ from .commands_buyback import buyback_cmd
13
+ from .commands_rob import rob_cmd
14
+ from .commands_train import train_cmd
15
+ from .commands_arena import arena_cmd
16
+ from .commands_ranking import ranking_info_cmd, ranking_join_cmd
17
+ from .commands_bank import deposit_cmd, withdraw_cmd, upgrade_cmd, bank_info_cmd, interest_cmd, transfer_cmd
18
+ from .commands_rankings import rankings_cmd
19
+ from .commands_weekly import reset_status_cmd, manual_reset_cmd, reset_help_cmd, last_week_cmd
20
+ from .commands_update import update_cmd
21
+ from .exit_handler import exit_notice
22
+
23
+ # 扩展玩法模块
24
+ from .commands_signin import signin_cmd, signin_rank_cmd
25
+ from .commands_level import level_cmd, level_rank_cmd
26
+ from .commands_achievement import achievement_cmd, achievement_rank_cmd
27
+ from .commands_dailytask import daily_task_cmd, claim_task_reward_cmd, refresh_task_cmd
28
+ from .commands_profile import profile_cmd, view_profile_cmd
29
+ from .commands_shop import shop_cmd, buy_item_cmd, my_items_cmd, use_item_cmd, gift_item_cmd
30
+ from .commands_randomevent import today_event_cmd
31
+ from .commands_title import title_cmd, equip_title_cmd
32
+ from .commands_bounty import bounty_post_cmd, bounty_list_cmd, bounty_claim_cmd, bounty_cancel_cmd
33
+ from .commands_season import season_info_cmd, season_rank_cmd, season_reward_cmd, season_history_cmd
34
+ from .commands_admin import (
35
+ admin_cooldown_status, admin_enable_quiet, admin_disable_quiet,
36
+ admin_enable_spam, admin_disable_spam, admin_set_work_cd, admin_set_group_cd
37
+ )
38
+
39
+ logger.info("[SlaveMarket] 指令模块已注册")
@@ -0,0 +1,137 @@
1
+ """成就系统"""
2
+ from nonebot import on_command
3
+ from nonebot.adapters.onebot.v11 import Bot, GroupMessageEvent
4
+
5
+ from .storage import ensure_player, load_player, save_player, list_group_players
6
+ from .utils import get_member_nickname
7
+ from .extension.config import ext_config
8
+ from .extension.utils import check_achievement_unlock, apply_achievement_rewards
9
+ from .extension.anti_spam import check_cooldown
10
+
11
+ achievement_cmd = on_command("我的成就", aliases={"成就", "成就列表"}, priority=5, block=True)
12
+ achievement_rank_cmd = on_command("成就排行", priority=5, block=True)
13
+
14
+ # 成就定义
15
+ ACHIEVEMENTS_DEF = {
16
+ "first_work": {"name": "初次打工", "desc": "第一次打工", "check": lambda d: d.get("workCount", 0) >= 1},
17
+ "work_10": {"name": "勤劳小蜜蜂", "desc": "累计打工10次", "check": lambda d: d.get("workCount", 0) >= 10},
18
+ "work_50": {"name": "打工皇帝", "desc": "累计打工50次", "check": lambda d: d.get("workCount", 0) >= 50},
19
+ "work_100": {"name": "永动机", "desc": "累计打工100次", "check": lambda d: d.get("workCount", 0) >= 100},
20
+ "first_purchase": {"name": "初次购买", "desc": "第一次购买群友", "check": lambda d: d.get("purchaseCount", 0) >= 1},
21
+ "purchase_10": {"name": "收藏家", "desc": "累计购买10次", "check": lambda d: d.get("purchaseCount", 0) >= 10},
22
+ "first_master": {"name": "成为主人", "desc": "第一次拥有奴隶", "check": lambda d: len(d.get("slave", [])) >= 1},
23
+ "first_bought": {"name": "被买下", "desc": "第一次被购买", "check": lambda d: bool(d.get("master", ""))},
24
+ "train_10": {"name": "训练大师", "desc": "累计训练成功10次", "check": lambda d: d.get("trainSuccessCount", 0) >= 10},
25
+ "arena_win_10": {"name": "决斗王者", "desc": "累计决斗胜利10次", "check": lambda d: d.get("duelStats", {}).get("wins", 0) >= 10},
26
+ "bank_10000": {"name": "理财达人", "desc": "银行存款达到10000", "check": lambda d: d.get("bank", {}).get("balance", 0) >= 10000},
27
+ "value_1000": {"name": "身价过千", "desc": "身价达到1000", "check": lambda d: d.get("value", 100) >= 1000},
28
+ "value_5000": {"name": "身价过万", "desc": "身价达到5000", "check": lambda d: d.get("value", 100) >= 5000},
29
+ "signin_7": {"name": "早起鸟儿", "desc": "连续签到7天", "check": lambda d: d.get("continuousSignInDays", 0) >= 7},
30
+ "signin_30": {"name": "持之以恒", "desc": "连续签到30天", "check": lambda d: d.get("continuousSignInDays", 0) >= 30},
31
+ "level_10": {"name": "初露锋芒", "desc": "等级达到10级", "check": lambda d: d.get("level", 1) >= 10},
32
+ "level_20": {"name": "一代宗师", "desc": "等级达到20级", "check": lambda d: d.get("level", 1) >= 20},
33
+ "level_50": {"name": "传说", "desc": "等级达到50级", "check": lambda d: d.get("level", 1) >= 50},
34
+ "slave_5": {"name": "奴隶收藏家", "desc": "同时拥有5名奴隶", "check": lambda d: len(d.get("slave", [])) >= 5},
35
+ "task_50": {"name": "任务达人", "desc": "累计完成50个每日任务", "check": lambda d: d.get("totalTasksCompleted", 0) >= 50},
36
+ }
37
+
38
+
39
+ def check_all_achievements(data: dict) -> list:
40
+ """检查所有成就,返回新解锁的成就ID列表"""
41
+ newly = []
42
+ for ach_id, ach_def in ACHIEVEMENTS_DEF.items():
43
+ if check_achievement_unlock(data, ach_id, ach_def["check"]):
44
+ newly.append(ach_id)
45
+ return newly
46
+
47
+
48
+ @achievement_cmd.handle()
49
+ async def _(bot: Bot, event: GroupMessageEvent):
50
+ if not isinstance(event, GroupMessageEvent):
51
+ await achievement_cmd.finish("该指令仅群聊可用")
52
+
53
+ allowed, msg = check_cooldown(event, "achievement")
54
+ if not allowed:
55
+ if msg:
56
+ await achievement_cmd.finish(msg)
57
+ return
58
+
59
+ if not ext_config.achievement.enabled:
60
+ await achievement_cmd.finish("成就系统已关闭")
61
+
62
+ group_id = event.group_id
63
+ user_id = event.user_id
64
+ nickname = await get_member_nickname(bot, group_id, user_id)
65
+ data = await ensure_player(group_id, user_id, nickname)
66
+
67
+ # 检查新成就
68
+ newly = check_all_achievements(data)
69
+ if newly:
70
+ apply_achievement_rewards(data)
71
+ await save_player(group_id, user_id, data)
72
+
73
+ achieved = set(data.get("achievements", []))
74
+
75
+ lines = [f"🏅 {nickname} 的成就"]
76
+ if newly:
77
+ lines.append(f"🎉 新解锁 {len(newly)} 个成就!")
78
+
79
+ unlocked = []
80
+ locked = []
81
+ for ach_id, ach_def in ACHIEVEMENTS_DEF.items():
82
+ status = "✅" if ach_id in achieved else "❌"
83
+ line = f"{status} {ach_def['name']} - {ach_def['desc']}"
84
+ if ach_id in achieved:
85
+ unlocked.append(line)
86
+ else:
87
+ locked.append(line)
88
+
89
+ lines.append(f"\n已解锁 ({len(unlocked)}/{len(ACHIEVEMENTS_DEF)}):")
90
+ lines.extend(unlocked[:10])
91
+ if len(unlocked) > 10:
92
+ lines.append(f"... 还有 {len(unlocked) - 10} 个")
93
+
94
+ if locked:
95
+ lines.append(f"\n未解锁:")
96
+ lines.extend(locked[:5])
97
+
98
+ await achievement_cmd.finish("\n".join(lines))
99
+
100
+
101
+ @achievement_rank_cmd.handle()
102
+ async def _(bot: Bot, event: GroupMessageEvent):
103
+ if not isinstance(event, GroupMessageEvent):
104
+ await achievement_rank_cmd.finish("该指令仅群聊可用")
105
+
106
+ allowed, msg = check_cooldown(event, "achievement_rank")
107
+ if not allowed:
108
+ if msg:
109
+ await achievement_rank_cmd.finish(msg)
110
+ return
111
+
112
+ if not ext_config.achievement.enabled:
113
+ await achievement_rank_cmd.finish("成就系统已关闭")
114
+
115
+ group_id = event.group_id
116
+ players = await list_group_players(group_id)
117
+
118
+ items = []
119
+ for pid in players:
120
+ pdata = await load_player(group_id, pid)
121
+ if pdata:
122
+ count = len(pdata.get("achievements", []))
123
+ items.append({
124
+ "name": await get_member_nickname(bot, group_id, pid),
125
+ "count": count,
126
+ })
127
+
128
+ if not items:
129
+ await achievement_rank_cmd.finish("暂无成就数据")
130
+
131
+ items.sort(key=lambda x: x["count"], reverse=True)
132
+
133
+ lines = ["🏅 成就排行榜"]
134
+ for i, item in enumerate(items[:15], 1):
135
+ lines.append(f"{i}. {item['name']} - {item['count']} 个成就")
136
+
137
+ await achievement_rank_cmd.finish("\n".join(lines))