nonebot-plugin-fishing2 0.0.1__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_fishing2-0.0.1/LICENSE +21 -0
- nonebot_plugin_fishing2-0.0.1/PKG-INFO +144 -0
- nonebot_plugin_fishing2-0.0.1/README.md +124 -0
- nonebot_plugin_fishing2-0.0.1/nonebot_plugin_fishing/__init__.py +165 -0
- nonebot_plugin_fishing2-0.0.1/nonebot_plugin_fishing/config.py +95 -0
- nonebot_plugin_fishing2-0.0.1/nonebot_plugin_fishing/data_source.py +463 -0
- nonebot_plugin_fishing2-0.0.1/nonebot_plugin_fishing/migrations/1be1c9b715a9_add_achievements.py +39 -0
- nonebot_plugin_fishing2-0.0.1/nonebot_plugin_fishing/migrations/7609e6d106dd_init_db.py +44 -0
- nonebot_plugin_fishing2-0.0.1/nonebot_plugin_fishing/migrations/c5ab992c9af3_add_achievements.py +39 -0
- nonebot_plugin_fishing2-0.0.1/nonebot_plugin_fishing/migrations/e9015df43907_add_special_fishes_field.py +39 -0
- nonebot_plugin_fishing2-0.0.1/nonebot_plugin_fishing/migrations/f70bdeaec7a4_add_specialfishes_table.py +41 -0
- nonebot_plugin_fishing2-0.0.1/nonebot_plugin_fishing/model.py +20 -0
- nonebot_plugin_fishing2-0.0.1/nonebot_plugin_fishing2.egg-info/PKG-INFO +144 -0
- nonebot_plugin_fishing2-0.0.1/nonebot_plugin_fishing2.egg-info/SOURCES.txt +17 -0
- nonebot_plugin_fishing2-0.0.1/nonebot_plugin_fishing2.egg-info/dependency_links.txt +1 -0
- nonebot_plugin_fishing2-0.0.1/nonebot_plugin_fishing2.egg-info/requires.txt +7 -0
- nonebot_plugin_fishing2-0.0.1/nonebot_plugin_fishing2.egg-info/top_level.txt +1 -0
- nonebot_plugin_fishing2-0.0.1/pyproject.toml +35 -0
- nonebot_plugin_fishing2-0.0.1/setup.cfg +4 -0
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2024 Polaris_Light
|
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,144 @@
|
|
1
|
+
Metadata-Version: 2.4
|
2
|
+
Name: nonebot-plugin-fishing2
|
3
|
+
Version: 0.0.1
|
4
|
+
Summary: 更好的电子钓鱼
|
5
|
+
Author-email: ALittleBot <160833462+C14H22O@users.noreply.github.com>, Polaris_Light <995905922@qq.com>
|
6
|
+
License-Expression: MIT
|
7
|
+
Project-URL: Homepage, https://github.com/FDCraft/nonebot-plugin-fishing2
|
8
|
+
Keywords: fishing
|
9
|
+
Requires-Python: >=3.8
|
10
|
+
Description-Content-Type: text/markdown
|
11
|
+
License-File: LICENSE
|
12
|
+
Requires-Dist: nonebot2>=2.2.1
|
13
|
+
Requires-Dist: nonebot-adapter-onebot>=2.0.0-beta.1
|
14
|
+
Requires-Dist: pydantic>=1.10
|
15
|
+
Requires-Dist: nonebot-plugin-localstore>=0.6.0
|
16
|
+
Requires-Dist: sqlalchemy>=2.0.27
|
17
|
+
Requires-Dist: aiosqlite>=0.20.0
|
18
|
+
Requires-Dist: nonebot-plugin-orm>=0.7.1
|
19
|
+
Dynamic: license-file
|
20
|
+
|
21
|
+
<div align="center">
|
22
|
+
<a href="https://v2.nonebot.dev/store"><img src="https://github.com/A-kirami/nonebot-plugin-template/blob/resources/nbp_logo.png" width="180" height="180" alt="NoneBotPluginLogo"></a>
|
23
|
+
<br>
|
24
|
+
<p><img src="https://github.com/A-kirami/nonebot-plugin-template/blob/resources/NoneBotPlugin.svg" width="240" alt="NoneBotPluginText"></p>
|
25
|
+
</div>
|
26
|
+
|
27
|
+
<div align="center">
|
28
|
+
|
29
|
+
# nonebot-plugin-fishing2
|
30
|
+
|
31
|
+
_✨ 更好的电子钓鱼 ✨_
|
32
|
+
|
33
|
+
<a href="./LICENSE">
|
34
|
+
<img src="https://img.shields.io/github/license/FDCraft/nonebot-plugin-fishing2.svg" alt="license">
|
35
|
+
</a>
|
36
|
+
<a href="https://pypi.python.org/pypi/nonebot-plugin-fishing2">
|
37
|
+
<img src="https://img.shields.io/pypi/v/nonebot-plugin-fishing2.svg" alt="pypi">
|
38
|
+
</a>
|
39
|
+
<img src="https://img.shields.io/badge/python-3.8+-blue.svg" alt="python">
|
40
|
+
|
41
|
+
</div>
|
42
|
+
|
43
|
+
## 💿 安装
|
44
|
+
|
45
|
+
<details open>
|
46
|
+
<summary>使用 nb-cli 安装</summary>
|
47
|
+
在 nonebot2 项目的根目录下打开命令行, 输入以下指令即可安装
|
48
|
+
|
49
|
+
nb plugin install nonebot-plugin-fishing2
|
50
|
+
|
51
|
+
</details>
|
52
|
+
|
53
|
+
<details>
|
54
|
+
<summary>使用包管理器安装</summary>
|
55
|
+
在 nonebot2 项目的插件目录下, 打开命令行, 根据你使用的包管理器, 输入相应的安装命令
|
56
|
+
|
57
|
+
<details>
|
58
|
+
<summary>pip</summary>
|
59
|
+
|
60
|
+
pip install nonebot-plugin-fishing2
|
61
|
+
</details>
|
62
|
+
<details>
|
63
|
+
<summary>pdm</summary>
|
64
|
+
|
65
|
+
pdm add nonebot-plugin-fishing2
|
66
|
+
</details>
|
67
|
+
<details>
|
68
|
+
<summary>poetry</summary>
|
69
|
+
|
70
|
+
poetry add nonebot-plugin-fishing2
|
71
|
+
</details>
|
72
|
+
<details>
|
73
|
+
<summary>conda</summary>
|
74
|
+
|
75
|
+
conda install nonebot-plugin-fishing2
|
76
|
+
</details>
|
77
|
+
|
78
|
+
打开 nonebot2 项目根目录下的 `pyproject.toml` 文件, 在 `[tool.nonebot]` 部分追加写入
|
79
|
+
|
80
|
+
plugins = ["nonebot_plugin_fishing2"]
|
81
|
+
|
82
|
+
</details>
|
83
|
+
|
84
|
+
注意:安装过后,需在控制台输入 `nb orm upgrade` 指令以初始化数据库。
|
85
|
+
|
86
|
+
## ⚙️ 配置
|
87
|
+
|
88
|
+
在 nonebot2 项目的`.env`文件中添加下表中的必填配置
|
89
|
+
|
90
|
+
| 配置项 | 必填 | 说明 |
|
91
|
+
|:-----:|:----:|:----:|
|
92
|
+
| fishes | 否 | 配置鱼塘内鱼们的名称、权重、等待时间和价格 |
|
93
|
+
| fishing_limit | 否 | 填入每次钓鱼后,限制钓鱼的秒数 |
|
94
|
+
| fishing_coin_name | 否 | 填入卖鱼获取的货币名称 |
|
95
|
+
| special_fish_enabled | 否 | 是否启用赛博放生功能(默认为否) |
|
96
|
+
| special_fish_price | 否 | 每放生一次所需的货币数量 |
|
97
|
+
| special_fish_probability | 否 | 钓鱼时钓到用户放生的鱼的概率 |
|
98
|
+
|
99
|
+
其中 `fishes` 配置项说明如下:
|
100
|
+
|
101
|
+
```dotenv
|
102
|
+
FISHES='
|
103
|
+
[
|
104
|
+
{
|
105
|
+
"name": "小鱼", # 鱼的名称
|
106
|
+
"frequency": 2, # 鱼上钩的时间
|
107
|
+
"weight": 100, # 权重
|
108
|
+
"price": 2 # 价格
|
109
|
+
}
|
110
|
+
]
|
111
|
+
'
|
112
|
+
```
|
113
|
+
|
114
|
+
## 🔨 更新
|
115
|
+
|
116
|
+
每一次更新后,需执行 `nb orm upgrade`。
|
117
|
+
|
118
|
+
## 🎉 使用
|
119
|
+
|
120
|
+
### 指令表
|
121
|
+
| 指令 | 范围 | 说明 |
|
122
|
+
|:-----:|:----:|:----:|
|
123
|
+
| 钓鱼 | 所有 | 放下鱼竿 |
|
124
|
+
| 卖鱼 | 所有 | 获取货币 |
|
125
|
+
| 放生 | 所有 | 赛博放生 |
|
126
|
+
| 祈愿 | 所有 | 向神祈愿 |
|
127
|
+
| 背包 | 所有 | 查看背包 |
|
128
|
+
| 成就 | 所有 | 查看成就 |
|
129
|
+
| 排行榜 | 所有 | 富翁排行 |
|
130
|
+
|
131
|
+
### 赛博放生
|
132
|
+
|
133
|
+
当用户使用货币放生由自己取名的一条鱼后,每个用户在钓鱼时都有机会钓到那一条鱼。但此功能开关 `special_fish_enabled` 默认关闭,原因是用户生成内容如果不符合规范,可能导致出现不可预料的情况,请谨慎开启。
|
134
|
+
|
135
|
+
|
136
|
+
## 📝 Todo
|
137
|
+
|
138
|
+
- [x] 重写数据库逻辑(改为使用 [nonebot/plugin-orm](https://github.com/nonebot/plugin-orm))
|
139
|
+
- [x] 增加系统商店,卖出钓到的鱼们
|
140
|
+
- [x] 赛博放生 [#4](https://github.com/C14H22O/nonebot-plugin-fishing/issues/4) (已基本完成)
|
141
|
+
- [ ] 使用 [nonebot_plugin_chikari_economy](https://github.com/mrqx0195/nonebot_plugin_chikari_economy) 经济系统
|
142
|
+
- [ ] 为鱼竿增加耐久度,耐久度为0时需重新购买鱼竿
|
143
|
+
- [ ] 为钓鱼背包添加排序
|
144
|
+
- [x] 添加成就系统
|
@@ -0,0 +1,124 @@
|
|
1
|
+
<div align="center">
|
2
|
+
<a href="https://v2.nonebot.dev/store"><img src="https://github.com/A-kirami/nonebot-plugin-template/blob/resources/nbp_logo.png" width="180" height="180" alt="NoneBotPluginLogo"></a>
|
3
|
+
<br>
|
4
|
+
<p><img src="https://github.com/A-kirami/nonebot-plugin-template/blob/resources/NoneBotPlugin.svg" width="240" alt="NoneBotPluginText"></p>
|
5
|
+
</div>
|
6
|
+
|
7
|
+
<div align="center">
|
8
|
+
|
9
|
+
# nonebot-plugin-fishing2
|
10
|
+
|
11
|
+
_✨ 更好的电子钓鱼 ✨_
|
12
|
+
|
13
|
+
<a href="./LICENSE">
|
14
|
+
<img src="https://img.shields.io/github/license/FDCraft/nonebot-plugin-fishing2.svg" alt="license">
|
15
|
+
</a>
|
16
|
+
<a href="https://pypi.python.org/pypi/nonebot-plugin-fishing2">
|
17
|
+
<img src="https://img.shields.io/pypi/v/nonebot-plugin-fishing2.svg" alt="pypi">
|
18
|
+
</a>
|
19
|
+
<img src="https://img.shields.io/badge/python-3.8+-blue.svg" alt="python">
|
20
|
+
|
21
|
+
</div>
|
22
|
+
|
23
|
+
## 💿 安装
|
24
|
+
|
25
|
+
<details open>
|
26
|
+
<summary>使用 nb-cli 安装</summary>
|
27
|
+
在 nonebot2 项目的根目录下打开命令行, 输入以下指令即可安装
|
28
|
+
|
29
|
+
nb plugin install nonebot-plugin-fishing2
|
30
|
+
|
31
|
+
</details>
|
32
|
+
|
33
|
+
<details>
|
34
|
+
<summary>使用包管理器安装</summary>
|
35
|
+
在 nonebot2 项目的插件目录下, 打开命令行, 根据你使用的包管理器, 输入相应的安装命令
|
36
|
+
|
37
|
+
<details>
|
38
|
+
<summary>pip</summary>
|
39
|
+
|
40
|
+
pip install nonebot-plugin-fishing2
|
41
|
+
</details>
|
42
|
+
<details>
|
43
|
+
<summary>pdm</summary>
|
44
|
+
|
45
|
+
pdm add nonebot-plugin-fishing2
|
46
|
+
</details>
|
47
|
+
<details>
|
48
|
+
<summary>poetry</summary>
|
49
|
+
|
50
|
+
poetry add nonebot-plugin-fishing2
|
51
|
+
</details>
|
52
|
+
<details>
|
53
|
+
<summary>conda</summary>
|
54
|
+
|
55
|
+
conda install nonebot-plugin-fishing2
|
56
|
+
</details>
|
57
|
+
|
58
|
+
打开 nonebot2 项目根目录下的 `pyproject.toml` 文件, 在 `[tool.nonebot]` 部分追加写入
|
59
|
+
|
60
|
+
plugins = ["nonebot_plugin_fishing2"]
|
61
|
+
|
62
|
+
</details>
|
63
|
+
|
64
|
+
注意:安装过后,需在控制台输入 `nb orm upgrade` 指令以初始化数据库。
|
65
|
+
|
66
|
+
## ⚙️ 配置
|
67
|
+
|
68
|
+
在 nonebot2 项目的`.env`文件中添加下表中的必填配置
|
69
|
+
|
70
|
+
| 配置项 | 必填 | 说明 |
|
71
|
+
|:-----:|:----:|:----:|
|
72
|
+
| fishes | 否 | 配置鱼塘内鱼们的名称、权重、等待时间和价格 |
|
73
|
+
| fishing_limit | 否 | 填入每次钓鱼后,限制钓鱼的秒数 |
|
74
|
+
| fishing_coin_name | 否 | 填入卖鱼获取的货币名称 |
|
75
|
+
| special_fish_enabled | 否 | 是否启用赛博放生功能(默认为否) |
|
76
|
+
| special_fish_price | 否 | 每放生一次所需的货币数量 |
|
77
|
+
| special_fish_probability | 否 | 钓鱼时钓到用户放生的鱼的概率 |
|
78
|
+
|
79
|
+
其中 `fishes` 配置项说明如下:
|
80
|
+
|
81
|
+
```dotenv
|
82
|
+
FISHES='
|
83
|
+
[
|
84
|
+
{
|
85
|
+
"name": "小鱼", # 鱼的名称
|
86
|
+
"frequency": 2, # 鱼上钩的时间
|
87
|
+
"weight": 100, # 权重
|
88
|
+
"price": 2 # 价格
|
89
|
+
}
|
90
|
+
]
|
91
|
+
'
|
92
|
+
```
|
93
|
+
|
94
|
+
## 🔨 更新
|
95
|
+
|
96
|
+
每一次更新后,需执行 `nb orm upgrade`。
|
97
|
+
|
98
|
+
## 🎉 使用
|
99
|
+
|
100
|
+
### 指令表
|
101
|
+
| 指令 | 范围 | 说明 |
|
102
|
+
|:-----:|:----:|:----:|
|
103
|
+
| 钓鱼 | 所有 | 放下鱼竿 |
|
104
|
+
| 卖鱼 | 所有 | 获取货币 |
|
105
|
+
| 放生 | 所有 | 赛博放生 |
|
106
|
+
| 祈愿 | 所有 | 向神祈愿 |
|
107
|
+
| 背包 | 所有 | 查看背包 |
|
108
|
+
| 成就 | 所有 | 查看成就 |
|
109
|
+
| 排行榜 | 所有 | 富翁排行 |
|
110
|
+
|
111
|
+
### 赛博放生
|
112
|
+
|
113
|
+
当用户使用货币放生由自己取名的一条鱼后,每个用户在钓鱼时都有机会钓到那一条鱼。但此功能开关 `special_fish_enabled` 默认关闭,原因是用户生成内容如果不符合规范,可能导致出现不可预料的情况,请谨慎开启。
|
114
|
+
|
115
|
+
|
116
|
+
## 📝 Todo
|
117
|
+
|
118
|
+
- [x] 重写数据库逻辑(改为使用 [nonebot/plugin-orm](https://github.com/nonebot/plugin-orm))
|
119
|
+
- [x] 增加系统商店,卖出钓到的鱼们
|
120
|
+
- [x] 赛博放生 [#4](https://github.com/C14H22O/nonebot-plugin-fishing/issues/4) (已基本完成)
|
121
|
+
- [ ] 使用 [nonebot_plugin_chikari_economy](https://github.com/mrqx0195/nonebot_plugin_chikari_economy) 经济系统
|
122
|
+
- [ ] 为鱼竿增加耐久度,耐久度为0时需重新购买鱼竿
|
123
|
+
- [ ] 为钓鱼背包添加排序
|
124
|
+
- [x] 添加成就系统
|
@@ -0,0 +1,165 @@
|
|
1
|
+
from nonebot import on_command, require
|
2
|
+
|
3
|
+
require("nonebot_plugin_orm") # noqa
|
4
|
+
|
5
|
+
from nonebot.plugin import PluginMetadata
|
6
|
+
from nonebot.adapters import Event, Message
|
7
|
+
from nonebot.params import CommandArg
|
8
|
+
from nonebot.permission import SUPERUSER
|
9
|
+
|
10
|
+
from nonebot.adapters.onebot.v11 import Bot, GroupMessageEvent, PrivateMessageEvent, Message, MessageSegment, ActionFailed
|
11
|
+
|
12
|
+
import asyncio
|
13
|
+
|
14
|
+
from typing import Union
|
15
|
+
|
16
|
+
from .config import Config, config
|
17
|
+
from .data_source import (
|
18
|
+
choice,
|
19
|
+
can_fishing,
|
20
|
+
can_catch_special_fish,
|
21
|
+
can_free_fish,
|
22
|
+
get_stats,
|
23
|
+
save_fish,
|
24
|
+
save_special_fish,
|
25
|
+
get_backpack,
|
26
|
+
sell_fish,
|
27
|
+
get_balance,
|
28
|
+
free_fish,
|
29
|
+
random_get_a_special_fish,
|
30
|
+
lottery,
|
31
|
+
give,
|
32
|
+
check_achievement,
|
33
|
+
get_achievements,
|
34
|
+
get_board
|
35
|
+
)
|
36
|
+
|
37
|
+
fishing_coin_name = config.fishing_coin_name
|
38
|
+
|
39
|
+
__plugin_meta__ = PluginMetadata(
|
40
|
+
name="赛博钓鱼",
|
41
|
+
description="你甚至可以电子钓鱼",
|
42
|
+
usage=f'''钓鱼帮助
|
43
|
+
▶ 钓鱼:有 {config.fishing_limit}s 的冷却,时间随上一条鱼稀有度变化
|
44
|
+
▶ 卖鱼 [鱼名] [数量]:卖鱼获得{fishing_coin_name}
|
45
|
+
▶ 放生 [鱼名]:给一条鱼取名并放生
|
46
|
+
▶ 祈愿:向神祈愿,随机获取/损失{fishing_coin_name}
|
47
|
+
▶ 背包:查看背包中的{fishing_coin_name}与物品
|
48
|
+
▶ 成就:查看拥有的成就
|
49
|
+
▶ 钓鱼排行榜:查看{fishing_coin_name}排行榜
|
50
|
+
''',
|
51
|
+
type="application",
|
52
|
+
homepage="https://github.com/ALittleBot/nonebot-plugin-fishing",
|
53
|
+
config=Config,
|
54
|
+
supported_adapters=None,
|
55
|
+
)
|
56
|
+
|
57
|
+
fishing_help = on_command("fishing_help", aliases={"钓鱼帮助"}, priority=3,block=True)
|
58
|
+
fishing = on_command("fishing", aliases={"钓鱼"}, priority=5)
|
59
|
+
backpack = on_command("backpack", aliases={"背包", "钓鱼背包"}, priority=5)
|
60
|
+
sell = on_command("sell", aliases={"卖鱼", "出售"}, priority=5)
|
61
|
+
free_fish_cmd = on_command("free_fish", aliases={"放生", "钓鱼放生"}, priority=5)
|
62
|
+
lottery_cmd = on_command("lottery", aliases={"祈愿"}, priority=5)
|
63
|
+
achievement_cmd = on_command("achievement", aliases={"成就", "钓鱼成就"}, priority=5)
|
64
|
+
give_cmd = on_command("give", aliases={"赐予"}, permission=SUPERUSER, priority=5)
|
65
|
+
board_cmd = on_command("board", aliases={"排行榜", "钓鱼排行榜"}, priority=5)
|
66
|
+
|
67
|
+
|
68
|
+
@fishing_help.handle()
|
69
|
+
async def _():
|
70
|
+
await fishing_help.finish(__plugin_meta__.usage)
|
71
|
+
|
72
|
+
@fishing.handle()
|
73
|
+
async def _(event: Event):
|
74
|
+
user_id = event.get_user_id()
|
75
|
+
if not await can_fishing(user_id):
|
76
|
+
await fishing.finish("河累了, 休息一下吧")
|
77
|
+
await fishing.send("正在钓鱼…")
|
78
|
+
if await can_catch_special_fish():
|
79
|
+
special_fish_name = await random_get_a_special_fish()
|
80
|
+
result = f"你钓到了别人放生的 {special_fish_name}"
|
81
|
+
await save_special_fish(user_id, special_fish_name)
|
82
|
+
await fishing.finish(result)
|
83
|
+
choice_result = choice()
|
84
|
+
fish = choice_result[0]
|
85
|
+
sleep_time = choice_result[1]
|
86
|
+
result = f"钓到了一条{fish}, 你把它收进了背包里"
|
87
|
+
await save_fish(user_id, fish)
|
88
|
+
await asyncio.sleep(sleep_time)
|
89
|
+
achievements = await check_achievement(user_id)
|
90
|
+
if achievements is not None:
|
91
|
+
for achievement in achievements:
|
92
|
+
await fishing.send(achievement)
|
93
|
+
await fishing.finish(MessageSegment.at(user_id) + " " + result)
|
94
|
+
|
95
|
+
|
96
|
+
@backpack.handle()
|
97
|
+
async def _(event: Event):
|
98
|
+
user_id = event.get_user_id()
|
99
|
+
await backpack.finish(MessageSegment.at(user_id) + " \n" + await get_stats(user_id) + "\n" + await get_balance(user_id) + "\n" + await get_backpack(user_id))
|
100
|
+
|
101
|
+
|
102
|
+
@sell.handle()
|
103
|
+
async def _(event: Event, arg: Message = CommandArg()):
|
104
|
+
fish_info = arg.extract_plain_text()
|
105
|
+
user_id = event.get_user_id()
|
106
|
+
if fish_info == "":
|
107
|
+
await sell.finish(MessageSegment.at(user_id) + " " + "请输入要卖出的鱼的名字和数量 (数量为1时可省略), 如 /卖鱼 小鱼 1")
|
108
|
+
if len(fish_info.split()) == 1:
|
109
|
+
await sell.finish(MessageSegment.at(user_id) + " " + await sell_fish(user_id, fish_info))
|
110
|
+
else:
|
111
|
+
fish_name, fish_quantity = fish_info.split()
|
112
|
+
await sell.finish(MessageSegment.at(user_id) + " " + await sell_fish(user_id, fish_name, int(fish_quantity)))
|
113
|
+
|
114
|
+
|
115
|
+
@free_fish_cmd.handle()
|
116
|
+
async def _(event: Event, arg: Message = CommandArg()):
|
117
|
+
if not can_free_fish():
|
118
|
+
await free_fish_cmd.finish("未开启此功能, 请联系机器人管理员")
|
119
|
+
fish_name = arg.extract_plain_text()
|
120
|
+
user_id = event.get_user_id()
|
121
|
+
if fish_name == "":
|
122
|
+
await free_fish_cmd.finish(MessageSegment.at(user_id) + " " + "请输入要放生的鱼的名字, 如 /放生 测试鱼")
|
123
|
+
await free_fish_cmd.finish(MessageSegment.at(user_id) + " " + await free_fish(user_id, fish_name))
|
124
|
+
|
125
|
+
|
126
|
+
@lottery_cmd.handle()
|
127
|
+
async def _(event: Event):
|
128
|
+
user_id = event.get_user_id()
|
129
|
+
await lottery_cmd.finish(MessageSegment.at(user_id) + " " + await lottery(user_id))
|
130
|
+
|
131
|
+
|
132
|
+
@achievement_cmd.handle()
|
133
|
+
async def _(event: Event):
|
134
|
+
user_id = event.get_user_id()
|
135
|
+
await achievement_cmd.finish(MessageSegment.at(user_id) + " " + await get_achievements(user_id))
|
136
|
+
|
137
|
+
|
138
|
+
@give_cmd.handle()
|
139
|
+
async def _(arg: Message = CommandArg()):
|
140
|
+
info = arg.extract_plain_text().split()
|
141
|
+
if len(info) < 2 or len(info) > 3:
|
142
|
+
await give_cmd.finish("请输入用户的 id 和鱼的名字和数量 (数量为1时可省略), 如 /give 114514 开发鱼 1")
|
143
|
+
else:
|
144
|
+
quantity = int(info[2]) if len(info) == 3 else 1
|
145
|
+
await give_cmd.finish(await give(info[0], info[1], quantity))
|
146
|
+
|
147
|
+
|
148
|
+
@board_cmd.handle()
|
149
|
+
async def _(bot: Bot, event: GroupMessageEvent):
|
150
|
+
group_id = event.group_id
|
151
|
+
top_users_list = await get_board()
|
152
|
+
msg = '钓鱼富豪排行榜:'
|
153
|
+
for index, user in enumerate(top_users_list):
|
154
|
+
try:
|
155
|
+
user_info = await bot.get_group_member_info(group_id=group_id, user_id=user[0])
|
156
|
+
username = user_info['card'] if user_info['card'] is not None and user_info['card'] != '' else user_info['nickname']
|
157
|
+
except ActionFailed:
|
158
|
+
username = "[神秘富豪]"
|
159
|
+
|
160
|
+
msg += f'\n{index + 1}. {username}: {user[1]} {fishing_coin_name}'
|
161
|
+
|
162
|
+
await board_cmd.finish(msg)
|
163
|
+
|
164
|
+
|
165
|
+
|
@@ -0,0 +1,95 @@
|
|
1
|
+
from pydantic import BaseModel
|
2
|
+
from typing import List, Dict
|
3
|
+
|
4
|
+
try:
|
5
|
+
# pydantic v2
|
6
|
+
from nonebot import get_plugin_config
|
7
|
+
except ImportError:
|
8
|
+
# pydantic v1
|
9
|
+
from nonebot import get_driver
|
10
|
+
|
11
|
+
|
12
|
+
class Config(BaseModel):
|
13
|
+
fishes: List[Dict] = [
|
14
|
+
{
|
15
|
+
"name": "小鱼",
|
16
|
+
"frequency": 2,
|
17
|
+
"weight": 100,
|
18
|
+
"price": 10
|
19
|
+
},
|
20
|
+
{
|
21
|
+
"name": "尚方宝剑",
|
22
|
+
"frequency": 2,
|
23
|
+
"weight": 50,
|
24
|
+
"price": 20
|
25
|
+
},
|
26
|
+
{
|
27
|
+
"name": "小杂鱼~♡",
|
28
|
+
"frequency": 10,
|
29
|
+
"weight": 10,
|
30
|
+
"price": 100
|
31
|
+
},
|
32
|
+
{
|
33
|
+
"name": "烤激光鱼",
|
34
|
+
"frequency": 20,
|
35
|
+
"weight": 1,
|
36
|
+
"price": 1000
|
37
|
+
},
|
38
|
+
{
|
39
|
+
"name": "大傻",
|
40
|
+
"frequency": 30,
|
41
|
+
"weight": 1,
|
42
|
+
"price": 2000
|
43
|
+
}
|
44
|
+
]
|
45
|
+
|
46
|
+
fishing_limit: int = 30
|
47
|
+
|
48
|
+
fishing_coin_name: str = "绿宝石" # It means Fishing Coin.
|
49
|
+
|
50
|
+
special_fish_enabled: bool = True
|
51
|
+
|
52
|
+
special_fish_price: int = 200
|
53
|
+
|
54
|
+
special_fish_probability: float = 0.01
|
55
|
+
|
56
|
+
fishing_achievement: List[Dict] = [
|
57
|
+
{
|
58
|
+
"type": "fishing_frequency",
|
59
|
+
"name": "腥味十足的生意",
|
60
|
+
"data": 1,
|
61
|
+
"description": "钓到一条鱼。"
|
62
|
+
},
|
63
|
+
{
|
64
|
+
"type": "fishing_frequency",
|
65
|
+
"name": "还是钓鱼大佬",
|
66
|
+
"data": 100,
|
67
|
+
"description": "累计钓鱼一百次。"
|
68
|
+
},
|
69
|
+
{
|
70
|
+
"type": "fish_type",
|
71
|
+
"name": "那是鱼吗?",
|
72
|
+
"data": "小杂鱼~♡",
|
73
|
+
"description": "获得#####。[原文如此]"
|
74
|
+
},
|
75
|
+
{
|
76
|
+
"type": "fish_type",
|
77
|
+
"name": "那一晚, 激光鱼和便携式烤炉都喝醉了",
|
78
|
+
"data": "烤激光鱼",
|
79
|
+
"description": "获得烤激光鱼。"
|
80
|
+
},
|
81
|
+
{
|
82
|
+
"type": "fish_type",
|
83
|
+
"name": "你怎么把 Fufu 钓上来了",
|
84
|
+
"data": "大傻",
|
85
|
+
"description": "获得大傻"
|
86
|
+
}
|
87
|
+
]
|
88
|
+
|
89
|
+
|
90
|
+
try:
|
91
|
+
# pydantic v2
|
92
|
+
config = get_plugin_config(Config)
|
93
|
+
except:
|
94
|
+
# pydantic v1
|
95
|
+
config = Config.parse_obj(get_driver().config)
|