Skip to content

Commit 674963e

Browse files
committed
fix(bot): 校验失败也打标签并 @ 作者
1 parent ff3af4a commit 674963e

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

‎scripts/intake.mjs‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ const issue = event.issue;
1717

1818
if (!issue) process.exit(0);
1919

20+
const at = issue.user?.login ? `@${issue.user.login} ` : "";
21+
2022
async function gh(method, path, payload) {
2123
return fetch(`${api}${path}`, {
2224
method,
@@ -41,7 +43,8 @@ const source_url = urls.find((u) =>
4143
);
4244

4345
if (!source_url) {
44-
await comment("⚠️ 未找到脚本。请把 `.js` 拖进文本框上传,或粘贴脚本 raw 直链,然后编辑本 issue 重新校验。");
46+
await setStatus(false);
47+
await comment(`${at}⚠️ 未找到脚本。请把 \`.js\` 拖进文本框上传,或粘贴脚本 raw 直链,然后编辑本 issue 重新校验。`);
4548
process.exit(0);
4649
}
4750

@@ -52,14 +55,15 @@ try {
5255
if (!res.ok) throw new Error(`HTTP ${res.status}`);
5356
source = await res.text();
5457
} catch (err) {
55-
await comment(`❌ 拉取脚本失败:${err.message}`);
58+
await setStatus(false);
59+
await comment(`${at}❌ 拉取脚本失败:${err.message}`);
5660
process.exit(0);
5761
}
5862

5963
const { id, header, errors } = validateSource(source);
6064
if (errors.length) {
6165
await setStatus(false);
62-
await comment("❌ 校验未通过:\n" + errors.map((e) => `- ${e}`).join("\n") + "\n\n修正后编辑本 issue 重新校验。");
66+
await comment(`${at}❌ 校验未通过:\n` + errors.map((e) => `- ${e}`).join("\n") + "\n\n修正后编辑本 issue 重新校验。");
6367
process.exit(0);
6468
}
6569

@@ -114,5 +118,5 @@ if (pr?.number) {
114118
await setStatus(true);
115119

116120
const note = is_update ? `更新 v${old_version} → v${version}` : "新插件";
117-
await comment(`✅ 校验通过,${note},已提交 PR 待维护者审查:${pr?.html_url ?? "PR 创建失败"}`);
121+
await comment(`${at}✅ 校验通过,${note},已提交 PR 待维护者审查:${pr?.html_url ?? "PR 创建失败"}`);
118122
console.log("done", id, pr?.html_url);

0 commit comments

Comments
 (0)