nonebot-plugin-fishing2 0.0.3__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 +281 -110
- nonebot_plugin_fishing2/config.py +144 -39
- nonebot_plugin_fishing2/data_source.py +393 -403
- nonebot_plugin_fishing2/fish_helper.py +157 -0
- nonebot_plugin_fishing2-0.0.4.dist-info/METADATA +168 -0
- {nonebot_plugin_fishing2-0.0.3.dist-info → nonebot_plugin_fishing2-0.0.4.dist-info}/RECORD +9 -8
- {nonebot_plugin_fishing2-0.0.3.dist-info → nonebot_plugin_fishing2-0.0.4.dist-info}/licenses/LICENSE +1 -1
- nonebot_plugin_fishing2-0.0.3.dist-info/METADATA +0 -144
- {nonebot_plugin_fishing2-0.0.3.dist-info → nonebot_plugin_fishing2-0.0.4.dist-info}/WHEEL +0 -0
- {nonebot_plugin_fishing2-0.0.3.dist-info → nonebot_plugin_fishing2-0.0.4.dist-info}/top_level.txt +0 -0
@@ -1,26 +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
|
-
fish_list,
|
21
|
-
get_info,
|
22
25
|
can_fishing,
|
23
|
-
can_free_fish,
|
24
26
|
get_fish,
|
25
27
|
get_stats,
|
26
28
|
get_backpack,
|
@@ -35,103 +37,124 @@ from .data_source import (
|
|
35
37
|
check_tools,
|
36
38
|
remove_tools,
|
37
39
|
get_shop,
|
38
|
-
buy_fish
|
40
|
+
buy_fish,
|
41
|
+
predict,
|
42
|
+
get_all_special_fish,
|
39
43
|
)
|
44
|
+
from .fish_helper import fish_list, get_fish_by_name
|
40
45
|
|
41
46
|
fishing_coin_name = config.fishing_coin_name
|
42
47
|
|
43
48
|
__plugin_meta__ = PluginMetadata(
|
44
49
|
name="更好的电子钓鱼",
|
45
50
|
description="赛博钓鱼……但是加强版本",
|
46
|
-
usage=f
|
47
|
-
▶ 查询 [物品]:查询某个物品的信息
|
51
|
+
usage=f"""▶ 查询 [物品]:查询某个物品的信息
|
48
52
|
▶ 钓鱼 [鱼竿] [鱼饵]:
|
49
|
-
▷ 有 {config.fishing_limit}s
|
53
|
+
▷ 有 {config.fishing_limit}s 的冷却
|
54
|
+
▷ {config.no_fish_probability} 概率空军,{config.special_fish_probability} 概率掉到特殊鱼
|
50
55
|
▷ 加参数可以使用鱼饵或鱼竿,同类物品同时只能使用一种
|
51
56
|
▷ 频繁钓鱼会触怒河神
|
52
57
|
▶ 出售 <物品> <数量>:出售物品获得{fishing_coin_name}
|
58
|
+
▷ 如果卖不出去,尝试用英文双引号框住鱼名
|
53
59
|
▶ 购买 <物品> <份数>:购买渔具店的物品
|
54
60
|
▶ 放生 <鱼名>:给一条鱼取名并放生
|
61
|
+
▷ 不要放生奇怪名字的鱼
|
55
62
|
▶ 商店:看看渔具店都有些啥
|
56
63
|
▶ 祈愿:向神祈愿,随机获取/损失{fishing_coin_name}
|
57
64
|
▶ 背包:查看背包中的{fishing_coin_name}与物品
|
58
65
|
▶ 成就:查看拥有的成就
|
59
66
|
▶ 钓鱼排行榜:查看{fishing_coin_name}排行榜
|
60
|
-
|
67
|
+
""",
|
61
68
|
type="application",
|
62
69
|
homepage="https://github.com/FDCraft/nonebot-plugin-fishing2",
|
63
70
|
config=Config,
|
64
|
-
supported_adapters=
|
65
|
-
extra={
|
66
|
-
'author': 'Polaris_Light',
|
67
|
-
'version': '0.0.3',
|
68
|
-
'priority': 5
|
69
|
-
}
|
71
|
+
supported_adapters={"~onebot.v11"},
|
72
|
+
extra={"author": "Polaris_Light", "version": "0.0.4", "priority": 5},
|
70
73
|
)
|
71
74
|
|
72
75
|
|
73
|
-
|
74
76
|
block_user_list = []
|
75
77
|
punish_user_dict = {}
|
76
78
|
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
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
|
89
97
|
|
90
98
|
|
91
99
|
@fishing_help.handle()
|
92
100
|
async def _():
|
93
101
|
await fishing_help.finish(__plugin_meta__.usage)
|
94
102
|
|
103
|
+
|
95
104
|
@shop.handle()
|
96
105
|
async def _(bot: Bot, event: Union[GroupMessageEvent, PrivateMessageEvent]):
|
97
106
|
messages = get_shop()
|
98
107
|
await forward_send(bot, event, messages)
|
99
108
|
return None
|
100
|
-
|
109
|
+
|
110
|
+
|
101
111
|
@fishing_lookup.handle()
|
102
|
-
async def _(
|
112
|
+
async def _(
|
113
|
+
bot: Bot,
|
114
|
+
event: Union[GroupMessageEvent, PrivateMessageEvent],
|
115
|
+
arg: Message = CommandArg(),
|
116
|
+
):
|
117
|
+
user_id = event.get_user_id()
|
103
118
|
arg = arg.extract_plain_text()
|
104
119
|
if not arg or arg == "":
|
105
|
-
await fishing_lookup.finish(
|
106
|
-
|
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())
|
107
131
|
return None
|
108
132
|
|
109
133
|
|
110
134
|
@fishing.handle()
|
111
|
-
async def _(bot:Bot, event: Event, matcher: Matcher, arg: Message = CommandArg()):
|
135
|
+
async def _(bot: Bot, event: Event, matcher: Matcher, arg: Message = CommandArg()):
|
112
136
|
user_id = event.get_user_id()
|
113
137
|
if user_id in block_user_list:
|
114
138
|
await fishing.finish()
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
logger.debug(f"
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
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
|
+
|
125
148
|
await punish(bot, event, matcher, user_id)
|
126
149
|
block_user_list.append(user_id)
|
127
150
|
try:
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
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)
|
135
158
|
achievements = await check_achievement(user_id)
|
136
159
|
if achievements is not None:
|
137
160
|
for achievement in achievements:
|
@@ -144,21 +167,104 @@ async def _(bot:Bot, event: Event, matcher: Matcher, arg: Message = CommandArg()
|
|
144
167
|
await fishing.finish(MessageSegment.at(user_id) + " " + result)
|
145
168
|
|
146
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
|
+
|
147
228
|
@backpack.handle()
|
148
|
-
async def _(event:
|
229
|
+
async def _(bot: Bot, event: Union[GroupMessageEvent, PrivateMessageEvent]):
|
149
230
|
user_id = event.get_user_id()
|
150
|
-
|
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
|
+
|
151
250
|
|
152
251
|
@buy.handle()
|
153
252
|
async def _(event: Event, arg: Message = CommandArg()):
|
154
|
-
|
253
|
+
args = arg.extract_plain_text().split(" ")
|
254
|
+
args = [x for x in args if x != ""]
|
255
|
+
|
155
256
|
user_id = event.get_user_id()
|
156
|
-
if
|
157
|
-
await buy.finish(
|
158
|
-
|
159
|
-
|
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)
|
160
266
|
else:
|
161
|
-
fish_name, fish_quantity =
|
267
|
+
fish_name, fish_quantity = args[0], args[1]
|
162
268
|
result = await buy_fish(user_id, fish_name, int(fish_quantity))
|
163
269
|
achievements = await check_achievement(user_id)
|
164
270
|
if achievements is not None:
|
@@ -169,26 +275,49 @@ async def _(event: Event, arg: Message = CommandArg()):
|
|
169
275
|
|
170
276
|
@sell.handle()
|
171
277
|
async def _(event: Event, arg: Message = CommandArg()):
|
172
|
-
|
278
|
+
args = shlex.split(arg.extract_plain_text())
|
279
|
+
|
173
280
|
user_id = event.get_user_id()
|
174
|
-
if
|
175
|
-
await sell.finish(
|
176
|
-
|
177
|
-
|
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
|
+
)
|
178
292
|
else:
|
179
|
-
fish_name, fish_quantity =
|
180
|
-
|
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)
|
181
296
|
|
182
297
|
|
183
298
|
@free_fish_cmd.handle()
|
184
|
-
async def _(event: Event, arg: Message = CommandArg()):
|
185
|
-
if not
|
299
|
+
async def _(bot: Bot, event: Event, arg: Message = CommandArg()):
|
300
|
+
if not config.special_fish_enabled:
|
186
301
|
await free_fish_cmd.finish("未开启此功能, 请联系机器人管理员")
|
302
|
+
|
187
303
|
fish_name = arg.extract_plain_text()
|
188
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
|
+
|
189
314
|
if fish_name == "":
|
190
|
-
await free_fish_cmd.finish(
|
191
|
-
|
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
|
+
)
|
192
321
|
|
193
322
|
|
194
323
|
@lottery_cmd.handle()
|
@@ -207,83 +336,117 @@ async def _(bot: Bot, event: Event, matcher: Matcher):
|
|
207
336
|
@achievement_cmd.handle()
|
208
337
|
async def _(event: Event):
|
209
338
|
user_id = event.get_user_id()
|
210
|
-
await achievement_cmd.finish(
|
339
|
+
await achievement_cmd.finish(
|
340
|
+
MessageSegment.at(user_id) + " " + await get_achievements(user_id)
|
341
|
+
)
|
211
342
|
|
212
343
|
|
213
344
|
@give_cmd.handle()
|
214
|
-
async def _(
|
215
|
-
|
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)
|
216
359
|
if len(args) < 2 or len(args) > 3:
|
217
|
-
await give_cmd.finish(
|
360
|
+
await give_cmd.finish(
|
361
|
+
"请输入用户的 id 和鱼的名字和数量 (数量为1时可省略), 如 /give 114514 开发鱼 1"
|
362
|
+
)
|
218
363
|
else:
|
219
|
-
print(f"PLDEBUG1: {args}")
|
220
364
|
quantity = int(args[2]) if len(args) == 3 else 1
|
221
365
|
result = await give(args[0], args[1], quantity)
|
222
366
|
achievements = await check_achievement(args[0])
|
223
367
|
if achievements is not None:
|
224
368
|
for achievement in achievements:
|
225
|
-
await fishing.send(achievement)
|
369
|
+
await fishing.send(achievement)
|
226
370
|
await give_cmd.finish(result)
|
227
371
|
|
228
372
|
|
229
373
|
@board_cmd.handle()
|
230
|
-
async def _(bot: Bot, event: GroupMessageEvent):
|
231
|
-
group_id = event.group_id
|
374
|
+
async def _(bot: Bot, event: Union[GroupMessageEvent, PrivateMessageEvent]):
|
232
375
|
top_users_list = await get_board()
|
233
|
-
msg =
|
376
|
+
msg = "钓鱼富豪排行榜:"
|
234
377
|
for index, user in enumerate(top_users_list):
|
235
378
|
try:
|
236
|
-
|
237
|
-
|
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"]
|
238
392
|
except ActionFailed:
|
239
393
|
username = "[神秘富豪]"
|
240
394
|
|
241
|
-
msg += f
|
242
|
-
|
395
|
+
msg += f"\n{index + 1}. {username}: {user[1]} {fishing_coin_name}"
|
396
|
+
|
243
397
|
await board_cmd.finish(msg)
|
244
|
-
|
245
|
-
|
398
|
+
|
246
399
|
|
247
400
|
async def punish(bot: Bot, event: Event, matcher: Matcher, user_id: int):
|
248
401
|
global punish_user_dict
|
249
|
-
|
402
|
+
|
250
403
|
if not await can_fishing(user_id):
|
251
404
|
try:
|
252
405
|
punish_user_dict[user_id] += 1
|
253
406
|
except KeyError:
|
254
407
|
punish_user_dict[user_id] = 1
|
255
408
|
|
256
|
-
if punish_user_dict[user_id] < config.punish_limit - 1
|
257
|
-
await matcher.finish(
|
409
|
+
if punish_user_dict[user_id] < config.punish_limit - 1:
|
410
|
+
await matcher.finish(
|
411
|
+
MessageSegment.at(user_id) + " " + "河累了,休息一下吧"
|
412
|
+
)
|
258
413
|
elif punish_user_dict[user_id] == config.punish_limit - 1:
|
259
414
|
await matcher.finish(MessageSegment.at(user_id) + " " + "河神快要不耐烦了")
|
260
415
|
elif punish_user_dict[user_id] == config.punish_limit:
|
261
416
|
groud_id = event.group_id if isinstance(event, GroupMessageEvent) else None
|
262
417
|
try:
|
263
|
-
await bot.set_group_ban(
|
418
|
+
await bot.set_group_ban(
|
419
|
+
group_id=groud_id, user_id=user_id, duration=1800
|
420
|
+
)
|
264
421
|
except ActionFailed:
|
265
422
|
pass
|
266
|
-
await matcher.finish(
|
423
|
+
await matcher.finish(
|
424
|
+
MessageSegment.at(user_id) + " " + "河神生气了,降下了惩罚"
|
425
|
+
)
|
267
426
|
else:
|
268
427
|
await matcher.finish()
|
269
428
|
|
270
429
|
|
271
|
-
async def forward_send(
|
430
|
+
async def forward_send(
|
431
|
+
bot: Bot,
|
432
|
+
event: Union[GroupMessageEvent, PrivateMessageEvent],
|
433
|
+
messages: list[MessageSegment],
|
434
|
+
) -> None:
|
272
435
|
if isinstance(event, GroupMessageEvent):
|
273
436
|
await bot.send_group_forward_msg(
|
274
437
|
group_id=event.group_id,
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
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
|
+
)
|
287
450
|
else:
|
288
451
|
await bot.send_private_forward_msg(
|
289
452
|
user_id=event.user_id,
|
@@ -299,4 +462,12 @@ async def forward_send(bot: Bot, event: Union[GroupMessageEvent, PrivateMessageE
|
|
299
462
|
for msg in messages
|
300
463
|
],
|
301
464
|
)
|
302
|
-
|
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
|