koishi-plugin-smmcat-selfhelp 0.0.2 → 0.0.3

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
@@ -5,5 +5,6 @@ export interface Config {
5
5
  overtime: number;
6
6
  debug: boolean;
7
7
  }
8
+ export declare const usage = "\n\u901A\u8FC7\u521B\u5EFA\u6587\u4EF6\u5939\u751F\u6210\u5BF9\u5E94\u6620\u5C04\u5173\u7CFB\u7684\u591A\u7EA7\u83DC\u5355\u9009\u9879\u7684\u7B80\u5355\u81EA\u52A9\u83DC\u5355\u63D2\u4EF6\n\n - result.text \u4E2D\u7684\u5185\u5BB9\u4EE3\u8868\u6700\u7EC8\u7684\u56DE\u590D\n - title.text \u4E2D\u7684\u5185\u5BB9\u4EE3\u8868\u8BE5\u5C42\u7EA7\u83DC\u5355\u7684\u6807\u9898\n\n\u53EA\u8981\u4E0A\u8FF0\u6587\u4EF6\u653E\u7F6E\u5728\u5BF9\u5E94\u6587\u4EF6\u5939\u4E2D\uFF0C\u5C31\u4F1A\u6709\u5BF9\u5E94\u7684\u6548\u679C\n";
8
9
  export declare const Config: Schema<Config>;
9
10
  export declare function apply(ctx: Context, config: Config): void;
package/lib/index.js CHANGED
@@ -32,7 +32,8 @@ var src_exports = {};
32
32
  __export(src_exports, {
33
33
  Config: () => Config,
34
34
  apply: () => apply,
35
- name: () => name
35
+ name: () => name,
36
+ usage: () => usage
36
37
  });
37
38
  module.exports = __toCommonJS(src_exports);
38
39
  var import_koishi = require("koishi");
@@ -86,6 +87,14 @@ var createDirMapByObject = /* @__PURE__ */ __name((folders, parentPath) => {
86
87
 
87
88
  // src/index.ts
88
89
  var name = "smmcat-selfhelp";
90
+ var usage = `
91
+ 通过创建文件夹生成对应映射关系的多级菜单选项的简单自助菜单插件
92
+
93
+ - result.text 中的内容代表最终的回复
94
+ - title.text 中的内容代表该层级菜单的标题
95
+
96
+ 只要上述文件放置在对应文件夹中,就会有对应的效果
97
+ `;
89
98
  var Config = import_koishi.Schema.object({
90
99
  mapAddress: import_koishi.Schema.string().default("./data/selfHelp").description("菜单结构放置位置"),
91
100
  overtime: import_koishi.Schema.number().default(3e4).description("菜单访问的超时时间"),
@@ -105,7 +114,7 @@ function apply(ctx, config) {
105
114
  { name: "2.无法访问插件市场", child: import_koishi.h.image("https://static.kivo.wiki/images/students/%E9%99%86%E5%85%AB%E9%AD%94%20%E9%98%BF%E9%9C%B2/gallery/%E5%88%9D%E5%A7%8B%E7%AB%8B%E7%BB%98%E5%B7%AE%E5%88%86/QQ%E6%88%AA%E5%9B%BE20211115183224.png?x-oss-process=image/resize,h_130") + "在 market 插件的配置项设置镜像源" }
106
115
  ]
107
116
  },
108
- { name: "1.插件问题", child: import_koishi.h.image("https://static.kivo.wiki/images/students/%E9%99%86%E5%85%AB%E9%AD%94%20%E9%98%BF%E9%9C%B2/gallery/%E5%88%9D%E5%A7%8B%E7%AB%8B%E7%BB%98%E5%B7%AE%E5%88%86/QQ%E6%88%AA%E5%9B%BE20211115183321.png?x-oss-process=image/resize,h_130") + "插件问题找插件作者啊" }
117
+ { name: "2.插件问题", child: import_koishi.h.image("https://static.kivo.wiki/images/students/%E9%99%86%E5%85%AB%E9%AD%94%20%E9%98%BF%E9%9C%B2/gallery/%E5%88%9D%E5%A7%8B%E7%AB%8B%E7%BB%98%E5%B7%AE%E5%88%86/QQ%E6%88%AA%E5%9B%BE20211115183321.png?x-oss-process=image/resize,h_130") + "插件问题找插件作者啊" }
109
118
  ]
110
119
  },
111
120
  {
@@ -173,19 +182,19 @@ function apply(ctx, config) {
173
182
  selectMenu = void 0;
174
183
  indePath.pop();
175
184
  PathName.pop();
176
- callback && callback({ selectMenu, lastPath: indePath.join("-"), crumbs: PathName.slice(-3).join(">"), end });
185
+ callback && callback({ selectMenu, lastPath: indePath.join("-"), crumbs: PathName.slice(-3).reverse().join("<"), end });
177
186
  return true;
178
187
  }
179
188
  if (selectMenu && typeof selectMenu === "object") {
180
189
  selectMenu = selectMenu[item - 1].child;
181
190
  if (typeof selectMenu === "string") {
182
191
  end = true;
183
- callback && callback({ selectMenu, lastPath: indePath.join("-"), crumbs: PathName.slice(-3).join(">"), end });
192
+ callback && callback({ selectMenu, lastPath: indePath.join("-"), crumbs: PathName.slice(-3).reverse().join("<"), end });
184
193
  return true;
185
194
  }
186
195
  }
187
196
  });
188
- end || callback && callback({ selectMenu, title, lastPath: indePath.join("-"), crumbs: PathName.slice(-3).join(">"), end });
197
+ end || callback && callback({ selectMenu, title, lastPath: indePath.join("-"), crumbs: PathName.reverse().slice(-3).join("<"), end });
189
198
  },
190
199
  // 菜单渲染到界面
191
200
  markScreen(pathLine) {
@@ -206,7 +215,7 @@ function apply(ctx, config) {
206
215
  return {
207
216
  msg: goalItem.selectMenu.replace(/\\/g, "") + (goalItem.crumbs ? `
208
217
 
209
- [当前位置] ${goalItem.crumbs}` : "\n\n主菜单") + "\n#.上页\n0.退出",
218
+ [当前位置] ${goalItem.crumbs}` : "\n\n主菜单") + "\n\n#. 上页\n=. 首页\n0. 退出",
210
219
  err: false
211
220
  };
212
221
  } else {
@@ -216,7 +225,7 @@ ${goalItem.crumbs}
216
225
  ` : "主菜单\n") + `----------------------------
217
226
  ` + (goalItem.title ? `${goalItem.title}
218
227
 
219
- ` : "") + `${goalItem.selectMenu.map((item) => item.name).join("\n") + "\n\n#.上页\n0.退出"}
228
+ ` : "") + `${goalItem.selectMenu.map((item) => item.name).join("\n") + "\n\n#. 上页\n=. 首页\n0. 退出"}
220
229
  ----------------------------
221
230
  `,
222
231
  err: false
@@ -224,44 +233,42 @@ ${goalItem.crumbs}
224
233
  }
225
234
  }
226
235
  };
227
- const useUserList = {};
228
236
  ctx.on("ready", () => {
229
237
  selfhelpMap.init();
230
238
  });
239
+ const useUserList = {};
240
+ const closeUserHelp = {};
231
241
  ctx.command("自助菜单").action(async ({ session }) => {
232
- await session.send("请回复任意内容进入自助菜单环节");
233
- useUserList[session.userId] = true;
234
- });
235
- ctx.middleware(async (session, next) => {
236
- if (!useUserList[session.userId]) {
237
- return next();
238
- }
239
242
  const proce = [];
240
243
  while (true) {
241
- if (!useUserList[session.userId]) {
242
- break;
243
- }
244
244
  const data = selfhelpMap.markScreen(proce.join("-"));
245
245
  if (data.err) {
246
246
  proce.pop();
247
247
  const data2 = selfhelpMap.markScreen(proce.join("-"));
248
- await session.send("操作不对,请重新输入:\n注意需要输入指定下标");
248
+ await session.send("操作不对,请重新输入:\n注意需要输入指定范围的下标");
249
249
  await session.send(data2.msg);
250
250
  }
251
251
  await session.send(data.msg);
252
252
  const res = await session.prompt(config.overtime);
253
+ if (res === void 0) {
254
+ break;
255
+ }
256
+ if (isNaN(Number(res)) && res !== "#" && res !== "=") {
257
+ await session.send("请输入指定序号下标");
258
+ continue;
259
+ }
253
260
  if (!res || res == "0") {
254
- useUserList[session.userId] = false;
255
261
  res == "0" && await session.send("已退出自助服务");
256
262
  break;
257
263
  }
258
- if (res == "#") {
264
+ if (res === "#") {
259
265
  proce.pop();
266
+ } else if (res === "=") {
267
+ proce.length = 0;
260
268
  } else {
261
269
  proce.push(res);
262
270
  }
263
271
  }
264
- return next();
265
272
  });
266
273
  }
267
274
  __name(apply, "apply");
@@ -269,5 +276,6 @@ __name(apply, "apply");
269
276
  0 && (module.exports = {
270
277
  Config,
271
278
  apply,
272
- name
279
+ name,
280
+ usage
273
281
  });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koishi-plugin-smmcat-selfhelp",
3
3
  "description": "用户自助服务系统",
4
- "version": "0.0.2",
4
+ "version": "0.0.3",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "files": [