nonebot-plugin-fishing2 0.0.1__py3-none-any.whl → 0.0.3__py3-none-any.whl
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/__init__.py +302 -0
- nonebot_plugin_fishing2/config.py +201 -0
- {nonebot_plugin_fishing → nonebot_plugin_fishing2}/data_source.py +310 -20
- nonebot_plugin_fishing2/migrations/68463f3e5f33_.py +35 -0
- {nonebot_plugin_fishing2-0.0.1.dist-info → nonebot_plugin_fishing2-0.0.3.dist-info}/METADATA +2 -2
- nonebot_plugin_fishing2-0.0.3.dist-info/RECORD +14 -0
- {nonebot_plugin_fishing2-0.0.1.dist-info → nonebot_plugin_fishing2-0.0.3.dist-info}/WHEEL +1 -1
- nonebot_plugin_fishing2-0.0.3.dist-info/top_level.txt +1 -0
- nonebot_plugin_fishing/__init__.py +0 -165
- nonebot_plugin_fishing/config.py +0 -95
- nonebot_plugin_fishing/migrations/1be1c9b715a9_add_achievements.py +0 -39
- nonebot_plugin_fishing2-0.0.1.dist-info/RECORD +0 -14
- nonebot_plugin_fishing2-0.0.1.dist-info/top_level.txt +0 -1
- {nonebot_plugin_fishing → nonebot_plugin_fishing2}/migrations/7609e6d106dd_init_db.py +0 -0
- {nonebot_plugin_fishing → nonebot_plugin_fishing2}/migrations/c5ab992c9af3_add_achievements.py +0 -0
- {nonebot_plugin_fishing → nonebot_plugin_fishing2}/migrations/e9015df43907_add_special_fishes_field.py +0 -0
- {nonebot_plugin_fishing → nonebot_plugin_fishing2}/migrations/f70bdeaec7a4_add_specialfishes_table.py +0 -0
- {nonebot_plugin_fishing → nonebot_plugin_fishing2}/model.py +0 -0
- {nonebot_plugin_fishing2-0.0.1.dist-info → nonebot_plugin_fishing2-0.0.3.dist-info}/licenses/LICENSE +0 -0
@@ -1,165 +0,0 @@
|
|
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
|
-
|
nonebot_plugin_fishing/config.py
DELETED
@@ -1,95 +0,0 @@
|
|
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)
|
@@ -1,39 +0,0 @@
|
|
1
|
-
"""add achievements
|
2
|
-
|
3
|
-
迁移 ID: 1be1c9b715a9
|
4
|
-
父迁移: e9015df43907
|
5
|
-
创建时间: 2024-09-22 17:12:51.193361
|
6
|
-
|
7
|
-
"""
|
8
|
-
from __future__ import annotations
|
9
|
-
|
10
|
-
from collections.abc import Sequence
|
11
|
-
|
12
|
-
from alembic import op
|
13
|
-
import sqlalchemy as sa
|
14
|
-
|
15
|
-
|
16
|
-
revision: str = '1be1c9b715a9'
|
17
|
-
down_revision: str | Sequence[str] | None = 'e9015df43907'
|
18
|
-
branch_labels: str | Sequence[str] | None = None
|
19
|
-
depends_on: str | Sequence[str] | None = None
|
20
|
-
|
21
|
-
|
22
|
-
def upgrade(name: str = "") -> None:
|
23
|
-
if name:
|
24
|
-
return
|
25
|
-
# ### commands auto generated by Alembic - please adjust! ###
|
26
|
-
with op.batch_alter_table('nonebot_plugin_fishing_fishingrecord', schema=None) as batch_op:
|
27
|
-
batch_op.add_column(sa.Column('achievements', sa.TEXT(), nullable=False))
|
28
|
-
|
29
|
-
# ### end Alembic commands ###
|
30
|
-
|
31
|
-
|
32
|
-
def downgrade(name: str = "") -> None:
|
33
|
-
if name:
|
34
|
-
return
|
35
|
-
# ### commands auto generated by Alembic - please adjust! ###
|
36
|
-
with op.batch_alter_table('nonebot_plugin_fishing_fishingrecord', schema=None) as batch_op:
|
37
|
-
batch_op.drop_column('achievements')
|
38
|
-
|
39
|
-
# ### end Alembic commands ###
|
@@ -1,14 +0,0 @@
|
|
1
|
-
nonebot_plugin_fishing/__init__.py,sha256=u8T_bhDTSWlUOqv8GUchjJ0T-v-AwvenbZHtahYDt9Y,6334
|
2
|
-
nonebot_plugin_fishing/config.py,sha256=jJm-KORMyLhNMOhmxqdat381QeOi4CsHyvU3ZSgyO0o,2369
|
3
|
-
nonebot_plugin_fishing/data_source.py,sha256=4uHuquboXQHfKNbZmhJC2p3ASzAEZD8i_5a3Ck_qJnk,18938
|
4
|
-
nonebot_plugin_fishing/model.py,sha256=_DtmxiQhJDiIvY1XOMQZ0HA-ruWY0bexWX9frdhnk0Q,752
|
5
|
-
nonebot_plugin_fishing/migrations/1be1c9b715a9_add_achievements.py,sha256=NELMtqzBf1A1EMsypn83ZIUTaqN27lRmX0H-D2BrOTg,1119
|
6
|
-
nonebot_plugin_fishing/migrations/7609e6d106dd_init_db.py,sha256=tpuIfsS6yPsnGIeMPo16exsEfYZ_urgYAqlCyQ8aw-Y,1386
|
7
|
-
nonebot_plugin_fishing/migrations/c5ab992c9af3_add_achievements.py,sha256=KVj9ADeP03zfW4ZBDmnghbWdxLor3u1yKeho0GaddCI,1119
|
8
|
-
nonebot_plugin_fishing/migrations/e9015df43907_add_special_fishes_field.py,sha256=R4p9vPD5lgg4vmY2KUgF2qIlraxhPYkL93lM5l7wMZw,1094
|
9
|
-
nonebot_plugin_fishing/migrations/f70bdeaec7a4_add_specialfishes_table.py,sha256=DUqv9MTaOSZCBj_9oT2eY3pmWeMnyH0cPj9GyYa5Sag,1194
|
10
|
-
nonebot_plugin_fishing2-0.0.1.dist-info/licenses/LICENSE,sha256=yuLTg7OdKnH7rznCsJ31UJwI4B8_oEP4f_zE7bJS75w,1091
|
11
|
-
nonebot_plugin_fishing2-0.0.1.dist-info/METADATA,sha256=Jr-jeWY5HxDtca1GGRSL1X52guWKRaZBO4DIA3LlrBM,4667
|
12
|
-
nonebot_plugin_fishing2-0.0.1.dist-info/WHEEL,sha256=pxyMxgL8-pra_rKaQ4drOZAegBVuX-G_4nRHjjgWbmo,91
|
13
|
-
nonebot_plugin_fishing2-0.0.1.dist-info/top_level.txt,sha256=vuWOK_pk0nchZlJtKePr16LLEgIEjBkPf9aQNSlSsoU,23
|
14
|
-
nonebot_plugin_fishing2-0.0.1.dist-info/RECORD,,
|
@@ -1 +0,0 @@
|
|
1
|
-
nonebot_plugin_fishing
|
File without changes
|
{nonebot_plugin_fishing → nonebot_plugin_fishing2}/migrations/c5ab992c9af3_add_achievements.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{nonebot_plugin_fishing2-0.0.1.dist-info → nonebot_plugin_fishing2-0.0.3.dist-info}/licenses/LICENSE
RENAMED
File without changes
|