fix new issue bot

This commit is contained in:
Ciro Santilli
2022-08-02 23:01:07 +00:00
parent 2d8f978472
commit 43be8544cb

View File

@@ -59,9 +59,12 @@ if (isComment) {
author = payload.issue.user.login; author = payload.issue.user.login;
} }
const quoteArray = []; const quoteArray = [];
const noQuoteArray = [];
for (const line of titleAndBody.split('\n')) { for (const line of titleAndBody.split('\n')) {
// Remove some speical chars to remove at mention spam possibilities. // Remove some speical chars to remove at mention spam possibilities.
quoteArray.push('> ' + line.replace(/[@#]/g, "")); const l = line.replace(/[@#]/g, "")
quoteArray.push('> ' + l);
noQuoteArray.push(l);
} }
const replyBody = `Hi @${author}, const replyBody = `Hi @${author},
@@ -170,12 +173,12 @@ try {
body: replyBody, body: replyBody,
}); });
if (isComment) { if (isComment) {
const title = (`@${author}: ` + replyBody.replaceAll('\n', ' ')).substring(0, 255) const title = (`@${author}: ` + quoteArray.join('\n').replaceAll('\n', ' ')).substring(0, 255)
const new_issue = octokit.issues.create({ const new_issue = octokit.issues.create({
owner: payload.repository.owner.login, owner: payload.repository.owner.login,
repo: payload.repository.name, repo: payload.repository.name,
title, title,
body: replyBody, body: payload.comment.html_url + '\n\n' + replyBody,
}) })
} else { } else {
// Update labels. // Update labels.