nonebot-plugin-fishing2 0.0.2__py3-none-any.whl → 0.0.4__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 +339 -106
- nonebot_plugin_fishing2/config.py +163 -39
- nonebot_plugin_fishing2/data_source.py +415 -311
- nonebot_plugin_fishing2/fish_helper.py +157 -0
- nonebot_plugin_fishing2-0.0.4.dist-info/METADATA +168 -0
- {nonebot_plugin_fishing2-0.0.2.dist-info → nonebot_plugin_fishing2-0.0.4.dist-info}/RECORD +9 -8
- {nonebot_plugin_fishing2-0.0.2.dist-info → nonebot_plugin_fishing2-0.0.4.dist-info}/licenses/LICENSE +1 -1
- nonebot_plugin_fishing2-0.0.2.dist-info/METADATA +0 -144
- {nonebot_plugin_fishing2-0.0.2.dist-info → nonebot_plugin_fishing2-0.0.4.dist-info}/WHEEL +0 -0
- {nonebot_plugin_fishing2-0.0.2.dist-info → nonebot_plugin_fishing2-0.0.4.dist-info}/top_level.txt +0 -0
@@ -1,24 +1,28 @@
|
|
1
|
-
from nonebot import
|
1
|
+
from nonebot import require
|
2
2
|
|
3
3
|
require("nonebot_plugin_orm") # noqa
|
4
4
|
|
5
|
-
|
5
|
+
import shlex
|
6
|
+
from typing import Union
|
7
|
+
|
8
|
+
from nonebot import on_command, logger
|
6
9
|
from nonebot.plugin import PluginMetadata
|
7
10
|
from nonebot.adapters import Event, Message
|
8
11
|
from nonebot.params import CommandArg
|
9
|
-
from nonebot.permission import SUPERUSER
|
10
12
|
from nonebot.matcher import Matcher
|
11
13
|
|
12
|
-
from nonebot.adapters.onebot.v11 import
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
14
|
+
from nonebot.adapters.onebot.v11 import (
|
15
|
+
Bot,
|
16
|
+
GroupMessageEvent,
|
17
|
+
PrivateMessageEvent,
|
18
|
+
Message,
|
19
|
+
MessageSegment,
|
20
|
+
ActionFailed,
|
21
|
+
)
|
17
22
|
|
18
23
|
from .config import Config, config
|
19
24
|
from .data_source import (
|
20
25
|
can_fishing,
|
21
|
-
can_free_fish,
|
22
26
|
get_fish,
|
23
27
|
get_stats,
|
24
28
|
get_backpack,
|
@@ -31,50 +35,65 @@ from .data_source import (
|
|
31
35
|
get_achievements,
|
32
36
|
get_board,
|
33
37
|
check_tools,
|
34
|
-
remove_tools
|
38
|
+
remove_tools,
|
39
|
+
get_shop,
|
40
|
+
buy_fish,
|
41
|
+
predict,
|
42
|
+
get_all_special_fish,
|
35
43
|
)
|
44
|
+
from .fish_helper import fish_list, get_fish_by_name
|
36
45
|
|
37
46
|
fishing_coin_name = config.fishing_coin_name
|
38
47
|
|
39
48
|
__plugin_meta__ = PluginMetadata(
|
40
|
-
name="
|
41
|
-
description="
|
42
|
-
usage=f
|
43
|
-
▶ 查询 [物品]:
|
49
|
+
name="更好的电子钓鱼",
|
50
|
+
description="赛博钓鱼……但是加强版本",
|
51
|
+
usage=f"""▶ 查询 [物品]:查询某个物品的信息
|
44
52
|
▶ 钓鱼 [鱼竿] [鱼饵]:
|
45
|
-
▷ 有 {config.fishing_limit}s
|
46
|
-
▷
|
53
|
+
▷ 有 {config.fishing_limit}s 的冷却
|
54
|
+
▷ {config.no_fish_probability} 概率空军,{config.special_fish_probability} 概率掉到特殊鱼
|
55
|
+
▷ 加参数可以使用鱼饵或鱼竿,同类物品同时只能使用一种
|
47
56
|
▷ 频繁钓鱼会触怒河神
|
48
57
|
▶ 出售 <物品> <数量>:出售物品获得{fishing_coin_name}
|
49
|
-
|
58
|
+
▷ 如果卖不出去,尝试用英文双引号框住鱼名
|
59
|
+
▶ 购买 <物品> <份数>:购买渔具店的物品
|
50
60
|
▶ 放生 <鱼名>:给一条鱼取名并放生
|
61
|
+
▷ 不要放生奇怪名字的鱼
|
62
|
+
▶ 商店:看看渔具店都有些啥
|
51
63
|
▶ 祈愿:向神祈愿,随机获取/损失{fishing_coin_name}
|
52
64
|
▶ 背包:查看背包中的{fishing_coin_name}与物品
|
53
65
|
▶ 成就:查看拥有的成就
|
54
66
|
▶ 钓鱼排行榜:查看{fishing_coin_name}排行榜
|
55
|
-
|
67
|
+
""",
|
56
68
|
type="application",
|
57
69
|
homepage="https://github.com/FDCraft/nonebot-plugin-fishing2",
|
58
70
|
config=Config,
|
59
|
-
supported_adapters=
|
71
|
+
supported_adapters={"~onebot.v11"},
|
72
|
+
extra={"author": "Polaris_Light", "version": "0.0.4", "priority": 5},
|
60
73
|
)
|
61
74
|
|
62
75
|
|
63
|
-
|
64
76
|
block_user_list = []
|
65
77
|
punish_user_dict = {}
|
66
78
|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
79
|
+
# fmt:off
|
80
|
+
fishing_help = on_command("fishing_help", aliases={"钓鱼帮助"}, force_whitespace=True, priority=3, block=True)
|
81
|
+
fishing_lookup = on_command("fishing_lookup",aliases={"查看", "查询"},force_whitespace=True,priority=3,block=True,)
|
82
|
+
fishing = on_command("fishing", aliases={"钓鱼"}, force_whitespace=True, priority=5)
|
83
|
+
backpack = on_command("backpack", aliases={"背包", "钓鱼背包"}, force_whitespace=True, priority=5)
|
84
|
+
shop = on_command("shop", aliases={"商店"}, force_whitespace=True, priority=5)
|
85
|
+
buy = on_command("buy", aliases={"购买"}, force_whitespace=True, priority=5)
|
86
|
+
sell = on_command("sell", aliases={"卖鱼", "出售", "售卖"}, force_whitespace=True, priority=5)
|
87
|
+
free_fish_cmd = on_command("free_fish", aliases={"放生", "钓鱼放生"}, force_whitespace=True, priority=5)
|
88
|
+
lottery_cmd = on_command("lottery", aliases={"祈愿"}, force_whitespace=True, priority=5)
|
89
|
+
achievement_cmd = on_command("achievement", aliases={"成就", "钓鱼成就"}, force_whitespace=True, priority=5)
|
90
|
+
give_cmd = on_command("give", aliases={"赐予"}, force_whitespace=True, priority=5)
|
91
|
+
board_cmd = on_command("board", aliases={"排行榜", "钓鱼排行榜"}, force_whitespace=True, priority=5)
|
92
|
+
|
93
|
+
# hidden cmd
|
94
|
+
predict_cmd = on_command("predict", aliases={"钓鱼预测"}, force_whitespace=True, priority=5)
|
95
|
+
pool_cmd = on_command("pool", aliases={"鱼池"}, force_whitespace=True, priority=5)
|
96
|
+
# fmt:on
|
78
97
|
|
79
98
|
|
80
99
|
@fishing_help.handle()
|
@@ -82,55 +101,60 @@ async def _():
|
|
82
101
|
await fishing_help.finish(__plugin_meta__.usage)
|
83
102
|
|
84
103
|
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
punish_user_dict[user_id] += 1
|
91
|
-
except KeyError:
|
92
|
-
punish_user_dict[user_id] = 1
|
104
|
+
@shop.handle()
|
105
|
+
async def _(bot: Bot, event: Union[GroupMessageEvent, PrivateMessageEvent]):
|
106
|
+
messages = get_shop()
|
107
|
+
await forward_send(bot, event, messages)
|
108
|
+
return None
|
93
109
|
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
110
|
+
|
111
|
+
@fishing_lookup.handle()
|
112
|
+
async def _(
|
113
|
+
bot: Bot,
|
114
|
+
event: Union[GroupMessageEvent, PrivateMessageEvent],
|
115
|
+
arg: Message = CommandArg(),
|
116
|
+
):
|
117
|
+
user_id = event.get_user_id()
|
118
|
+
arg = arg.extract_plain_text()
|
119
|
+
if not arg or arg == "":
|
120
|
+
await fishing_lookup.finish(
|
121
|
+
"请输入要查询的物品\n可查询物品:" + "、".join(fish_list)
|
122
|
+
)
|
123
|
+
if arg == "空军":
|
124
|
+
await fishing_lookup.finish(
|
125
|
+
MessageSegment.at(user_id)
|
126
|
+
+ " 在钓鱼活动中,空军指钓鱼者一无所获,没有钓到任何鱼,空手而归。"
|
127
|
+
)
|
128
|
+
elif arg not in fish_list:
|
129
|
+
await fishing_lookup.finish(MessageSegment.at(user_id) + " 查无此鱼。")
|
130
|
+
await forward_send(bot, event, get_fish_by_name(arg).print_info())
|
131
|
+
return None
|
107
132
|
|
108
133
|
|
109
134
|
@fishing.handle()
|
110
|
-
async def _(bot:Bot, event: Event, matcher: Matcher, arg: Message = CommandArg()):
|
135
|
+
async def _(bot: Bot, event: Event, matcher: Matcher, arg: Message = CommandArg()):
|
111
136
|
user_id = event.get_user_id()
|
112
137
|
if user_id in block_user_list:
|
113
138
|
await fishing.finish()
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
logger.debug(f"
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
139
|
+
|
140
|
+
tools = shlex.split((arg.extract_plain_text()))[:2]
|
141
|
+
|
142
|
+
logger.debug(f"Fishing: {user_id} try to use {tools}")
|
143
|
+
|
144
|
+
check_result = await check_tools(user_id, tools)
|
145
|
+
if check_result:
|
146
|
+
await fishing.finish(MessageSegment.at(user_id) + " " + check_result)
|
147
|
+
|
124
148
|
await punish(bot, event, matcher, user_id)
|
125
149
|
block_user_list.append(user_id)
|
126
150
|
try:
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
151
|
+
await remove_tools(user_id, tools)
|
152
|
+
await fishing.send(
|
153
|
+
MessageSegment.at(user_id) + f'\n你使用了{"、".join(tools)}\n'
|
154
|
+
if tools != []
|
155
|
+
else "" + "正在钓鱼…"
|
156
|
+
)
|
157
|
+
result = await get_fish(user_id, tools)
|
134
158
|
achievements = await check_achievement(user_id)
|
135
159
|
if achievements is not None:
|
136
160
|
for achievement in achievements:
|
@@ -143,46 +167,157 @@ async def _(bot:Bot, event: Event, matcher: Matcher, arg: Message = CommandArg()
|
|
143
167
|
await fishing.finish(MessageSegment.at(user_id) + " " + result)
|
144
168
|
|
145
169
|
|
170
|
+
@predict_cmd.handle()
|
171
|
+
async def _(
|
172
|
+
bot: Bot,
|
173
|
+
event: Union[GroupMessageEvent, PrivateMessageEvent],
|
174
|
+
arg: Message = CommandArg(),
|
175
|
+
):
|
176
|
+
user_id = event.get_user_id()
|
177
|
+
|
178
|
+
is_superuser = str(user_id) in bot.config.superusers
|
179
|
+
is_self = event.self_id == user_id
|
180
|
+
if not is_superuser and not is_self:
|
181
|
+
return None
|
182
|
+
|
183
|
+
tools = shlex.split(arg.extract_plain_text())[:2]
|
184
|
+
|
185
|
+
tools = [x for x in tools if x != ""]
|
186
|
+
|
187
|
+
check_result = await check_tools(user_id, tools, check_have=False)
|
188
|
+
if check_result:
|
189
|
+
await predict_cmd.finish(MessageSegment.at(user_id) + " " + check_result)
|
190
|
+
result = predict(tools)
|
191
|
+
await predict_cmd.finish(result)
|
192
|
+
|
193
|
+
|
194
|
+
@pool_cmd.handle()
|
195
|
+
async def _(bot: Bot, event: Union[GroupMessageEvent, PrivateMessageEvent]):
|
196
|
+
user_id = event.get_user_id()
|
197
|
+
is_superuser = str(user_id) in bot.config.superusers
|
198
|
+
is_self = event.self_id == user_id
|
199
|
+
if not is_superuser and not is_self:
|
200
|
+
return None
|
201
|
+
|
202
|
+
message: list[MessageSegment] = []
|
203
|
+
pool = await get_all_special_fish()
|
204
|
+
message.append(MessageSegment.text(f"现在鱼池里面有 {len(pool)} 条鱼。"))
|
205
|
+
|
206
|
+
result = dict()
|
207
|
+
for fish in pool:
|
208
|
+
try:
|
209
|
+
result[fish] += 1
|
210
|
+
except KeyError:
|
211
|
+
result[fish] = 1
|
212
|
+
|
213
|
+
msg = "鱼池列表:\n"
|
214
|
+
for fish, num in result.items():
|
215
|
+
if len(msg) > 300:
|
216
|
+
msg += f"{fish} x {num}"
|
217
|
+
message.append(MessageSegment.text(msg))
|
218
|
+
msg = ""
|
219
|
+
else:
|
220
|
+
msg += f"{fish} x {num}\n"
|
221
|
+
else:
|
222
|
+
message.append(MessageSegment.text(msg))
|
223
|
+
|
224
|
+
await forward_send(bot, event, message)
|
225
|
+
return None
|
226
|
+
|
227
|
+
|
146
228
|
@backpack.handle()
|
147
|
-
async def _(event:
|
229
|
+
async def _(bot: Bot, event: Union[GroupMessageEvent, PrivateMessageEvent]):
|
148
230
|
user_id = event.get_user_id()
|
149
|
-
|
231
|
+
if not config.backpack_forward:
|
232
|
+
await backpack.finish(
|
233
|
+
MessageSegment.at(user_id)
|
234
|
+
+ " \n"
|
235
|
+
+ await get_stats(user_id)
|
236
|
+
+ "\n"
|
237
|
+
+ await get_balance(user_id)
|
238
|
+
+ "\n"
|
239
|
+
+ "\n\n".join(await get_backpack(user_id))
|
240
|
+
)
|
241
|
+
else:
|
242
|
+
message: list[MessageSegment] = []
|
243
|
+
message.append(MessageSegment.at(user_id))
|
244
|
+
message.append(await get_stats(user_id))
|
245
|
+
message.append(await get_balance(user_id))
|
246
|
+
backpacks = await get_backpack(user_id)
|
247
|
+
message += [MessageSegment.text(msg) for msg in backpacks]
|
248
|
+
await forward_send(bot, event, message)
|
249
|
+
|
150
250
|
|
151
251
|
@buy.handle()
|
152
252
|
async def _(event: Event, arg: Message = CommandArg()):
|
153
|
-
|
253
|
+
args = arg.extract_plain_text().split(" ")
|
254
|
+
args = [x for x in args if x != ""]
|
255
|
+
|
154
256
|
user_id = event.get_user_id()
|
155
|
-
if
|
156
|
-
await buy.finish(
|
157
|
-
|
158
|
-
|
257
|
+
if args == []:
|
258
|
+
await buy.finish(
|
259
|
+
MessageSegment.at(user_id)
|
260
|
+
+ " "
|
261
|
+
+ "请输入要买入物品的名字和份数 (份数为1时可省略), 如 /购买 钛金鱼竿 1"
|
262
|
+
)
|
263
|
+
if len(args) == 1:
|
264
|
+
fish_name = args[0]
|
265
|
+
result = await buy_fish(user_id, fish_name)
|
159
266
|
else:
|
160
|
-
fish_name, fish_quantity =
|
161
|
-
|
267
|
+
fish_name, fish_quantity = args[0], args[1]
|
268
|
+
result = await buy_fish(user_id, fish_name, int(fish_quantity))
|
269
|
+
achievements = await check_achievement(user_id)
|
270
|
+
if achievements is not None:
|
271
|
+
for achievement in achievements:
|
272
|
+
await fishing.send(achievement)
|
273
|
+
await buy.finish(MessageSegment.at(user_id) + " " + result)
|
162
274
|
|
163
275
|
|
164
276
|
@sell.handle()
|
165
277
|
async def _(event: Event, arg: Message = CommandArg()):
|
166
|
-
|
278
|
+
args = shlex.split(arg.extract_plain_text())
|
279
|
+
|
167
280
|
user_id = event.get_user_id()
|
168
|
-
if
|
169
|
-
await sell.finish(
|
170
|
-
|
171
|
-
|
281
|
+
if args == []:
|
282
|
+
await sell.finish(
|
283
|
+
MessageSegment.at(user_id)
|
284
|
+
+ " "
|
285
|
+
+ "请输入要卖出的鱼的名字和数量 (数量为1时可省略), 如 /卖鱼 小鱼 1"
|
286
|
+
)
|
287
|
+
if len(args) == 1:
|
288
|
+
fish_name = args[0]
|
289
|
+
await sell.finish(
|
290
|
+
MessageSegment.at(user_id) + " " + await sell_fish(user_id, fish_name)
|
291
|
+
)
|
172
292
|
else:
|
173
|
-
fish_name, fish_quantity =
|
174
|
-
|
293
|
+
fish_name, fish_quantity = args[0], args[1]
|
294
|
+
result = await sell_fish(user_id, fish_name, int(fish_quantity))
|
295
|
+
await sell.finish(MessageSegment.at(user_id) + " " + result)
|
175
296
|
|
176
297
|
|
177
298
|
@free_fish_cmd.handle()
|
178
|
-
async def _(event: Event, arg: Message = CommandArg()):
|
179
|
-
if not
|
299
|
+
async def _(bot: Bot, event: Event, arg: Message = CommandArg()):
|
300
|
+
if not config.special_fish_enabled:
|
180
301
|
await free_fish_cmd.finish("未开启此功能, 请联系机器人管理员")
|
302
|
+
|
181
303
|
fish_name = arg.extract_plain_text()
|
182
304
|
user_id = event.get_user_id()
|
305
|
+
|
306
|
+
if '"' in fish_name:
|
307
|
+
if isinstance(event, GroupMessageEvent):
|
308
|
+
group_id = event.group_id
|
309
|
+
await bot.set_group_ban(group_id=group_id, user_id=user_id, duration=1800)
|
310
|
+
await free_fish_cmd.finish(
|
311
|
+
MessageSegment.at(user_id) + " " + "你 TM 在放生什么?滚滚滚"
|
312
|
+
)
|
313
|
+
|
183
314
|
if fish_name == "":
|
184
|
-
await free_fish_cmd.finish(
|
185
|
-
|
315
|
+
await free_fish_cmd.finish(
|
316
|
+
MessageSegment.at(user_id) + " " + "请输入要放生的鱼的名字, 如 /放生 测试鱼"
|
317
|
+
)
|
318
|
+
await free_fish_cmd.finish(
|
319
|
+
MessageSegment.at(user_id) + " " + await free_fish(user_id, fish_name)
|
320
|
+
)
|
186
321
|
|
187
322
|
|
188
323
|
@lottery_cmd.handle()
|
@@ -201,40 +336,138 @@ async def _(bot: Bot, event: Event, matcher: Matcher):
|
|
201
336
|
@achievement_cmd.handle()
|
202
337
|
async def _(event: Event):
|
203
338
|
user_id = event.get_user_id()
|
204
|
-
await achievement_cmd.finish(
|
339
|
+
await achievement_cmd.finish(
|
340
|
+
MessageSegment.at(user_id) + " " + await get_achievements(user_id)
|
341
|
+
)
|
205
342
|
|
206
343
|
|
207
344
|
@give_cmd.handle()
|
208
|
-
async def _(
|
209
|
-
|
345
|
+
async def _(
|
346
|
+
bot: Bot,
|
347
|
+
event: Union[GroupMessageEvent, PrivateMessageEvent],
|
348
|
+
arg: Message = CommandArg(),
|
349
|
+
):
|
350
|
+
is_superuser = str(event.user_id) in bot.config.superusers
|
351
|
+
is_self = event.self_id == event.user_id
|
352
|
+
if not is_superuser and not is_self:
|
353
|
+
return None
|
354
|
+
|
355
|
+
target = await get_at(event)
|
356
|
+
args = shlex.split(arg.extract_plain_text())
|
357
|
+
if target:
|
358
|
+
args.insert(0, target)
|
210
359
|
if len(args) < 2 or len(args) > 3:
|
211
|
-
await give_cmd.finish(
|
360
|
+
await give_cmd.finish(
|
361
|
+
"请输入用户的 id 和鱼的名字和数量 (数量为1时可省略), 如 /give 114514 开发鱼 1"
|
362
|
+
)
|
212
363
|
else:
|
213
|
-
print(f"PLDEBUG1: {args}")
|
214
364
|
quantity = int(args[2]) if len(args) == 3 else 1
|
215
365
|
result = await give(args[0], args[1], quantity)
|
216
366
|
achievements = await check_achievement(args[0])
|
217
367
|
if achievements is not None:
|
218
368
|
for achievement in achievements:
|
219
|
-
await fishing.send(achievement)
|
369
|
+
await fishing.send(achievement)
|
220
370
|
await give_cmd.finish(result)
|
221
371
|
|
222
372
|
|
223
373
|
@board_cmd.handle()
|
224
|
-
async def _(bot: Bot, event: GroupMessageEvent):
|
225
|
-
group_id = event.group_id
|
374
|
+
async def _(bot: Bot, event: Union[GroupMessageEvent, PrivateMessageEvent]):
|
226
375
|
top_users_list = await get_board()
|
227
|
-
msg =
|
376
|
+
msg = "钓鱼富豪排行榜:"
|
228
377
|
for index, user in enumerate(top_users_list):
|
229
378
|
try:
|
230
|
-
|
231
|
-
|
379
|
+
if isinstance(event, GroupMessageEvent):
|
380
|
+
group_id = event.group_id
|
381
|
+
user_info = await bot.get_group_member_info(
|
382
|
+
group_id=group_id, user_id=user[0]
|
383
|
+
)
|
384
|
+
username = (
|
385
|
+
user_info["card"]
|
386
|
+
if user_info["card"] is not None and user_info["card"] != ""
|
387
|
+
else user_info["nickname"]
|
388
|
+
)
|
389
|
+
elif isinstance(event, PrivateMessageEvent):
|
390
|
+
user_info = await bot.get_stranger_info(user_id=user[0])
|
391
|
+
username = user_info["nickname"]
|
232
392
|
except ActionFailed:
|
233
393
|
username = "[神秘富豪]"
|
234
394
|
|
235
|
-
msg += f
|
236
|
-
|
395
|
+
msg += f"\n{index + 1}. {username}: {user[1]} {fishing_coin_name}"
|
396
|
+
|
237
397
|
await board_cmd.finish(msg)
|
238
|
-
|
239
|
-
|
240
|
-
|
398
|
+
|
399
|
+
|
400
|
+
async def punish(bot: Bot, event: Event, matcher: Matcher, user_id: int):
|
401
|
+
global punish_user_dict
|
402
|
+
|
403
|
+
if not await can_fishing(user_id):
|
404
|
+
try:
|
405
|
+
punish_user_dict[user_id] += 1
|
406
|
+
except KeyError:
|
407
|
+
punish_user_dict[user_id] = 1
|
408
|
+
|
409
|
+
if punish_user_dict[user_id] < config.punish_limit - 1:
|
410
|
+
await matcher.finish(
|
411
|
+
MessageSegment.at(user_id) + " " + "河累了,休息一下吧"
|
412
|
+
)
|
413
|
+
elif punish_user_dict[user_id] == config.punish_limit - 1:
|
414
|
+
await matcher.finish(MessageSegment.at(user_id) + " " + "河神快要不耐烦了")
|
415
|
+
elif punish_user_dict[user_id] == config.punish_limit:
|
416
|
+
groud_id = event.group_id if isinstance(event, GroupMessageEvent) else None
|
417
|
+
try:
|
418
|
+
await bot.set_group_ban(
|
419
|
+
group_id=groud_id, user_id=user_id, duration=1800
|
420
|
+
)
|
421
|
+
except ActionFailed:
|
422
|
+
pass
|
423
|
+
await matcher.finish(
|
424
|
+
MessageSegment.at(user_id) + " " + "河神生气了,降下了惩罚"
|
425
|
+
)
|
426
|
+
else:
|
427
|
+
await matcher.finish()
|
428
|
+
|
429
|
+
|
430
|
+
async def forward_send(
|
431
|
+
bot: Bot,
|
432
|
+
event: Union[GroupMessageEvent, PrivateMessageEvent],
|
433
|
+
messages: list[MessageSegment],
|
434
|
+
) -> None:
|
435
|
+
if isinstance(event, GroupMessageEvent):
|
436
|
+
await bot.send_group_forward_msg(
|
437
|
+
group_id=event.group_id,
|
438
|
+
messages=[
|
439
|
+
{
|
440
|
+
"type": "node",
|
441
|
+
"data": {
|
442
|
+
"name": "花花",
|
443
|
+
"uin": bot.self_id,
|
444
|
+
"content": msg,
|
445
|
+
},
|
446
|
+
}
|
447
|
+
for msg in messages
|
448
|
+
],
|
449
|
+
)
|
450
|
+
else:
|
451
|
+
await bot.send_private_forward_msg(
|
452
|
+
user_id=event.user_id,
|
453
|
+
messages=[
|
454
|
+
{
|
455
|
+
"type": "node",
|
456
|
+
"data": {
|
457
|
+
"name": "花花",
|
458
|
+
"uin": bot.self_id,
|
459
|
+
"content": msg,
|
460
|
+
},
|
461
|
+
}
|
462
|
+
for msg in messages
|
463
|
+
],
|
464
|
+
)
|
465
|
+
|
466
|
+
|
467
|
+
async def get_at(event: Union[GroupMessageEvent, PrivateMessageEvent]) -> int:
|
468
|
+
if isinstance(event, GroupMessageEvent):
|
469
|
+
msg = event.get_message()
|
470
|
+
for msg_seg in msg:
|
471
|
+
if msg_seg.type == "at":
|
472
|
+
return msg_seg.data["qq"]
|
473
|
+
return None
|