koishi-plugin-tmp-application-change 1.0.0 → 1.0.2

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.
Files changed (2) hide show
  1. package/lib/index.js +7 -10
  2. package/package.json +1 -1
package/lib/index.js CHANGED
@@ -32,20 +32,17 @@ var Config = import_koishi.Schema.object({
32
32
  token: import_koishi.Schema.string().description("API访问令牌").required(),
33
33
  allowedGroups: import_koishi.Schema.array(import_koishi.Schema.string()).description("允许使用指令的群号列表").required(),
34
34
  checkApiUrl: import_koishi.Schema.string().description("查询申请状态的API地址").required(),
35
- approveApiUrl: import_koishi.Schema.string().description("审批申请的API地址").required()
35
+ approveApiUrl: import_koishi.Schema.string().description("审批申请的API地址模板,支持{recruitment_id}、{action}、{reason}占位符").required()
36
36
  });
37
37
  var logger = new import_koishi2.Logger("tmp-application-change");
38
38
  function apply(ctx, config) {
39
- ctx.middleware((session, next) => {
40
- if (!config.allowedGroups.includes(session.channelId.toString())) {
41
- return session.send("此群无权限使用此指令");
42
- }
43
- return next();
44
- });
45
- ctx.command("vtc-apply <recruitment_id:string> <status:string> [reason:string]", "VTC申请审批", {
39
+ ctx.command("vtc申请 <recruitment_id:string> <status:string> [reason:string]", "VTC申请审批", {
46
40
  authority: 1
47
41
  }).action(async ({ session }, recruitmentId, status, reason) => {
48
42
  try {
43
+ if (!config.allowedGroups.includes(session.channelId.toString())) {
44
+ return "此群无权限使用此指令";
45
+ }
49
46
  if (!recruitmentId || !status) {
50
47
  return "请提供完整的参数:recruitment_id 和 status";
51
48
  }
@@ -73,9 +70,9 @@ function apply(ctx, config) {
73
70
  return `该申请已经审核过了,当前状态: ${application.status}`;
74
71
  }
75
72
  const action = statusLower === "同意" ? "hire" : "decline";
76
- let approveUrl = `${config.approveApiUrl}?token=${config.token}&recruitment_id=${recruitmentId}&action=${action}`;
73
+ let approveUrl = config.approveApiUrl.replace("{recruitment_id}", recruitmentId).replace("{action}", action).replace("{token}", config.token);
77
74
  if (statusLower === "拒绝") {
78
- approveUrl += `&reason=${encodeURIComponent(reason)}`;
75
+ approveUrl += (approveUrl.includes("?") ? "&" : "?") + `reason=${encodeURIComponent(reason)}`;
79
76
  }
80
77
  logger.info(`执行审批: ${approveUrl}`);
81
78
  const approveResponse = await ctx.http.get(approveUrl);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koishi-plugin-tmp-application-change",
3
3
  "description": "truckersmp中vtc申请审批",
4
- "version": "1.0.0",
4
+ "version": "1.0.2",
5
5
  "contributors": [
6
6
  "opwop <slhp1013@qq.com>"
7
7
  ],