koishi-plugin-tmp-application-change 1.0.0 → 1.0.1
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.js +4 -4
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -32,7 +32,7 @@ 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
|
|
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) {
|
|
@@ -42,7 +42,7 @@ function apply(ctx, config) {
|
|
|
42
42
|
}
|
|
43
43
|
return next();
|
|
44
44
|
});
|
|
45
|
-
ctx.command("vtc
|
|
45
|
+
ctx.command("vtc申请 <recruitment_id:string> <status:string> [reason:string]", "VTC申请审批", {
|
|
46
46
|
authority: 1
|
|
47
47
|
}).action(async ({ session }, recruitmentId, status, reason) => {
|
|
48
48
|
try {
|
|
@@ -73,9 +73,9 @@ function apply(ctx, config) {
|
|
|
73
73
|
return `该申请已经审核过了,当前状态: ${application.status}`;
|
|
74
74
|
}
|
|
75
75
|
const action = statusLower === "同意" ? "hire" : "decline";
|
|
76
|
-
let approveUrl =
|
|
76
|
+
let approveUrl = config.approveApiUrl.replace("{recruitment_id}", recruitmentId).replace("{action}", action).replace("{token}", config.token);
|
|
77
77
|
if (statusLower === "拒绝") {
|
|
78
|
-
approveUrl +=
|
|
78
|
+
approveUrl += (approveUrl.includes("?") ? "&" : "?") + `reason=${encodeURIComponent(reason)}`;
|
|
79
79
|
}
|
|
80
80
|
logger.info(`执行审批: ${approveUrl}`);
|
|
81
81
|
const approveResponse = await ctx.http.get(approveUrl);
|