koishi-plugin-echo-cave 1.8.0 → 1.9.1
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 +48 -23
- package/lib/index.d.ts +2 -0
- package/package.json +1 -1
package/lib/index.cjs
CHANGED
|
@@ -34,7 +34,9 @@ var require_zh_CN = __commonJS({
|
|
|
34
34
|
"src/locales/zh-CN.json"(exports2, module2) {
|
|
35
35
|
module2.exports = {
|
|
36
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"
|
|
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
|
+
allowContributorDelete: "\u5141\u8BB8\u6295\u7A3F\u8005\u5220\u9664\u81EA\u5DF1\u6295\u7A3F\u7684\u56DE\u58F0\u6D1E",
|
|
39
|
+
allowSenderDelete: "\u5141\u8BB8\u539F\u59CB\u53D1\u9001\u8005\u5220\u9664\u88AB\u6295\u7A3F\u7684\u56DE\u58F0\u6D1E"
|
|
38
40
|
},
|
|
39
41
|
general: {
|
|
40
42
|
privateChatReminder: "\u274C \u8BF7\u5728\u7FA4\u804A\u4E2D\u4F7F\u7528\u8BE5\u547D\u4EE4\uFF01",
|
|
@@ -61,9 +63,17 @@ var require_zh_CN = __commonJS({
|
|
|
61
63
|
messages: {
|
|
62
64
|
noIdProvided: "\u274C \u8BF7\u63D0\u4F9B\u8981\u5220\u9664\u7684\u56DE\u58F0\u6D1E\u6D88\u606F ID\uFF01",
|
|
63
65
|
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\
|
|
66
|
+
permissionDenied: "\u26D4 \u60A8\u6CA1\u6709\u6743\u9650\u5220\u9664\u6B64\u6D88\u606F\uFF01\u53EA\u6709\u7BA1\u7406\u5458\u53EF\u4EE5\u5220\u9664\u3002",
|
|
67
|
+
contributorDeleteDenied: "\u26D4 \u60A8\u6CA1\u6709\u6743\u9650\u5220\u9664\u6B64\u6D88\u606F\uFF01\u5F53\u524D\u914D\u7F6E\u4E0D\u5141\u8BB8\u6295\u7A3F\u8005\u5220\u9664\u56DE\u58F0\u6D1E\u3002",
|
|
68
|
+
senderDeleteDenied: "\u26D4 \u60A8\u6CA1\u6709\u6743\u9650\u5220\u9664\u6B64\u6D88\u606F\uFF01\u5F53\u524D\u914D\u7F6E\u4E0D\u5141\u8BB8\u539F\u59CB\u53D1\u9001\u8005\u5220\u9664\u56DE\u58F0\u6D1E\u3002",
|
|
65
69
|
msgDeleted: "\u2705 \u5DF2\u6210\u529F\u62B9\u53BB\u56DE\u58F0\u6D1E\u6D88\u606F ID\uFF1A{0}"
|
|
66
70
|
}
|
|
71
|
+
},
|
|
72
|
+
"cave.listen": {
|
|
73
|
+
description: "\u83B7\u5F97\u7531\u81EA\u5DF1\u6295\u7A3F\u7684\u56DE\u58F0\u6D1E\u5217\u8868",
|
|
74
|
+
messages: {
|
|
75
|
+
noMsgContributed: '\u{1F680} \u60A8\u5728\u56DE\u58F0\u6D1E\u4E2D\u6682\u65E0\u6295\u7A3F\uFF0C\u5FEB\u4F7F\u7528 "cave.echo" \u547D\u4EE4\u6DFB\u52A0\u7B2C\u4E00\u6761\u6D88\u606F\u5427\uFF01'
|
|
76
|
+
}
|
|
67
77
|
}
|
|
68
78
|
}
|
|
69
79
|
};
|
|
@@ -296,20 +306,25 @@ async function processForwardMessageContent(ctx, msg) {
|
|
|
296
306
|
|
|
297
307
|
// src/msg-helper.ts
|
|
298
308
|
async function processMessageContent(ctx, msg) {
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
309
|
+
const result = [];
|
|
310
|
+
for (const element of msg) {
|
|
311
|
+
if (element.type === "reply") {
|
|
312
|
+
continue;
|
|
313
|
+
}
|
|
314
|
+
if (element.type === "image") {
|
|
315
|
+
const newUrl = await saveImages(ctx, element.data);
|
|
316
|
+
result.push({
|
|
317
|
+
...element,
|
|
318
|
+
data: {
|
|
319
|
+
...element.data,
|
|
320
|
+
url: newUrl
|
|
321
|
+
}
|
|
322
|
+
});
|
|
323
|
+
} else {
|
|
324
|
+
result.push(element);
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
return result;
|
|
313
328
|
}
|
|
314
329
|
|
|
315
330
|
// src/index.ts
|
|
@@ -320,7 +335,9 @@ var import_node_path2 = __toESM(require("node:path"), 1);
|
|
|
320
335
|
var name = "echo-cave";
|
|
321
336
|
var inject = ["database"];
|
|
322
337
|
var Config = import_koishi.Schema.object({
|
|
323
|
-
adminMessageProtection: import_koishi.Schema.boolean().default(false)
|
|
338
|
+
adminMessageProtection: import_koishi.Schema.boolean().default(false),
|
|
339
|
+
allowContributorDelete: import_koishi.Schema.boolean().default(true),
|
|
340
|
+
allowSenderDelete: import_koishi.Schema.boolean().default(true)
|
|
324
341
|
}).i18n({
|
|
325
342
|
"zh-CN": require_zh_CN().config
|
|
326
343
|
});
|
|
@@ -354,9 +371,7 @@ function apply(ctx, cfg) {
|
|
|
354
371
|
ctx.command("cave.wipe <id:number>").action(
|
|
355
372
|
async ({ session }, id) => await deleteCave(ctx, session, cfg, id)
|
|
356
373
|
);
|
|
357
|
-
ctx.command("cave.listen"
|
|
358
|
-
async ({ session }) => await getCaveListByUser(ctx, session)
|
|
359
|
-
);
|
|
374
|
+
ctx.command("cave.listen").action(async ({ session }) => await getCaveListByUser(ctx, session));
|
|
360
375
|
ctx.command("cave.trace", "\u83B7\u5F97\u81EA\u5DF1\u53D1\u8A00\u7684\u56DE\u58F0\u6D1E\u5217\u8868").action(
|
|
361
376
|
async ({ session }) => await getCaveListByOriginUser(ctx, session)
|
|
362
377
|
);
|
|
@@ -371,7 +386,7 @@ async function getCaveListByUser(ctx, session) {
|
|
|
371
386
|
channelId
|
|
372
387
|
});
|
|
373
388
|
if (caves.length === 0) {
|
|
374
|
-
return
|
|
389
|
+
return session.text(".noMsgContributed");
|
|
375
390
|
}
|
|
376
391
|
let response = `\u{1F4DC} \u60A8\u5728\u672C\u9891\u9053\u6295\u7A3F\u7684\u56DE\u58F0\u6D1E\u6D88\u606F\u5217\u8868\uFF1A
|
|
377
392
|
`;
|
|
@@ -450,8 +465,18 @@ async function deleteCave(ctx, session, cfg, id) {
|
|
|
450
465
|
return session.text(".adminOnly");
|
|
451
466
|
}
|
|
452
467
|
}
|
|
453
|
-
if (
|
|
454
|
-
|
|
468
|
+
if (!isCurrentUserAdmin) {
|
|
469
|
+
if (currentUserId === caveMsg.userId) {
|
|
470
|
+
if (!cfg.allowContributorDelete) {
|
|
471
|
+
return session.text(".contributorDeleteDenied");
|
|
472
|
+
}
|
|
473
|
+
} else if (currentUserId === caveMsg.originUserId) {
|
|
474
|
+
if (!cfg.allowSenderDelete) {
|
|
475
|
+
return session.text(".senderDeleteDenied");
|
|
476
|
+
}
|
|
477
|
+
} else {
|
|
478
|
+
return session.text(".permissionDenied");
|
|
479
|
+
}
|
|
455
480
|
}
|
|
456
481
|
await ctx.database.remove("echo_cave", id);
|
|
457
482
|
return session.text(".msgDeleted", [id]);
|
package/lib/index.d.ts
CHANGED
|
@@ -4,6 +4,8 @@ export declare const name = "echo-cave";
|
|
|
4
4
|
export declare const inject: string[];
|
|
5
5
|
export interface Config {
|
|
6
6
|
adminMessageProtection?: boolean;
|
|
7
|
+
allowContributorDelete?: boolean;
|
|
8
|
+
allowSenderDelete?: boolean;
|
|
7
9
|
}
|
|
8
10
|
export declare const Config: Schema<Config>;
|
|
9
11
|
export interface EchoCave {
|