Skip to content

Commit 25ca82d

Browse files
committed
fix: gfi only for spam users
Signed-off-by: exploreriii <133720349+exploreriii@users.noreply.github.com>
1 parent 8312359 commit 25ca82d

2 files changed

Lines changed: 25 additions & 7 deletions

File tree

.github/scripts/bot-beginner-assign-on-comment.js

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -167,11 +167,31 @@ module.exports = async ({ github, context }) => {
167167
return; // Exit after warning
168168
}
169169

170+
// Block spam users from beginner issues
171+
172+
const spamUser = isSpamUser(commenter);
173+
174+
if (spamUser) {
175+
console.log(`[Beginner Bot] Spam user @${commenter} attempted to assign to beginner issue. Blocked.`);
176+
177+
try {
178+
await github.rest.issues.createComment({
179+
owner: repo.owner.login,
180+
repo: repo.name,
181+
issue_number: issue.number,
182+
body: `Hi @${commenter}, your account is currently restricted to **Good First Issues** issues. Please complete a Good First Issue or contact a maintainer to have restrictions reviewed.`,
183+
});
184+
} catch (error) {
185+
console.error(`[Beginner Bot] Failed to post spam restriction message: ${error.message}`);
186+
}
187+
188+
return;
189+
}
190+
170191
// Enforce Assignment Limits
171192

172193
const openCount = await getOpenAssignments(commenter);
173-
const spamUser = isSpamUser(commenter);
174-
const maxAllowed = spamUser ? 1 : 2;
194+
const maxAllowed = 2;
175195

176196
console.log("[Beginner Bot] Limit check:", {
177197
commenter,
@@ -181,9 +201,7 @@ module.exports = async ({ github, context }) => {
181201
});
182202

183203
if (openCount >= maxAllowed) {
184-
const message = spamUser
185-
? `👋 Hi @${commenter}, you are limited to **1 active beginner issue** at a time. Please complete your current assignment before requesting another.`
186-
: `👋 Hi @${commenter}, you already have **2 open assignments**. Please finish one before requesting another.`;
204+
const message = `👋 Hi @${commenter}, you already have **2 open assignments**. Please finish one before requesting another.`;
187205

188206
try {
189207
await github.rest.issues.createComment({
@@ -275,4 +293,4 @@ module.exports = async ({ github, context }) => {
275293
comment: context.payload?.comment?.id
276294
});
277295
}
278-
};
296+
};

.github/scripts/bot-gfi-assign-on-comment.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ module.exports = async ({ github, context }) => {
311311

312312
if (openCount >= maxAllowed) {
313313
const message = spamUser
314-
? `Hi @${requesterUsername}, you are limited to **1 active Good First Issue** at a time. Please complete your current assignment before requesting another.`
314+
? `Hi @${requesterUsername}, you are limited to **1 active issue** at a time. Please complete your current assignment before requesting another.`
315315
: `Hi @${requesterUsername}, you already have **2 open assignments**. Please finish one before requesting another.`;
316316

317317
await github.rest.issues.createComment({

0 commit comments

Comments
 (0)