nonebot-plugin-farm 1.2.0__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.
Potentially problematic release.
This version of nonebot-plugin-farm might be problematic. Click here for more details.
- nonebot_plugin_farm/__init__.py +55 -0
- nonebot_plugin_farm/command.py +425 -0
- nonebot_plugin_farm/config/item.json +22 -0
- nonebot_plugin_farm/config/level.json +172 -0
- nonebot_plugin_farm/config/plant.json +276 -0
- nonebot_plugin_farm/config/sign_in.json +4 -0
- nonebot_plugin_farm/config/soil.json +157 -0
- nonebot_plugin_farm/config.py +16 -0
- nonebot_plugin_farm/database/database.py +130 -0
- nonebot_plugin_farm/database/user.py +438 -0
- nonebot_plugin_farm/database/userItem.py +168 -0
- nonebot_plugin_farm/database/userPlant.py +147 -0
- nonebot_plugin_farm/database/userSeed.py +224 -0
- nonebot_plugin_farm/database/userSoil.py +330 -0
- nonebot_plugin_farm/database/userSteal.py +228 -0
- nonebot_plugin_farm/dbService.py +35 -0
- nonebot_plugin_farm/event/event.py +103 -0
- nonebot_plugin_farm/farm/farm.py +640 -0
- nonebot_plugin_farm/farm/shop.py +171 -0
- nonebot_plugin_farm/json.py +100 -0
- nonebot_plugin_farm/log/log.md +31 -0
- nonebot_plugin_farm/request.py +125 -0
- nonebot_plugin_farm/resource/background/background.jpg +0 -0
- nonebot_plugin_farm/resource/background/background.png +0 -0
- nonebot_plugin_farm/resource/background/expansion.png +0 -0
- nonebot_plugin_farm/resource/background/frame.png +0 -0
- nonebot_plugin_farm/resource/background/ripe.png +0 -0
- nonebot_plugin_farm/resource/plant/ATTomato/1.png +0 -0
- nonebot_plugin_farm/resource/plant/ATTomato/2.png +0 -0
- nonebot_plugin_farm/resource/plant/ATTomato/3.png +0 -0
- nonebot_plugin_farm/resource/plant/ATTomato/4.png +0 -0
- nonebot_plugin_farm/resource/plant/ATTomato/5.png +0 -0
- nonebot_plugin_farm/resource/plant/ATTomato/icon.png +0 -0
- nonebot_plugin_farm/resource/plant/basic/0.png +0 -0
- nonebot_plugin_farm/resource/plant/basic/9.png +0 -0
- nonebot_plugin_farm/resource/plant//345/244/247/347/231/275/350/217/234/1.png +0 -0
- nonebot_plugin_farm/resource/plant//345/244/247/347/231/275/350/217/234/2.png +0 -0
- nonebot_plugin_farm/resource/plant//345/244/247/347/231/275/350/217/234/3.png +0 -0
- nonebot_plugin_farm/resource/plant//345/244/247/347/231/275/350/217/234/4.png +0 -0
- nonebot_plugin_farm/resource/plant//345/244/247/347/231/275/350/217/234/icon.png +0 -0
- nonebot_plugin_farm/resource/plant//345/244/247/350/222/234/1.png +0 -0
- nonebot_plugin_farm/resource/plant//345/244/247/350/222/234/2.png +0 -0
- nonebot_plugin_farm/resource/plant//345/244/247/350/222/234/3.png +0 -0
- nonebot_plugin_farm/resource/plant//345/244/247/350/222/234/4.png +0 -0
- nonebot_plugin_farm/resource/plant//345/244/247/350/222/234/5.png +0 -0
- nonebot_plugin_farm/resource/plant//345/244/247/350/222/234/icon.png +0 -0
- nonebot_plugin_farm/resource/plant//345/260/217/347/231/275/350/217/234/1.png +0 -0
- nonebot_plugin_farm/resource/plant//345/260/217/347/231/275/350/217/234/2.png +0 -0
- nonebot_plugin_farm/resource/plant//345/260/217/347/231/275/350/217/234/3.png +0 -0
- nonebot_plugin_farm/resource/plant//345/260/217/347/231/275/350/217/234/4.png +0 -0
- nonebot_plugin_farm/resource/plant//345/260/217/347/231/275/350/217/234/icon.png +0 -0
- nonebot_plugin_farm/resource/plant//345/260/217/351/272/246/1.png +0 -0
- nonebot_plugin_farm/resource/plant//345/260/217/351/272/246/2.png +0 -0
- nonebot_plugin_farm/resource/plant//345/260/217/351/272/246/3.png +0 -0
- nonebot_plugin_farm/resource/plant//345/260/217/351/272/246/4.png +0 -0
- nonebot_plugin_farm/resource/plant//345/260/217/351/272/246/5.png +0 -0
- nonebot_plugin_farm/resource/plant//345/260/217/351/272/246/icon.png +0 -0
- nonebot_plugin_farm/resource/plant//346/260/264/347/250/273/0.png +0 -0
- nonebot_plugin_farm/resource/plant//346/260/264/347/250/273/1.png +0 -0
- nonebot_plugin_farm/resource/plant//346/260/264/347/250/273/2.png +0 -0
- nonebot_plugin_farm/resource/plant//346/260/264/347/250/273/3.png +0 -0
- nonebot_plugin_farm/resource/plant//346/260/264/347/250/273/4.png +0 -0
- nonebot_plugin_farm/resource/plant//346/260/264/347/250/273/icon.png +0 -0
- nonebot_plugin_farm/resource/plant//346/262/271/350/217/234/1.png +0 -0
- nonebot_plugin_farm/resource/plant//346/262/271/350/217/234/2.png +0 -0
- nonebot_plugin_farm/resource/plant//346/262/271/350/217/234/3.png +0 -0
- nonebot_plugin_farm/resource/plant//346/262/271/350/217/234/4.png +0 -0
- nonebot_plugin_farm/resource/plant//346/262/271/350/217/234/icon.png +0 -0
- nonebot_plugin_farm/resource/plant//347/211/247/350/215/211/1.png +0 -0
- nonebot_plugin_farm/resource/plant//347/211/247/350/215/211/2.png +0 -0
- nonebot_plugin_farm/resource/plant//347/211/247/350/215/211/3.png +0 -0
- nonebot_plugin_farm/resource/plant//347/211/247/350/215/211/4.png +0 -0
- nonebot_plugin_farm/resource/plant//347/211/247/350/215/211/icon.png +0 -0
- nonebot_plugin_farm/resource/plant//347/216/211/347/261/263/1.png +0 -0
- nonebot_plugin_farm/resource/plant//347/216/211/347/261/263/2.png +0 -0
- nonebot_plugin_farm/resource/plant//347/216/211/347/261/263/3.png +0 -0
- nonebot_plugin_farm/resource/plant//347/216/211/347/261/263/4.png +0 -0
- nonebot_plugin_farm/resource/plant//347/216/211/347/261/263/5.png +0 -0
- nonebot_plugin_farm/resource/plant//347/216/211/347/261/263/icon.png +0 -0
- nonebot_plugin_farm/resource/plant//347/224/237/350/217/234/1.png +0 -0
- nonebot_plugin_farm/resource/plant//347/224/237/350/217/234/2.png +0 -0
- nonebot_plugin_farm/resource/plant//347/224/237/350/217/234/3.png +0 -0
- nonebot_plugin_farm/resource/plant//347/224/237/350/217/234/4.png +0 -0
- nonebot_plugin_farm/resource/plant//347/224/237/350/217/234/5.png +0 -0
- nonebot_plugin_farm/resource/plant//347/224/237/350/217/234/icon.png +0 -0
- nonebot_plugin_farm/resource/plant//347/225/252/350/214/204/1.png +0 -0
- nonebot_plugin_farm/resource/plant//347/225/252/350/214/204/2.png +0 -0
- nonebot_plugin_farm/resource/plant//347/225/252/350/214/204/3.png +0 -0
- nonebot_plugin_farm/resource/plant//347/225/252/350/214/204/4.png +0 -0
- nonebot_plugin_farm/resource/plant//347/225/252/350/214/204/5.png +0 -0
- nonebot_plugin_farm/resource/plant//347/225/252/350/214/204/icon.png +0 -0
- nonebot_plugin_farm/resource/plant//347/231/275/350/220/235/345/215/234/1.png +0 -0
- nonebot_plugin_farm/resource/plant//347/231/275/350/220/235/345/215/234/2.png +0 -0
- nonebot_plugin_farm/resource/plant//347/231/275/350/220/235/345/215/234/3.png +0 -0
- nonebot_plugin_farm/resource/plant//347/231/275/350/220/235/345/215/234/4.png +0 -0
- nonebot_plugin_farm/resource/plant//347/231/275/350/220/235/345/215/234/icon.png +0 -0
- nonebot_plugin_farm/resource/plant//347/272/242/346/236/243/1.png +0 -0
- nonebot_plugin_farm/resource/plant//347/272/242/346/236/243/2.png +0 -0
- nonebot_plugin_farm/resource/plant//347/272/242/346/236/243/3.png +0 -0
- nonebot_plugin_farm/resource/plant//347/272/242/346/236/243/4.png +0 -0
- nonebot_plugin_farm/resource/plant//347/272/242/346/236/243/5.png +0 -0
- nonebot_plugin_farm/resource/plant//347/272/242/346/236/243/icon.png +0 -0
- nonebot_plugin_farm/resource/plant//347/272/242/347/216/253/347/221/260/1.png +0 -0
- nonebot_plugin_farm/resource/plant//347/272/242/347/216/253/347/221/260/2.png +0 -0
- nonebot_plugin_farm/resource/plant//347/272/242/347/216/253/347/221/260/3.png +0 -0
- nonebot_plugin_farm/resource/plant//347/272/242/347/216/253/347/221/260/4.png +0 -0
- nonebot_plugin_farm/resource/plant//347/272/242/347/216/253/347/221/260/5.png +0 -0
- nonebot_plugin_farm/resource/plant//347/272/242/347/216/253/347/221/260/icon.png +0 -0
- nonebot_plugin_farm/resource/plant//350/203/241/350/220/235/345/215/234/1.png +0 -0
- nonebot_plugin_farm/resource/plant//350/203/241/350/220/235/345/215/234/2.png +0 -0
- nonebot_plugin_farm/resource/plant//350/203/241/350/220/235/345/215/234/3.png +0 -0
- nonebot_plugin_farm/resource/plant//350/203/241/350/220/235/345/215/234/4.png +0 -0
- nonebot_plugin_farm/resource/plant//350/203/241/350/220/235/345/215/234/icon.png +0 -0
- nonebot_plugin_farm/resource/plant//350/214/204/345/255/220/1.png +0 -0
- nonebot_plugin_farm/resource/plant//350/214/204/345/255/220/2.png +0 -0
- nonebot_plugin_farm/resource/plant//350/214/204/345/255/220/3.png +0 -0
- nonebot_plugin_farm/resource/plant//350/214/204/345/255/220/4.png +0 -0
- nonebot_plugin_farm/resource/plant//350/214/204/345/255/220/5.png +0 -0
- nonebot_plugin_farm/resource/plant//350/214/204/345/255/220/icon.png +0 -0
- nonebot_plugin_farm/resource/plant//350/261/214/350/261/206/1.png +0 -0
- nonebot_plugin_farm/resource/plant//350/261/214/350/261/206/2.png +0 -0
- nonebot_plugin_farm/resource/plant//350/261/214/350/261/206/3.png +0 -0
- nonebot_plugin_farm/resource/plant//350/261/214/350/261/206/4.png +0 -0
- nonebot_plugin_farm/resource/plant//350/261/214/350/261/206/5.png +0 -0
- nonebot_plugin_farm/resource/plant//350/261/214/350/261/206/icon.png +0 -0
- nonebot_plugin_farm/resource/soil//346/231/256/351/200/232/345/234/237/345/234/260.png +0 -0
- nonebot_plugin_farm/resource/soil//347/274/272/346/260/264-/346/231/256/351/200/232/345/234/237/345/234/260.png +0 -0
- nonebot_plugin_farm/resource/soil//350/215/211/345/234/237/345/234/260.png +0 -0
- nonebot_plugin_farm-1.2.0.dist-info/LICENSE +674 -0
- nonebot_plugin_farm-1.2.0.dist-info/METADATA +115 -0
- nonebot_plugin_farm-1.2.0.dist-info/RECORD +132 -0
- nonebot_plugin_farm-1.2.0.dist-info/WHEEL +4 -0
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
from nonebot import get_driver
|
|
2
|
+
from nonebot.plugin import PluginMetadata
|
|
3
|
+
|
|
4
|
+
from nonebot import logger
|
|
5
|
+
|
|
6
|
+
from .command import diuse_farm, diuse_register, reclamation
|
|
7
|
+
from .config import g_pConfigManager
|
|
8
|
+
from .json import g_pJsonManager
|
|
9
|
+
from .database.database import g_pSqlManager
|
|
10
|
+
from .dbService import g_pDBService
|
|
11
|
+
from .farm.farm import g_pFarmManager
|
|
12
|
+
from .farm.shop import g_pShopManager
|
|
13
|
+
from .request import g_pRequestManager
|
|
14
|
+
|
|
15
|
+
__plugin_meta__ = PluginMetadata(
|
|
16
|
+
name="真寻农场",
|
|
17
|
+
description="快乐的农场时光",
|
|
18
|
+
usage="""
|
|
19
|
+
你也要种地?
|
|
20
|
+
指令:
|
|
21
|
+
at 开通农场
|
|
22
|
+
我的农场
|
|
23
|
+
我的农场币
|
|
24
|
+
种子商店 [页数]
|
|
25
|
+
购买种子 [作物/种子名称] [数量]
|
|
26
|
+
我的种子
|
|
27
|
+
播种 [作物/种子名称] [数量] (数量不填默认将最大可能播种
|
|
28
|
+
收获
|
|
29
|
+
铲除
|
|
30
|
+
我的作物
|
|
31
|
+
出售作物 [作物/种子名称] [数量] (不填写作物名将售卖仓库种全部作物 填作物名不填数量将指定作物全部出售
|
|
32
|
+
偷菜 at (每人每天只能偷5次
|
|
33
|
+
开垦
|
|
34
|
+
购买农场币 [数量] 数量为消耗金币的数量
|
|
35
|
+
更改农场名 [新农场名]
|
|
36
|
+
""".strip()
|
|
37
|
+
)
|
|
38
|
+
driver = get_driver()
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
# 构造函数
|
|
42
|
+
@driver.on_startup
|
|
43
|
+
async def start():
|
|
44
|
+
# 初始化数据库
|
|
45
|
+
await g_pSqlManager.init()
|
|
46
|
+
|
|
47
|
+
# 初始化读取Json
|
|
48
|
+
await g_pJsonManager.init()
|
|
49
|
+
|
|
50
|
+
await g_pDBService.init()
|
|
51
|
+
|
|
52
|
+
# 析构函数
|
|
53
|
+
@driver.on_shutdown
|
|
54
|
+
async def shutdown():
|
|
55
|
+
await g_pSqlManager.cleanup()
|
|
@@ -0,0 +1,425 @@
|
|
|
1
|
+
from nonebot.adapters import Event, MessageTemplate
|
|
2
|
+
from nonebot.rule import to_me
|
|
3
|
+
from nonebot_plugin_alconna import (Alconna, AlconnaMatch, AlconnaQuery, Args,
|
|
4
|
+
Arparma, At, Match, MultiVar, Option,
|
|
5
|
+
Query, Subcommand, on_alconna, store_true)
|
|
6
|
+
from nonebot_plugin_uninfo import Uninfo
|
|
7
|
+
from nonebot_plugin_waiter import waiter
|
|
8
|
+
|
|
9
|
+
from nonebot import logger
|
|
10
|
+
from zhenxun_utils.message import MessageUtils
|
|
11
|
+
|
|
12
|
+
from .dbService import g_pDBService
|
|
13
|
+
from .farm.farm import g_pFarmManager
|
|
14
|
+
from .farm.shop import g_pShopManager
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
async def isRegisteredByUid(uid: str) -> bool:
|
|
18
|
+
result = await g_pDBService.user.isUserExist(uid)
|
|
19
|
+
|
|
20
|
+
if not result:
|
|
21
|
+
await MessageUtils.build_message("尚未开通农场,快at我发送 开通农场 开通吧").send()
|
|
22
|
+
return False
|
|
23
|
+
|
|
24
|
+
return True
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
diuse_register = on_alconna(
|
|
28
|
+
Alconna("开通农场"),
|
|
29
|
+
priority=5,
|
|
30
|
+
rule=to_me(),
|
|
31
|
+
block=True,
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
@diuse_register.handle()
|
|
35
|
+
async def handle_register(session: Uninfo):
|
|
36
|
+
uid = str(session.user.id)
|
|
37
|
+
user = await g_pDBService.user.getUserInfoByUid(uid)
|
|
38
|
+
|
|
39
|
+
if user:
|
|
40
|
+
await MessageUtils.build_message("🎉 您已经开通农场啦~").send(reply_to=True)
|
|
41
|
+
return
|
|
42
|
+
|
|
43
|
+
try:
|
|
44
|
+
# 获取原始用户名并安全处理
|
|
45
|
+
raw_name = str(session.user.name)
|
|
46
|
+
safe_name = sanitize_username(raw_name)
|
|
47
|
+
|
|
48
|
+
# 初始化用户信息
|
|
49
|
+
success = await g_pDBService.user.initUserInfoByUid(
|
|
50
|
+
uid=uid,
|
|
51
|
+
name=safe_name,
|
|
52
|
+
exp=0,
|
|
53
|
+
point=500
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
msg = (
|
|
57
|
+
"✅ 农场开通成功!\n💼 初始资金:500农场币"
|
|
58
|
+
if success
|
|
59
|
+
else "⚠️ 开通失败,请稍后再试"
|
|
60
|
+
)
|
|
61
|
+
logger.info(f"用户注册 {'成功' if success else '失败'}:{uid}")
|
|
62
|
+
|
|
63
|
+
except Exception as e:
|
|
64
|
+
msg = "⚠️ 系统繁忙,请稍后再试"
|
|
65
|
+
logger.error(f"注册异常 | UID:{uid} | 错误:{str(e)}")
|
|
66
|
+
|
|
67
|
+
await MessageUtils.build_message(msg).send(reply_to=True)
|
|
68
|
+
|
|
69
|
+
def sanitize_username(username: str, max_length: int = 15) -> str:
|
|
70
|
+
"""
|
|
71
|
+
安全处理用户名
|
|
72
|
+
功能:
|
|
73
|
+
1. 移除首尾空白
|
|
74
|
+
2. 过滤危险字符
|
|
75
|
+
3. 转义单引号
|
|
76
|
+
4. 处理空值
|
|
77
|
+
5. 限制长度
|
|
78
|
+
"""
|
|
79
|
+
# 处理空值
|
|
80
|
+
if not username:
|
|
81
|
+
return "神秘农夫"
|
|
82
|
+
|
|
83
|
+
# 基础清洗
|
|
84
|
+
cleaned = username.strip()
|
|
85
|
+
|
|
86
|
+
# 允许的字符白名单(可自定义扩展)
|
|
87
|
+
safe_chars = {
|
|
88
|
+
'_', '-', '!', '@', '#', '$', '%', '^', '&', '*', '(', ')',
|
|
89
|
+
'+', '=', '.', ',', '~', '·', ' ',
|
|
90
|
+
'a','b','c','d','e','f','g','h','i','j','k','l','m',
|
|
91
|
+
'n','o','p','q','r','s','t','u','v','w','x','y','z',
|
|
92
|
+
'A','B','C','D','E','F','G','H','I','J','K','L','M',
|
|
93
|
+
'N','O','P','Q','R','S','T','U','V','W','X','Y','Z',
|
|
94
|
+
'0','1','2','3','4','5','6','7','8','9',
|
|
95
|
+
}
|
|
96
|
+
# 添加常用中文字符(Unicode范围)
|
|
97
|
+
safe_chars.update(chr(c) for c in range(0x4E00, 0x9FFF+1))
|
|
98
|
+
|
|
99
|
+
# 过滤危险字符
|
|
100
|
+
filtered = [
|
|
101
|
+
c if c in safe_chars or 0x4E00 <= ord(c) <= 0x9FFF
|
|
102
|
+
else ''
|
|
103
|
+
for c in cleaned
|
|
104
|
+
]
|
|
105
|
+
|
|
106
|
+
# 合并处理结果
|
|
107
|
+
safe_str = ''.join(filtered)
|
|
108
|
+
|
|
109
|
+
# 转义单引号(双重保障)
|
|
110
|
+
escaped = safe_str.replace("'", "''")
|
|
111
|
+
|
|
112
|
+
# 处理空结果
|
|
113
|
+
if not escaped:
|
|
114
|
+
return "神秘农夫"
|
|
115
|
+
|
|
116
|
+
# 长度限制
|
|
117
|
+
return escaped[:max_length]
|
|
118
|
+
|
|
119
|
+
diuse_farm = on_alconna(
|
|
120
|
+
Alconna(
|
|
121
|
+
"我的农场",
|
|
122
|
+
Option("--all", action=store_true),
|
|
123
|
+
Subcommand("my-point", help_text="我的农场币"),
|
|
124
|
+
Subcommand("seed-shop", Args["num?", int], help_text="种子商店"),
|
|
125
|
+
Subcommand("buy-seed", Args["name?", str]["num?", int], help_text="购买种子"),
|
|
126
|
+
Subcommand("my-seed", help_text="我的种子"),
|
|
127
|
+
Subcommand("sowing", Args["name?", str]["num?", int], help_text="播种"),
|
|
128
|
+
Subcommand("harvest", help_text="收获"),
|
|
129
|
+
Subcommand("eradicate", help_text="铲除"),
|
|
130
|
+
Subcommand("my-plant", help_text="我的作物"),
|
|
131
|
+
Subcommand("sell-plant", Args["name?", str]["num?", int], help_text="出售作物"),
|
|
132
|
+
Subcommand("stealing", Args["target?", At], help_text="偷菜"),
|
|
133
|
+
Subcommand("buy-point", Args["num?", int], help_text="购买农场币"),
|
|
134
|
+
#Subcommand("sell-point", Args["num?", int], help_text="转换金币")
|
|
135
|
+
Subcommand("change-name", Args["name?", str], help_text="更改农场名")
|
|
136
|
+
),
|
|
137
|
+
priority=5,
|
|
138
|
+
block=True,
|
|
139
|
+
)
|
|
140
|
+
|
|
141
|
+
@diuse_farm.assign("$main")
|
|
142
|
+
async def _(session: Uninfo):
|
|
143
|
+
uid = str(session.user.id)
|
|
144
|
+
|
|
145
|
+
if await isRegisteredByUid(uid) == False:
|
|
146
|
+
return
|
|
147
|
+
|
|
148
|
+
image = await g_pFarmManager.drawFarmByUid(uid)
|
|
149
|
+
await MessageUtils.build_message(image).send(reply_to=True)
|
|
150
|
+
|
|
151
|
+
diuse_farm.shortcut(
|
|
152
|
+
"我的农场币",
|
|
153
|
+
command="我的农场",
|
|
154
|
+
arguments=["my-point"],
|
|
155
|
+
prefix=True,
|
|
156
|
+
)
|
|
157
|
+
|
|
158
|
+
@diuse_farm.assign("my-point")
|
|
159
|
+
async def _(session: Uninfo):
|
|
160
|
+
uid = str(session.user.id)
|
|
161
|
+
point = await g_pDBService.user.getUserPointByUid(uid)
|
|
162
|
+
|
|
163
|
+
if point < 0:
|
|
164
|
+
await MessageUtils.build_message("尚未开通农场,快at我发送 开通农场 开通吧").send()
|
|
165
|
+
return False
|
|
166
|
+
|
|
167
|
+
await MessageUtils.build_message(f"你的当前农场币为: {point}").send(reply_to=True)
|
|
168
|
+
|
|
169
|
+
diuse_farm.shortcut(
|
|
170
|
+
"种子商店(.*?)",
|
|
171
|
+
command="我的农场",
|
|
172
|
+
arguments=["seed-shop"],
|
|
173
|
+
prefix=True,
|
|
174
|
+
)
|
|
175
|
+
|
|
176
|
+
@diuse_farm.assign("seed-shop")
|
|
177
|
+
async def _(session: Uninfo, num: Query[int] = AlconnaQuery("num", 1)):
|
|
178
|
+
uid = str(session.user.id)
|
|
179
|
+
|
|
180
|
+
if await isRegisteredByUid(uid) == False:
|
|
181
|
+
return
|
|
182
|
+
|
|
183
|
+
image = await g_pShopManager.getSeedShopImage(num.result)
|
|
184
|
+
await MessageUtils.build_message(image).send()
|
|
185
|
+
|
|
186
|
+
diuse_farm.shortcut(
|
|
187
|
+
"购买种子(?P<name>.*?)",
|
|
188
|
+
command="我的农场",
|
|
189
|
+
arguments=["buy-seed", "{name}"],
|
|
190
|
+
prefix=True,
|
|
191
|
+
)
|
|
192
|
+
|
|
193
|
+
@diuse_farm.assign("buy-seed")
|
|
194
|
+
async def _(session: Uninfo, name: Match[str], num: Query[int] = AlconnaQuery("num", 1),):
|
|
195
|
+
if not name.available:
|
|
196
|
+
await MessageUtils.build_message(
|
|
197
|
+
"请在指令后跟需要购买的种子名称"
|
|
198
|
+
).finish(reply_to=True)
|
|
199
|
+
|
|
200
|
+
uid = str(session.user.id)
|
|
201
|
+
|
|
202
|
+
if await isRegisteredByUid(uid) == False:
|
|
203
|
+
return
|
|
204
|
+
|
|
205
|
+
result = await g_pShopManager.buySeed(uid, name.result, num.result)
|
|
206
|
+
await MessageUtils.build_message(result).send(reply_to=True)
|
|
207
|
+
|
|
208
|
+
diuse_farm.shortcut(
|
|
209
|
+
"我的种子",
|
|
210
|
+
command="我的农场",
|
|
211
|
+
arguments=["my-seed"],
|
|
212
|
+
prefix=True,
|
|
213
|
+
)
|
|
214
|
+
|
|
215
|
+
@diuse_farm.assign("my-seed")
|
|
216
|
+
async def _(session: Uninfo):
|
|
217
|
+
uid = str(session.user.id)
|
|
218
|
+
|
|
219
|
+
if await isRegisteredByUid(uid) == False:
|
|
220
|
+
return
|
|
221
|
+
|
|
222
|
+
result = await g_pFarmManager.getUserSeedByUid(uid)
|
|
223
|
+
await MessageUtils.build_message(result).send(reply_to=True)
|
|
224
|
+
|
|
225
|
+
diuse_farm.shortcut(
|
|
226
|
+
"播种(?P<name>.*?)",
|
|
227
|
+
command="我的农场",
|
|
228
|
+
arguments=["sowing", "{name}"],
|
|
229
|
+
prefix=True,
|
|
230
|
+
)
|
|
231
|
+
|
|
232
|
+
@diuse_farm.assign("sowing")
|
|
233
|
+
async def _(session: Uninfo, name: Match[str], num: Query[int] = AlconnaQuery("num", -1),):
|
|
234
|
+
if not name.available:
|
|
235
|
+
await MessageUtils.build_message(
|
|
236
|
+
"请在指令后跟需要播种的种子名称"
|
|
237
|
+
).finish(reply_to=True)
|
|
238
|
+
|
|
239
|
+
uid = str(session.user.id)
|
|
240
|
+
|
|
241
|
+
if await isRegisteredByUid(uid) == False:
|
|
242
|
+
return
|
|
243
|
+
|
|
244
|
+
result = await g_pFarmManager.sowing(uid, name.result, num.result)
|
|
245
|
+
await MessageUtils.build_message(result).send(reply_to=True)
|
|
246
|
+
|
|
247
|
+
|
|
248
|
+
diuse_farm.shortcut(
|
|
249
|
+
"收获",
|
|
250
|
+
command="我的农场",
|
|
251
|
+
arguments=["harvest"],
|
|
252
|
+
prefix=True,
|
|
253
|
+
)
|
|
254
|
+
|
|
255
|
+
@diuse_farm.assign("harvest")
|
|
256
|
+
async def _(session: Uninfo):
|
|
257
|
+
uid = str(session.user.id)
|
|
258
|
+
|
|
259
|
+
if await isRegisteredByUid(uid) == False:
|
|
260
|
+
return
|
|
261
|
+
|
|
262
|
+
result = await g_pFarmManager.harvest(uid)
|
|
263
|
+
await MessageUtils.build_message(result).send(reply_to=True)
|
|
264
|
+
|
|
265
|
+
diuse_farm.shortcut(
|
|
266
|
+
"铲除",
|
|
267
|
+
command="我的农场",
|
|
268
|
+
arguments=["eradicate"],
|
|
269
|
+
prefix=True,
|
|
270
|
+
)
|
|
271
|
+
|
|
272
|
+
@diuse_farm.assign("eradicate")
|
|
273
|
+
async def _(session: Uninfo):
|
|
274
|
+
uid = str(session.user.id)
|
|
275
|
+
|
|
276
|
+
if await isRegisteredByUid(uid) == False:
|
|
277
|
+
return
|
|
278
|
+
|
|
279
|
+
result = await g_pFarmManager.eradicate(uid)
|
|
280
|
+
await MessageUtils.build_message(result).send(reply_to=True)
|
|
281
|
+
|
|
282
|
+
|
|
283
|
+
diuse_farm.shortcut(
|
|
284
|
+
"我的作物",
|
|
285
|
+
command="我的农场",
|
|
286
|
+
arguments=["my-plant"],
|
|
287
|
+
prefix=True,
|
|
288
|
+
)
|
|
289
|
+
|
|
290
|
+
@diuse_farm.assign("my-plant")
|
|
291
|
+
async def _(session: Uninfo):
|
|
292
|
+
uid = str(session.user.id)
|
|
293
|
+
|
|
294
|
+
if await isRegisteredByUid(uid) == False:
|
|
295
|
+
return
|
|
296
|
+
|
|
297
|
+
result = await g_pFarmManager.getUserPlantByUid(uid)
|
|
298
|
+
await MessageUtils.build_message(result).send(reply_to=True)
|
|
299
|
+
|
|
300
|
+
|
|
301
|
+
reclamation = on_alconna(
|
|
302
|
+
Alconna("开垦"),
|
|
303
|
+
priority=5,
|
|
304
|
+
block=True,
|
|
305
|
+
)
|
|
306
|
+
|
|
307
|
+
@reclamation.handle()
|
|
308
|
+
async def _(session: Uninfo):
|
|
309
|
+
uid = str(session.user.id)
|
|
310
|
+
|
|
311
|
+
if await isRegisteredByUid(uid) == False:
|
|
312
|
+
return
|
|
313
|
+
|
|
314
|
+
condition = await g_pFarmManager.reclamationCondition(uid)
|
|
315
|
+
condition += "\n 回复是将执行开垦"
|
|
316
|
+
await MessageUtils.build_message(condition).send(reply_to=True)
|
|
317
|
+
|
|
318
|
+
@waiter(waits=["message"], keep_session=True)
|
|
319
|
+
async def check(event: Event):
|
|
320
|
+
return event.get_plaintext()
|
|
321
|
+
|
|
322
|
+
resp = await check.wait(timeout=60)
|
|
323
|
+
if resp is None:
|
|
324
|
+
await MessageUtils.build_message("等待超时").send(reply_to=True)
|
|
325
|
+
return
|
|
326
|
+
if not resp == "是":
|
|
327
|
+
return
|
|
328
|
+
|
|
329
|
+
res = await g_pFarmManager.reclamation(uid)
|
|
330
|
+
await MessageUtils.build_message(res).send(reply_to=True)
|
|
331
|
+
|
|
332
|
+
diuse_farm.shortcut(
|
|
333
|
+
"出售作物(?P<name>.*?)",
|
|
334
|
+
command="我的农场",
|
|
335
|
+
arguments=["sell-plant", "{name}"],
|
|
336
|
+
prefix=True,
|
|
337
|
+
)
|
|
338
|
+
|
|
339
|
+
@diuse_farm.assign("sell-plant")
|
|
340
|
+
async def _(session: Uninfo, name: Match[str], num: Query[int] = AlconnaQuery("num", -1),):
|
|
341
|
+
uid = str(session.user.id)
|
|
342
|
+
|
|
343
|
+
if await isRegisteredByUid(uid) == False:
|
|
344
|
+
return
|
|
345
|
+
|
|
346
|
+
result = await g_pShopManager.sellPlantByUid(uid, name.result, num.result)
|
|
347
|
+
await MessageUtils.build_message(result).send(reply_to=True)
|
|
348
|
+
|
|
349
|
+
diuse_farm.shortcut(
|
|
350
|
+
"偷菜",
|
|
351
|
+
command="我的农场",
|
|
352
|
+
arguments=["stealing"],
|
|
353
|
+
prefix=True,
|
|
354
|
+
)
|
|
355
|
+
|
|
356
|
+
@diuse_farm.assign("stealing")
|
|
357
|
+
async def _(session: Uninfo, target: Match[At]):
|
|
358
|
+
uid = str(session.user.id)
|
|
359
|
+
|
|
360
|
+
if await isRegisteredByUid(uid) == False:
|
|
361
|
+
return
|
|
362
|
+
|
|
363
|
+
if not target.available:
|
|
364
|
+
await MessageUtils.build_message("请在指令后跟需要at的人").finish(reply_to=True)
|
|
365
|
+
|
|
366
|
+
tar = target.result
|
|
367
|
+
result = await g_pDBService.user.isUserExist(tar.target)
|
|
368
|
+
|
|
369
|
+
if not result:
|
|
370
|
+
await MessageUtils.build_message("目标尚未开通农场,快邀请ta开通吧").send()
|
|
371
|
+
return None
|
|
372
|
+
|
|
373
|
+
result = await g_pFarmManager.stealing(uid, tar.target)
|
|
374
|
+
await MessageUtils.build_message(result).send(reply_to=True)
|
|
375
|
+
|
|
376
|
+
diuse_farm.shortcut(
|
|
377
|
+
"购买农场币(.*?)",
|
|
378
|
+
command="我的农场",
|
|
379
|
+
arguments=["buy-point"],
|
|
380
|
+
prefix=True,
|
|
381
|
+
)
|
|
382
|
+
|
|
383
|
+
@diuse_farm.assign("buy-point")
|
|
384
|
+
async def _(session: Uninfo, num: Query[int] = AlconnaQuery("num", 0)):
|
|
385
|
+
if num.result <= 0:
|
|
386
|
+
await MessageUtils.build_message(
|
|
387
|
+
"请在指令后跟需要购买农场币的数量"
|
|
388
|
+
).finish(reply_to=True)
|
|
389
|
+
|
|
390
|
+
uid = str(session.user.id)
|
|
391
|
+
|
|
392
|
+
if await isRegisteredByUid(uid) == False:
|
|
393
|
+
return
|
|
394
|
+
|
|
395
|
+
result = await g_pFarmManager.buyPointByUid(uid, num.result)
|
|
396
|
+
await MessageUtils.build_message(result).send(reply_to=True)
|
|
397
|
+
|
|
398
|
+
|
|
399
|
+
diuse_farm.shortcut(
|
|
400
|
+
"更改农场名(?P<name>)",
|
|
401
|
+
command="我的农场",
|
|
402
|
+
arguments=["change-name", "{name}"],
|
|
403
|
+
prefix=True,
|
|
404
|
+
)
|
|
405
|
+
|
|
406
|
+
@diuse_farm.assign("change-name")
|
|
407
|
+
async def _(session: Uninfo, name: Match[str]):
|
|
408
|
+
if not name.available:
|
|
409
|
+
await MessageUtils.build_message(
|
|
410
|
+
"请在指令后跟需要更改的用户名"
|
|
411
|
+
).finish(reply_to=True)
|
|
412
|
+
|
|
413
|
+
uid = str(session.user.id)
|
|
414
|
+
|
|
415
|
+
if await isRegisteredByUid(uid) == False:
|
|
416
|
+
return
|
|
417
|
+
|
|
418
|
+
safeName = sanitize_username(name.result)
|
|
419
|
+
|
|
420
|
+
result = await g_pDBService.user.updateUserNameByUid(uid, safeName)
|
|
421
|
+
|
|
422
|
+
if result == True:
|
|
423
|
+
await MessageUtils.build_message("更新用户名成功!").send(reply_to=True)
|
|
424
|
+
else:
|
|
425
|
+
await MessageUtils.build_message("更新用户名失败!").send(reply_to=True)
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 0.01,
|
|
3
|
+
"zhuShi":
|
|
4
|
+
[
|
|
5
|
+
"name: 名称",
|
|
6
|
+
"level: 等级",
|
|
7
|
+
"price: 单价",
|
|
8
|
+
"icon: 显示图片",
|
|
9
|
+
"sell: 是否可以上架交易行"
|
|
10
|
+
],
|
|
11
|
+
"item":
|
|
12
|
+
{
|
|
13
|
+
"muBan":
|
|
14
|
+
{
|
|
15
|
+
"name": "木板",
|
|
16
|
+
"level": 0,
|
|
17
|
+
"price": 5000,
|
|
18
|
+
"icon": "Test",
|
|
19
|
+
"sell": true
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 0.01,
|
|
3
|
+
"soil":[1, 1, 1, 2, 3, 5, 7, 9, 11, 13,
|
|
4
|
+
15, 17, 19, 21, 23, 25, 27, 29, 31, 33,
|
|
5
|
+
36, 39, 42, 45, 48, 51, 54, 57, 60, 70
|
|
6
|
+
],
|
|
7
|
+
"reclamation":
|
|
8
|
+
{
|
|
9
|
+
"4":
|
|
10
|
+
{
|
|
11
|
+
"level": 2,
|
|
12
|
+
"point": 800,
|
|
13
|
+
"item": []
|
|
14
|
+
},
|
|
15
|
+
"5":
|
|
16
|
+
{
|
|
17
|
+
"level": 3,
|
|
18
|
+
"point": 1300,
|
|
19
|
+
"item": []
|
|
20
|
+
},
|
|
21
|
+
"6":
|
|
22
|
+
{
|
|
23
|
+
"level": 5,
|
|
24
|
+
"point": 3200,
|
|
25
|
+
"item": []
|
|
26
|
+
},
|
|
27
|
+
"7":
|
|
28
|
+
{
|
|
29
|
+
"level": 7,
|
|
30
|
+
"point": 5500,
|
|
31
|
+
"item": []
|
|
32
|
+
},
|
|
33
|
+
"8":
|
|
34
|
+
{
|
|
35
|
+
"level": 9,
|
|
36
|
+
"point": 12000,
|
|
37
|
+
"item": []
|
|
38
|
+
},
|
|
39
|
+
"9":
|
|
40
|
+
{
|
|
41
|
+
"level": 11,
|
|
42
|
+
"point": 19800,
|
|
43
|
+
"item": []
|
|
44
|
+
},
|
|
45
|
+
"10":
|
|
46
|
+
{
|
|
47
|
+
"level": 13,
|
|
48
|
+
"point": 30000,
|
|
49
|
+
"item": []
|
|
50
|
+
},
|
|
51
|
+
"11":
|
|
52
|
+
{
|
|
53
|
+
"level": 15,
|
|
54
|
+
"point": 50000,
|
|
55
|
+
"item": []
|
|
56
|
+
},
|
|
57
|
+
"12":
|
|
58
|
+
{
|
|
59
|
+
"level": 17,
|
|
60
|
+
"point": 70000,
|
|
61
|
+
"item": []
|
|
62
|
+
},
|
|
63
|
+
"13":
|
|
64
|
+
{
|
|
65
|
+
"level": 19,
|
|
66
|
+
"point": 90000,
|
|
67
|
+
"item": []
|
|
68
|
+
},
|
|
69
|
+
"14":
|
|
70
|
+
{
|
|
71
|
+
"level": 21,
|
|
72
|
+
"point": 130000,
|
|
73
|
+
"item": []
|
|
74
|
+
},
|
|
75
|
+
"15":
|
|
76
|
+
{
|
|
77
|
+
"level": 23,
|
|
78
|
+
"point": 150000,
|
|
79
|
+
"item": []
|
|
80
|
+
},
|
|
81
|
+
"16":
|
|
82
|
+
{
|
|
83
|
+
"level": 25,
|
|
84
|
+
"point": 180000,
|
|
85
|
+
"item": []
|
|
86
|
+
},
|
|
87
|
+
"17":
|
|
88
|
+
{
|
|
89
|
+
"level": 27,
|
|
90
|
+
"point": 230000,
|
|
91
|
+
"item": []
|
|
92
|
+
},
|
|
93
|
+
"18":
|
|
94
|
+
{
|
|
95
|
+
"level": 29,
|
|
96
|
+
"point": 300000,
|
|
97
|
+
"item": []
|
|
98
|
+
},
|
|
99
|
+
"19":
|
|
100
|
+
{
|
|
101
|
+
"level": 31,
|
|
102
|
+
"point": 500000,
|
|
103
|
+
"item": []
|
|
104
|
+
},
|
|
105
|
+
"20":
|
|
106
|
+
{
|
|
107
|
+
"level": 33,
|
|
108
|
+
"point": 850000,
|
|
109
|
+
"item": []
|
|
110
|
+
},
|
|
111
|
+
"21":
|
|
112
|
+
{
|
|
113
|
+
"level": 36,
|
|
114
|
+
"point": 1100000,
|
|
115
|
+
"item": []
|
|
116
|
+
},
|
|
117
|
+
"22":
|
|
118
|
+
{
|
|
119
|
+
"level": 39,
|
|
120
|
+
"point": 1300000,
|
|
121
|
+
"item": []
|
|
122
|
+
},
|
|
123
|
+
"23":
|
|
124
|
+
{
|
|
125
|
+
"level": 42,
|
|
126
|
+
"point": 1500000,
|
|
127
|
+
"item": []
|
|
128
|
+
},
|
|
129
|
+
"24":
|
|
130
|
+
{
|
|
131
|
+
"level": 45,
|
|
132
|
+
"point": 1700000,
|
|
133
|
+
"item": []
|
|
134
|
+
},
|
|
135
|
+
"25":
|
|
136
|
+
{
|
|
137
|
+
"level": 48,
|
|
138
|
+
"point": 2000000,
|
|
139
|
+
"item": []
|
|
140
|
+
},
|
|
141
|
+
"26":
|
|
142
|
+
{
|
|
143
|
+
"level": 51,
|
|
144
|
+
"point": 2200000,
|
|
145
|
+
"item": []
|
|
146
|
+
},
|
|
147
|
+
"27":
|
|
148
|
+
{
|
|
149
|
+
"level": 54,
|
|
150
|
+
"point": 2800000,
|
|
151
|
+
"item": []
|
|
152
|
+
},
|
|
153
|
+
"28":
|
|
154
|
+
{
|
|
155
|
+
"level": 57,
|
|
156
|
+
"point": 3500000,
|
|
157
|
+
"item": []
|
|
158
|
+
},
|
|
159
|
+
"29":
|
|
160
|
+
{
|
|
161
|
+
"level": 60,
|
|
162
|
+
"point": 4300000,
|
|
163
|
+
"item": []
|
|
164
|
+
},
|
|
165
|
+
"30":
|
|
166
|
+
{
|
|
167
|
+
"level": 70,
|
|
168
|
+
"point": 5200000,
|
|
169
|
+
"item": []
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|