@meteorstream/koishi-plugin-auto-reply 0.0.6 → 0.0.7

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 CHANGED
@@ -4,6 +4,8 @@ export interface Config {
4
4
  }
5
5
  export declare const Config: Schema<Schemastery.ObjectS<{
6
6
  debugger: Schema<boolean, boolean>;
7
+ sendErrMsg: Schema<boolean, boolean>;
8
+ errMsg: Schema<string, string>;
7
9
  }> | Schemastery.ObjectS<{
8
10
  replyList: Schema<Schemastery.ObjectS<{
9
11
  command: Schema<string, string>;
@@ -34,6 +36,8 @@ export declare const Config: Schema<Schemastery.ObjectS<{
34
36
  }>[]>;
35
37
  }>, {
36
38
  debugger: boolean;
39
+ sendErrMsg: boolean;
40
+ errMsg: string;
37
41
  } & import("cosmokit").Dict & {
38
42
  replyList: Schemastery.ObjectT<{
39
43
  command: Schema<string, string>;
package/lib/index.js CHANGED
@@ -41,6 +41,11 @@ var fs = __toESM(require("fs/promises"));
41
41
  var path = __toESM(require("path"));
42
42
  var name = "auto-reply";
43
43
  var Config = import_koishi.Schema.intersect([
44
+ import_koishi.Schema.object({
45
+ debugger: import_koishi.Schema.boolean().default(false).description("日志调试模式"),
46
+ sendErrMsg: import_koishi.Schema.boolean().default(false).description("相应失败时是否发送文字提示"),
47
+ errMsg: import_koishi.Schema.string().default("发生错误").description("相应失败时发送的文字提示")
48
+ }).description("开发者选项"),
44
49
  import_koishi.Schema.object({
45
50
  replyList: import_koishi.Schema.array(import_koishi.Schema.object({
46
51
  command: import_koishi.Schema.string().description("指令"),
@@ -53,10 +58,7 @@ var Config = import_koishi.Schema.intersect([
53
58
  })).description("响应情况").role("table")
54
59
  })).description("响应指令").role("table")
55
60
  // exitCommandList: Schema.array(String).role('table').description('退出选择指令。<br>一行一个指令(此指令 在歌单内容中默认没有使用提示)').default(["0", "不听了"]),
56
- }),
57
- import_koishi.Schema.object({
58
- debugger: import_koishi.Schema.boolean().default(false).description("日志调试模式")
59
- }).description("开发者选项")
61
+ })
60
62
  ]);
61
63
  var lastUserIndexMap = /* @__PURE__ */ new Map();
62
64
  function apply(ctx, config) {
@@ -82,21 +84,28 @@ function apply(ctx, config) {
82
84
  }
83
85
  link = match.address[index].source == "本地" ? (0, import_url.pathToFileURL)(path.join(root, match.address[index].link)).href : match.address[index].link;
84
86
  logInfo(`匹配到指令[${match.command}]${match.mode}[${index}]:${link}`);
85
- switch (match.address[index].fileType) {
86
- case "文本":
87
- session.send(link);
88
- break;
89
- case "图片":
90
- session.send(import_koishi.h.image(link));
91
- break;
92
- case "视频":
93
- session.send(import_koishi.h.video(link));
94
- break;
95
- case "音频":
96
- session.send(import_koishi.h.audio(link));
97
- break;
98
- default:
99
- session.send(link);
87
+ try {
88
+ switch (match.address[index].fileType) {
89
+ case "文本":
90
+ session.send(link);
91
+ break;
92
+ case "图片":
93
+ session.send(import_koishi.h.image(link));
94
+ break;
95
+ case "视频":
96
+ session.send(import_koishi.h.video(link));
97
+ break;
98
+ case "音频":
99
+ session.send(import_koishi.h.audio(link));
100
+ break;
101
+ default:
102
+ session.send(link);
103
+ }
104
+ } catch (error) {
105
+ if (config.sendErrMsg) {
106
+ session.send(config.errMsg);
107
+ }
108
+ logInfo("发送失败:", error);
100
109
  }
101
110
  }
102
111
  });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@meteorstream/koishi-plugin-auto-reply",
3
3
  "description": "meteorstream自用",
4
- "version": "0.0.6",
4
+ "version": "0.0.7",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "files": [