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

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,6 +5,7 @@ export interface Config {
5
5
  allowedGroups: string[];
6
6
  checkApiUrl: string;
7
7
  approveApiUrl: string;
8
+ declineApiUrl: string;
8
9
  }
9
10
  export declare const Config: Schema<Config>;
10
11
  export declare function apply(ctx: Context, config: Config): void;
package/lib/index.js CHANGED
@@ -32,7 +32,8 @@ 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地址模板,支持{recruitment_id}、{action}、{reason}占位符").required()
35
+ approveApiUrl: import_koishi.Schema.string().description("同意申请的API地址模板,支持{recruitment_id}、{action}、{token}占位符").required(),
36
+ declineApiUrl: import_koishi.Schema.string().description("拒绝申请的API地址模板,支持{recruitment_id}、{action}、{reason}、{token}占位符").required()
36
37
  });
37
38
  var logger = new import_koishi2.Logger("tmp-application-change");
38
39
  function apply(ctx, config) {
@@ -69,19 +70,26 @@ function apply(ctx, config) {
69
70
  if (application.status !== "New") {
70
71
  return `该申请已经审核过了,当前状态: ${application.status}`;
71
72
  }
72
- const action = statusLower === "同意" ? "hire" : "decline";
73
- let approveUrl = config.approveApiUrl.replace("{recruitment_id}", recruitmentId).replace("{action}", action).replace("{token}", config.token);
74
- if (statusLower === "拒绝") {
75
- approveUrl += (approveUrl.includes("?") ? "&" : "?") + `reason=${encodeURIComponent(reason)}`;
76
- }
77
- logger.info(`执行审批: ${approveUrl}`);
78
- const approveResponse = await ctx.http.get(approveUrl);
79
- logger.info(`审批响应: ${JSON.stringify(approveResponse)}`);
80
- if (approveResponse.code === 200) {
81
- const successMsg = statusLower === "同意" ? "同意成功" : "拒绝成功";
82
- return `${successMsg},申请ID: ${recruitmentId}`;
73
+ if (statusLower === "同意") {
74
+ let approveUrl = config.approveApiUrl.replace("{recruitment_id}", recruitmentId).replace("{action}", "hire").replace("{token}", config.token);
75
+ logger.info(`执行同意审批: ${approveUrl}`);
76
+ const approveResponse = await ctx.http.get(approveUrl);
77
+ logger.info(`同意审批响应: ${JSON.stringify(approveResponse)}`);
78
+ if (approveResponse.code === 200) {
79
+ return `同意成功,申请ID: ${recruitmentId}`;
80
+ } else {
81
+ return `同意失败: ${approveResponse.msg || "未知错误"}`;
82
+ }
83
83
  } else {
84
- return `审批失败: ${approveResponse.msg || "未知错误"}`;
84
+ let declineUrl = config.declineApiUrl.replace("{recruitment_id}", recruitmentId).replace("{action}", "decline").replace("{reason}", encodeURIComponent(reason)).replace("{token}", config.token);
85
+ logger.info(`执行拒绝审批: ${declineUrl}`);
86
+ const declineResponse = await ctx.http.get(declineUrl);
87
+ logger.info(`拒绝审批响应: ${JSON.stringify(declineResponse)}`);
88
+ if (declineResponse.code === 200) {
89
+ return `拒绝成功,申请ID: ${recruitmentId}`;
90
+ } else {
91
+ return `拒绝失败: ${declineResponse.msg || "未知错误"}`;
92
+ }
85
93
  }
86
94
  } catch (error) {
87
95
  logger.error("处理VTC申请时发生错误:", error);
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.2",
4
+ "version": "1.0.4",
5
5
  "contributors": [
6
6
  "opwop <slhp1013@qq.com>"
7
7
  ],