update
This commit is contained in:
@@ -59,6 +59,7 @@ app.route({
|
||||
repo: tool.schema.string().optional().describe('代码仓库名称, 如 my-user/my-repo'),
|
||||
issueNumber: tool.schema.number().describe('Issue 编号'),
|
||||
body: tool.schema.string().describe('评论内容'),
|
||||
clearAt: tool.schema.boolean().optional().describe('是否清除评论内容中的 @ 提及,默认: true'),
|
||||
},
|
||||
summary: '创建 Issue 评论',
|
||||
})
|
||||
@@ -67,7 +68,8 @@ app.route({
|
||||
const cnb = await cnbManager.getContext(ctx);
|
||||
let repo = ctx.query?.repo || useKey('CNB_REPO_SLUG_LOWERCASE');
|
||||
const issueNumber = ctx.query?.issueNumber;
|
||||
const body = ctx.query?.body;
|
||||
let body = ctx.query?.body;
|
||||
const clearAt = ctx.query?.clearAt ?? true;
|
||||
|
||||
if (!repo) {
|
||||
ctx.throw(400, '缺少参数 repo');
|
||||
@@ -78,6 +80,10 @@ app.route({
|
||||
if (!body) {
|
||||
ctx.throw(400, '缺少参数 body');
|
||||
}
|
||||
if (clearAt && body) {
|
||||
// 清除评论内容中的 @ 提及
|
||||
body = body.replace(/@/g, '');
|
||||
}
|
||||
|
||||
const res = await cnb.issue.createComment(repo, issueNumber, body);
|
||||
ctx.forward(res);
|
||||
@@ -138,6 +144,7 @@ app.route({
|
||||
issueNumber: tool.schema.number().describe('Issue 编号'),
|
||||
commentId: tool.schema.number().describe('评论 ID'),
|
||||
body: tool.schema.string().describe('评论内容'),
|
||||
clearAt: tool.schema.boolean().optional().describe('是否清除评论内容中的 @ 提及,默认: true'),
|
||||
},
|
||||
summary: '修改 Issue 评论',
|
||||
})
|
||||
@@ -147,8 +154,8 @@ app.route({
|
||||
let repo = ctx.query?.repo || useKey('CNB_REPO_SLUG_LOWERCASE');
|
||||
const issueNumber = ctx.query?.issueNumber;
|
||||
const commentId = ctx.query?.commentId;
|
||||
const body = ctx.query?.body;
|
||||
|
||||
let body = ctx.query?.body;
|
||||
const clearAt = ctx.query?.clearAt ?? true;
|
||||
if (!repo) {
|
||||
ctx.throw(400, '缺少参数 repo');
|
||||
}
|
||||
@@ -161,7 +168,10 @@ app.route({
|
||||
if (!body) {
|
||||
ctx.throw(400, '缺少参数 body');
|
||||
}
|
||||
|
||||
if (clearAt && body) {
|
||||
// 清除评论内容中的 @ 提及
|
||||
body = body.replace(/@/g, '');
|
||||
}
|
||||
const res = await cnb.issue.updateComment(repo, issueNumber, commentId, body);
|
||||
ctx.forward(res);
|
||||
}).addTo(app);
|
||||
|
||||
Reference in New Issue
Block a user