koishi-plugin-echo-cave 1.7.5 → 1.8.0
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.cjs +67 -22
- package/package.json +6 -1
package/lib/index.cjs
CHANGED
|
@@ -4,6 +4,9 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
4
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
5
|
var __getProtoOf = Object.getPrototypeOf;
|
|
6
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
8
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
9
|
+
};
|
|
7
10
|
var __export = (target, all) => {
|
|
8
11
|
for (var name2 in all)
|
|
9
12
|
__defProp(target, name2, { get: all[name2], enumerable: true });
|
|
@@ -26,6 +29,47 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
26
29
|
));
|
|
27
30
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
31
|
|
|
32
|
+
// src/locales/zh-CN.json
|
|
33
|
+
var require_zh_CN = __commonJS({
|
|
34
|
+
"src/locales/zh-CN.json"(exports2, module2) {
|
|
35
|
+
module2.exports = {
|
|
36
|
+
config: {
|
|
37
|
+
adminMessageProtection: "\u5F00\u542F\u7BA1\u7406\u5458\u6D88\u606F\u4FDD\u62A4\uFF0C\u5F00\u542F\u540E\u7BA1\u7406\u5458\u53D1\u5E03\u7684\u6D88\u606F\u53EA\u80FD\u7531\u7BA1\u7406\u5458\u5220\u9664"
|
|
38
|
+
},
|
|
39
|
+
general: {
|
|
40
|
+
privateChatReminder: "\u274C \u8BF7\u5728\u7FA4\u804A\u4E2D\u4F7F\u7528\u8BE5\u547D\u4EE4\uFF01",
|
|
41
|
+
noMsgWithId: "\u{1F50D} \u672A\u627E\u5230\u8BE5 ID \u7684\u56DE\u58F0\u6D1E\u6D88\u606F"
|
|
42
|
+
},
|
|
43
|
+
commands: {
|
|
44
|
+
cave: {
|
|
45
|
+
description: "\u968F\u673A\u83B7\u53D6 / \u83B7\u53D6\u7279\u5B9A id \u7684\u56DE\u58F0\u6D1E\u4FE1\u606F",
|
|
46
|
+
messages: {
|
|
47
|
+
noMsgInCave: '\u{1F680} \u56DE\u58F0\u6D1E\u4E2D\u6682\u65E0\u6D88\u606F\uFF0C\u5FEB\u4F7F\u7528 "cave.echo" \u547D\u4EE4\u6DFB\u52A0\u7B2C\u4E00\u6761\u6D88\u606F\u5427\uFF01'
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
"cave.echo": {
|
|
51
|
+
description: "\u5C06\u6D88\u606F\u5B58\u5165\u56DE\u58F0\u6D1E",
|
|
52
|
+
messages: {
|
|
53
|
+
noMsgQuoted: "\u{1F4A1} \u8BF7\u5F15\u7528\u4E00\u6761\u6D88\u606F\u540E\u518D\u4F7F\u7528\u6B64\u547D\u4EE4\uFF01",
|
|
54
|
+
existingMsg: "\u267B\uFE0F \u8BE5\u6D88\u606F\u5DF2\u5B58\u5728\u4E8E\u56DE\u58F0\u6D1E\u7A74\u4E2D\uFF01",
|
|
55
|
+
msgSaved: "\u2705 \u56DE\u58F0\u6D1E\u6D88\u606F\u5DF2\u6210\u529F\u5B58\u5165\uFF0C\u6D88\u606F ID\uFF1A{0}",
|
|
56
|
+
msgFailedToSave: "\u274C \u56DE\u58F0\u6D1E\u4FDD\u5B58\u5931\u8D25\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5\uFF01"
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
"cave.wipe": {
|
|
60
|
+
description: "\u62B9\u53BB\u7279\u5B9A id \u7684\u56DE\u58F0\u6D1E\u4FE1\u606F",
|
|
61
|
+
messages: {
|
|
62
|
+
noIdProvided: "\u274C \u8BF7\u63D0\u4F9B\u8981\u5220\u9664\u7684\u56DE\u58F0\u6D1E\u6D88\u606F ID\uFF01",
|
|
63
|
+
adminOnly: "\u26D4 \u8BE5\u6D88\u606F\u7531\u7BA1\u7406\u5458\u53D1\u5E03\uFF0C\u5DF2\u5F00\u542F\u7BA1\u7406\u5458\u6D88\u606F\u4FDD\u62A4\uFF0C\u53EA\u6709\u7BA1\u7406\u5458\u53EF\u4EE5\u5220\u9664\u3002",
|
|
64
|
+
permissionDenied: "\u26D4 \u60A8\u6CA1\u6709\u6743\u9650\u5220\u9664\u6B64\u6D88\u606F\uFF01\u53EA\u6709\u6D88\u606F\u7684\u5B58\u50A8\u8005\u3001\u539F\u59CB\u53D1\u9001\u8005\u6216\u7BA1\u7406\u5458\u53EF\u4EE5\u5220\u9664\u3002",
|
|
65
|
+
msgDeleted: "\u2705 \u5DF2\u6210\u529F\u62B9\u53BB\u56DE\u58F0\u6D1E\u6D88\u606F ID\uFF1A{0}"
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
|
|
29
73
|
// src/index.ts
|
|
30
74
|
var index_exports = {};
|
|
31
75
|
__export(index_exports, {
|
|
@@ -276,9 +320,12 @@ var import_node_path2 = __toESM(require("node:path"), 1);
|
|
|
276
320
|
var name = "echo-cave";
|
|
277
321
|
var inject = ["database"];
|
|
278
322
|
var Config = import_koishi.Schema.object({
|
|
279
|
-
adminMessageProtection: import_koishi.Schema.boolean().
|
|
323
|
+
adminMessageProtection: import_koishi.Schema.boolean().default(false)
|
|
324
|
+
}).i18n({
|
|
325
|
+
"zh-CN": require_zh_CN().config
|
|
280
326
|
});
|
|
281
327
|
function apply(ctx, cfg) {
|
|
328
|
+
ctx.i18n.define("zh-CN", require_zh_CN());
|
|
282
329
|
const imgPath = import_node_path2.default.join(ctx.baseDir, "data", "cave", "images");
|
|
283
330
|
if (!import_fs.default.existsSync(imgPath)) {
|
|
284
331
|
import_fs.default.mkdirSync(imgPath, { recursive: true });
|
|
@@ -300,13 +347,11 @@ function apply(ctx, cfg) {
|
|
|
300
347
|
unique: ["content"]
|
|
301
348
|
}
|
|
302
349
|
);
|
|
303
|
-
ctx.command("cave [id:number]"
|
|
350
|
+
ctx.command("cave [id:number]").action(
|
|
304
351
|
async ({ session }, id) => await getCave(ctx, session, id)
|
|
305
352
|
);
|
|
306
|
-
ctx.command("cave.echo"
|
|
307
|
-
|
|
308
|
-
);
|
|
309
|
-
ctx.command("cave.wipe <id:number>", "\u62B9\u53BB\u7279\u5B9A id \u7684\u56DE\u58F0\u6D1E\u4FE1\u606F").action(
|
|
353
|
+
ctx.command("cave.echo").action(async ({ session }) => await addCave(ctx, session));
|
|
354
|
+
ctx.command("cave.wipe <id:number>").action(
|
|
310
355
|
async ({ session }, id) => await deleteCave(ctx, session, cfg, id)
|
|
311
356
|
);
|
|
312
357
|
ctx.command("cave.listen", "\u83B7\u5F97\u7531\u81EA\u5DF1\u6295\u7A3F\u7684\u56DE\u58F0\u6D1E\u5217\u8868").action(
|
|
@@ -318,7 +363,7 @@ function apply(ctx, cfg) {
|
|
|
318
363
|
}
|
|
319
364
|
async function getCaveListByUser(ctx, session) {
|
|
320
365
|
if (!session.guildId) {
|
|
321
|
-
return "
|
|
366
|
+
return session.text("general.privateChatReminder");
|
|
322
367
|
}
|
|
323
368
|
const { userId, channelId } = session;
|
|
324
369
|
const caves = await ctx.database.get("echo_cave", {
|
|
@@ -338,7 +383,7 @@ async function getCaveListByUser(ctx, session) {
|
|
|
338
383
|
}
|
|
339
384
|
async function getCaveListByOriginUser(ctx, session) {
|
|
340
385
|
if (!session.guildId) {
|
|
341
|
-
return "
|
|
386
|
+
return session.text("general.privateChatReminder");
|
|
342
387
|
}
|
|
343
388
|
const { userId, channelId } = session;
|
|
344
389
|
const caves = await ctx.database.get("echo_cave", {
|
|
@@ -358,7 +403,7 @@ async function getCaveListByOriginUser(ctx, session) {
|
|
|
358
403
|
}
|
|
359
404
|
async function getCave(ctx, session, id) {
|
|
360
405
|
if (!session.guildId) {
|
|
361
|
-
return "
|
|
406
|
+
return session.text("general.privateChatReminder");
|
|
362
407
|
}
|
|
363
408
|
let caveMsg;
|
|
364
409
|
const { channelId } = session;
|
|
@@ -367,7 +412,7 @@ async function getCave(ctx, session, id) {
|
|
|
367
412
|
channelId
|
|
368
413
|
});
|
|
369
414
|
if (caves.length === 0) {
|
|
370
|
-
return
|
|
415
|
+
return session.text(".noMsgInCave");
|
|
371
416
|
}
|
|
372
417
|
caveMsg = caves[Math.floor(Math.random() * caves.length)];
|
|
373
418
|
} else {
|
|
@@ -376,7 +421,7 @@ async function getCave(ctx, session, id) {
|
|
|
376
421
|
channelId
|
|
377
422
|
});
|
|
378
423
|
if (caves.length === 0) {
|
|
379
|
-
return "
|
|
424
|
+
return session.text("general.noMsgWithId");
|
|
380
425
|
}
|
|
381
426
|
caveMsg = caves[0];
|
|
382
427
|
}
|
|
@@ -384,14 +429,14 @@ async function getCave(ctx, session, id) {
|
|
|
384
429
|
}
|
|
385
430
|
async function deleteCave(ctx, session, cfg, id) {
|
|
386
431
|
if (!session.guildId) {
|
|
387
|
-
return "
|
|
432
|
+
return session.text("general.privateChatReminder");
|
|
388
433
|
}
|
|
389
434
|
if (!id) {
|
|
390
|
-
return "
|
|
435
|
+
return session.text(".noIdProvided");
|
|
391
436
|
}
|
|
392
437
|
const caves = await ctx.database.get("echo_cave", id);
|
|
393
438
|
if (caves.length === 0) {
|
|
394
|
-
return "
|
|
439
|
+
return session.text("general.noMsgWithId");
|
|
395
440
|
}
|
|
396
441
|
const caveMsg = caves[0];
|
|
397
442
|
const currentUserId = session.userId;
|
|
@@ -402,21 +447,21 @@ async function deleteCave(ctx, session, cfg, id) {
|
|
|
402
447
|
const caveUser = await ctx.database.getUser(session.platform, caveMsg.userId);
|
|
403
448
|
const isCaveUserAdmin = caveUser.authority >= 4;
|
|
404
449
|
if (isCaveUserAdmin && !isCurrentUserAdmin) {
|
|
405
|
-
return "
|
|
450
|
+
return session.text(".adminOnly");
|
|
406
451
|
}
|
|
407
452
|
}
|
|
408
453
|
if (currentUserId !== caveMsg.userId && currentUserId !== caveMsg.originUserId && !isCurrentUserAdmin) {
|
|
409
|
-
return "
|
|
454
|
+
return session.text(".permissionDenied");
|
|
410
455
|
}
|
|
411
456
|
await ctx.database.remove("echo_cave", id);
|
|
412
|
-
return
|
|
457
|
+
return session.text(".msgDeleted", [id]);
|
|
413
458
|
}
|
|
414
459
|
async function addCave(ctx, session) {
|
|
415
460
|
if (!session.guildId) {
|
|
416
|
-
return "
|
|
461
|
+
return session.text("general.privateChatReminder");
|
|
417
462
|
}
|
|
418
463
|
if (!session.quote) {
|
|
419
|
-
return "
|
|
464
|
+
return session.text(".noMsgQuoted");
|
|
420
465
|
}
|
|
421
466
|
const { userId, channelId, quote } = session;
|
|
422
467
|
const messageId = quote.id;
|
|
@@ -442,7 +487,7 @@ async function addCave(ctx, session) {
|
|
|
442
487
|
}
|
|
443
488
|
await ctx.database.get("echo_cave", { content }).then((existing) => {
|
|
444
489
|
if (existing) {
|
|
445
|
-
return "
|
|
490
|
+
return session.text(".existingMsg");
|
|
446
491
|
}
|
|
447
492
|
});
|
|
448
493
|
try {
|
|
@@ -454,9 +499,9 @@ async function addCave(ctx, session) {
|
|
|
454
499
|
type,
|
|
455
500
|
content
|
|
456
501
|
});
|
|
457
|
-
return
|
|
502
|
+
return session.text(".msgSaved", [result.id]);
|
|
458
503
|
} catch (error) {
|
|
459
|
-
return "
|
|
504
|
+
return session.text(".msgFailedToSave");
|
|
460
505
|
}
|
|
461
506
|
}
|
|
462
507
|
// Annotate the CommonJS export names for ESM import in node:
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "koishi-plugin-echo-cave",
|
|
3
3
|
"description": "Group echo cave",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.8.0",
|
|
5
5
|
"main": "lib/index.cjs",
|
|
6
6
|
"typings": "lib/index.d.ts",
|
|
7
7
|
"type": "module",
|
|
@@ -23,6 +23,11 @@
|
|
|
23
23
|
"plugin",
|
|
24
24
|
"cave"
|
|
25
25
|
],
|
|
26
|
+
"koishi": {
|
|
27
|
+
"locales": [
|
|
28
|
+
"zh"
|
|
29
|
+
]
|
|
30
|
+
},
|
|
26
31
|
"peerDependencies": {
|
|
27
32
|
"koishi": "^4.18.9"
|
|
28
33
|
},
|