koishi-plugin-echo-cave 1.8.0 → 1.9.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 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,7 +63,9 @@ 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\u6D88\u606F\u7684\u5B58\u50A8\u8005\u3001\u539F\u59CB\u53D1\u9001\u8005\u6216\u7BA1\u7406\u5458\u53EF\u4EE5\u5220\u9664\u3002",
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
  }
67
71
  }
@@ -320,7 +324,9 @@ var import_node_path2 = __toESM(require("node:path"), 1);
320
324
  var name = "echo-cave";
321
325
  var inject = ["database"];
322
326
  var Config = import_koishi.Schema.object({
323
- adminMessageProtection: import_koishi.Schema.boolean().default(false)
327
+ adminMessageProtection: import_koishi.Schema.boolean().default(false),
328
+ allowContributorDelete: import_koishi.Schema.boolean().default(true),
329
+ allowSenderDelete: import_koishi.Schema.boolean().default(true)
324
330
  }).i18n({
325
331
  "zh-CN": require_zh_CN().config
326
332
  });
@@ -450,8 +456,18 @@ async function deleteCave(ctx, session, cfg, id) {
450
456
  return session.text(".adminOnly");
451
457
  }
452
458
  }
453
- if (currentUserId !== caveMsg.userId && currentUserId !== caveMsg.originUserId && !isCurrentUserAdmin) {
454
- return session.text(".permissionDenied");
459
+ if (!isCurrentUserAdmin) {
460
+ if (currentUserId === caveMsg.userId) {
461
+ if (!cfg.allowContributorDelete) {
462
+ return session.text(".contributorDeleteDenied");
463
+ }
464
+ } else if (currentUserId === caveMsg.originUserId) {
465
+ if (!cfg.allowSenderDelete) {
466
+ return session.text(".senderDeleteDenied");
467
+ }
468
+ } else {
469
+ return session.text(".permissionDenied");
470
+ }
455
471
  }
456
472
  await ctx.database.remove("echo_cave", id);
457
473
  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 {
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.8.0",
4
+ "version": "1.9.0",
5
5
  "main": "lib/index.cjs",
6
6
  "typings": "lib/index.d.ts",
7
7
  "type": "module",