This commit is contained in:
Ciro Santilli
2021-04-16 17:00:16 +00:00
parent 79b7b5b8fe
commit 94d02ac19b

View File

@@ -58,16 +58,31 @@ ${quoteArray.join('\n')}
${full_images.join('\n\n')} ${full_images.join('\n\n')}
`; `;
const newLabels = []; // Label handling.
const existingLabels = payload.issue.labels.map(label => label.name); const labels = new Set(payload.issue.labels.map(label => label.name));
console.log(existingLabels); const newLabels = new Set();
if (/傻逼/i.test(titleAndBody)) { if (/傻逼/i.test(titleAndBody)) {
newLabels.push('you-are-stupid-argument'); newLabels.add('you-are-stupid-argument');
} }
if (newLabels.length > 0) { if (/nmsl/i.test(titleAndBody)) {
newLabels.push('shitpost'); newLabels.add('your-mother-died-argument');
}
const shitpostWords = [
'fuck',
'shit',
];
for (const word of shitpostWords) {
if (new RegExp(word, 'i').test(titleAndBody)) {
newLabels.add('shitpost');
break;
}
}
if (newLabels.size > 0) {
newLabels.add('shitpost');
labels.delete('not-shitpost');
} }
// Make the request.
try { try {
console.log(github.context); console.log(github.context);
const octokit = new github.getOctokit(process.env.GITHUB_TOKEN); const octokit = new github.getOctokit(process.env.GITHUB_TOKEN);
@@ -81,7 +96,7 @@ try {
owner: 'cirosantilli', owner: 'cirosantilli',
repo: payload.repository.name, repo: payload.repository.name,
issue_number: payload.issue.number, issue_number: payload.issue.number,
labels: newLabels labels: Array.from([...labels, ...newLabels])
}); });
} catch (error) { } catch (error) {
core.setFailed(error.message); core.setFailed(error.message);