koishi-plugin-ll-brick 1.0.7 → 1.0.9
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.
- package/lib/index.d.ts +3 -0
- package/lib/index.js +64 -15
- package/package.json +1 -1
- package/readme.md +6 -0
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
|
@@ -34,6 +34,12 @@ exports.Config = koishi_1.Schema.intersect([
|
|
|
34
34
|
specialUser: koishi_1.Schema.dict(Number)
|
|
35
35
|
.role('table')
|
|
36
36
|
.description('键为用户ID,值为被拍时的反击概率(%)<br/>不设置则使用默认概率'),
|
|
37
|
+
adminUsers: koishi_1.Schema.array(koishi_1.Schema.string())
|
|
38
|
+
.default([])
|
|
39
|
+
.description('管理员 ID 列表(openid):被加入的 ID 可以使用「充值」等管理命令'),
|
|
40
|
+
slapImage: koishi_1.Schema.string()
|
|
41
|
+
.default('https://img3.tofaka.com/autoupload/ontjZmlK09ZHnuFOv9znC7KXl_QqVl-bpSwqP4fJO68/20260624/lOIl/240X240/images.jpg')
|
|
42
|
+
.description('「拍人」消息顶部图片 URL(需公网可访问;留空则不显示图片)'),
|
|
37
43
|
}),
|
|
38
44
|
koishi_1.Schema.object({
|
|
39
45
|
checking: koishi_1.Schema.boolean()
|
|
@@ -76,19 +82,23 @@ function stripMarkdown(md) {
|
|
|
76
82
|
function mdCard(lines) {
|
|
77
83
|
return lines.filter(Boolean).join('\n');
|
|
78
84
|
}
|
|
79
|
-
async function sendQQMarkdown(session, text) {
|
|
85
|
+
async function sendQQMarkdown(session, text, imageUrl, imageSize) {
|
|
80
86
|
const channelId = session.guildId;
|
|
81
87
|
const internal = session.bot?.internal;
|
|
82
88
|
if (!channelId || !internal || typeof internal.sendMessage !== 'function') {
|
|
83
89
|
return false;
|
|
84
90
|
}
|
|
85
|
-
|
|
91
|
+
// 顶部图片:QQ markdown 图片必须带尺寸参数,且需公网可访问 URL
|
|
92
|
+
const md = imageUrl
|
|
93
|
+
? `\n\n${text}`
|
|
94
|
+
: text;
|
|
95
|
+
const plain = stripMarkdown(md) || ' ';
|
|
86
96
|
try {
|
|
87
97
|
await internal.sendMessage(channelId, {
|
|
88
98
|
msg_type: 2,
|
|
89
99
|
msg_seq: 0,
|
|
90
100
|
content: plain,
|
|
91
|
-
markdown: { content:
|
|
101
|
+
markdown: { content: md },
|
|
92
102
|
});
|
|
93
103
|
return true;
|
|
94
104
|
}
|
|
@@ -236,14 +246,12 @@ async function apply(ctx, config) {
|
|
|
236
246
|
if (koishi_1.Random.bool(probability)) {
|
|
237
247
|
const muteErr = await tryMute(session.userId);
|
|
238
248
|
const msg = mdCard([
|
|
239
|
-
|
|
240
|
-
'
|
|
241
|
-
'
|
|
242
|
-
`> 🎯 ${atUser(session, targetUserId)} 夺过你的砖头,把你拍晕了 **${muteTime}** 秒 🏏`,
|
|
243
|
-
muteErr ? '> ⚠️ 因为我不是群管理员,所以并没什么卵用' : '',
|
|
249
|
+
`${atUser(session, targetUserId)} 夺过你的砖头,把你拍晕了 **${muteTime}** 秒 🏏`,
|
|
250
|
+
'⚠️ 危险警告:有人动用了板砖!',
|
|
251
|
+
muteErr ? '(因为我不是群管理员,所以并没什么卵用)' : '',
|
|
244
252
|
]);
|
|
245
253
|
if (isQQ) {
|
|
246
|
-
await sendQQMarkdown(session, msg);
|
|
254
|
+
await sendQQMarkdown(session, msg, config.slapImage);
|
|
247
255
|
return;
|
|
248
256
|
}
|
|
249
257
|
return msg;
|
|
@@ -251,14 +259,12 @@ async function apply(ctx, config) {
|
|
|
251
259
|
else {
|
|
252
260
|
const muteErr = await tryMute(targetUserId);
|
|
253
261
|
const msg = mdCard([
|
|
254
|
-
|
|
255
|
-
'
|
|
256
|
-
'
|
|
257
|
-
`> 🎯 ${atUser(session, targetUserId)} 你被 ${atUser(session, session.userId)} 一砖头拍晕了 **${muteTime}** 秒 🏏`,
|
|
258
|
-
muteErr ? '> ⚠️ 因为我不是群管理员,所以并没什么卵用' : '',
|
|
262
|
+
`${atUser(session, targetUserId)} 你被 ${atUser(session, session.userId)} 一砖头拍晕了 **${muteTime}** 秒 🏏`,
|
|
263
|
+
'⚠️ 危险警告:有人动用了板砖!',
|
|
264
|
+
muteErr ? '(因为我不是群管理员,所以并没什么卵用)' : '',
|
|
259
265
|
]);
|
|
260
266
|
if (isQQ) {
|
|
261
|
-
await sendQQMarkdown(session, msg);
|
|
267
|
+
await sendQQMarkdown(session, msg, config.slapImage);
|
|
262
268
|
return;
|
|
263
269
|
}
|
|
264
270
|
return msg;
|
|
@@ -319,6 +325,49 @@ async function apply(ctx, config) {
|
|
|
319
325
|
return `你有 ${brickData[0].brick}/${config.maxBrick} 块砖头`;
|
|
320
326
|
}
|
|
321
327
|
});
|
|
328
|
+
ctx.command("砖头.充值 <user:user> <amount:number>", "给指定用户充值砖头(仅管理员)")
|
|
329
|
+
.alias("充值")
|
|
330
|
+
.example("充值 @某人 10")
|
|
331
|
+
.action(async ({ session }, user, amount) => {
|
|
332
|
+
if (!config.adminUsers.includes(session.userId)) {
|
|
333
|
+
return '只有管理员才能使用 充值';
|
|
334
|
+
}
|
|
335
|
+
const targetUserId = user && user.split(":")[1];
|
|
336
|
+
if (!targetUserId) {
|
|
337
|
+
return '无效的用户';
|
|
338
|
+
}
|
|
339
|
+
const add = Math.floor(Number(amount));
|
|
340
|
+
if (!Number.isFinite(add) || add <= 0) {
|
|
341
|
+
return '充值数量无效';
|
|
342
|
+
}
|
|
343
|
+
const existing = await ctx.database.get('brick', {
|
|
344
|
+
userId: targetUserId,
|
|
345
|
+
guildId: session.guildId,
|
|
346
|
+
});
|
|
347
|
+
const cur = existing.length ? existing[0].brick : 0;
|
|
348
|
+
if (cur >= config.maxBrick) {
|
|
349
|
+
return `该用户砖头已满(${cur}/${config.maxBrick})`;
|
|
350
|
+
}
|
|
351
|
+
let real = add;
|
|
352
|
+
if (cur + real > config.maxBrick) {
|
|
353
|
+
real = config.maxBrick - cur;
|
|
354
|
+
}
|
|
355
|
+
if (existing.length === 0) {
|
|
356
|
+
await ctx.database.create('brick', {
|
|
357
|
+
userId: targetUserId,
|
|
358
|
+
guildId: session.guildId,
|
|
359
|
+
brick: real,
|
|
360
|
+
});
|
|
361
|
+
}
|
|
362
|
+
else {
|
|
363
|
+
await ctx.database.upsert('brick', (row) => [{
|
|
364
|
+
userId: targetUserId,
|
|
365
|
+
guildId: session.guildId,
|
|
366
|
+
brick: koishi_1.$.add(row.brick, real),
|
|
367
|
+
}], ["userId", "guildId"]);
|
|
368
|
+
}
|
|
369
|
+
return `已给 ${targetUserId.slice(0, 8)} 充值 ${real} 块砖头(现有 ${cur + real}/${config.maxBrick})`;
|
|
370
|
+
});
|
|
322
371
|
if (config.checking) {
|
|
323
372
|
ctx.command("砖头.签到")
|
|
324
373
|
.alias("砖头签到")
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -13,6 +13,12 @@
|
|
|
13
13
|
- `砖头 查看` — 查看自己的砖头数量
|
|
14
14
|
- `砖头 签到`(可选开启)— 每日签到获取随机砖头
|
|
15
15
|
|
|
16
|
+
## v1.0.8 新增
|
|
17
|
+
|
|
18
|
+
- **设置页新增「管理员 ID 列表」**(`adminUsers`):填入用户的 openid 即成为管理员,无需额外管理员命令
|
|
19
|
+
- 新增命令 **`砖头 充值 @某人 <数量>`**(仅管理员可用):给指定用户充入砖头(不会超过上限 `maxBrick`)
|
|
20
|
+
- 非管理员使用充值会提示"只有管理员才能使用 充值"
|
|
21
|
+
|
|
16
22
|
## v1.0.7 更新
|
|
17
23
|
|
|
18
24
|
- **移除所有图片**,所有通知统一改为 markdown 卡片样式(`# 标题` + `---` + `> 引用行`),加载更快
|