Skip to content

Add spam-guard workflow: 限制新号在 issue/discussion 留言#2

Merged
wuwangzhang1216 merged 1 commit into
mainfrom
chore/spam-guard
May 31, 2026
Merged

Add spam-guard workflow: 限制新号在 issue/discussion 留言#2
wuwangzhang1216 merged 1 commit into
mainfrom
chore/spam-guard

Conversation

@wuwangzhang1216

@wuwangzhang1216 wuwangzhang1216 commented May 31, 2026

Copy link
Copy Markdown
Contributor

目的

限制新号/垃圾号在 issue 和 discussion 的垃圾留言。「新号」定义:注册 < 3 个月(默认 90 天)。

⚠️ GitHub 内置 interaction limit 只有 existing_users(写死 24h)/contributors_only/collaborators_only 三档,无法按月龄。所以「<3 个月」这条规则由本 PR 的 workflow 执行(读账号 created_at);内置 limit 仅作为 24h 的免费平台级预拦截保留。

第一层 — 内置 interaction limit(已生效,不在本 PR 内)

limit = existing_users   # 平台层拦住 <24h 的全新号(issue/PR)
到期 = 2026-11-30
  • 覆盖 issue/PR 的开贴、评论、reaction、编辑;不覆盖 Discussions,最长 6 个月到期。
  • 撤销:gh api -X DELETE repos/opendb-ai/openDB/interaction-limits

第二层 — 本 PR:.github/workflows/spam-guard.yml

issue / PR / discussion 的新发帖和评论自动审核,真正落实「<3 个月 = 新号」,并补上 Discussions 覆盖 + 永久生效。

判定:同时满足才动手 ——

  1. 作者账号年龄 < NEW_ACCOUNT_MAX_AGE_DAYS(默认 90 天 ≈ 3 个月);
  2. 作者不是 collaborator / member / 历史贡献者;
  3. 不是 bot。

动作(全部可逆):

对象 默认动作
issue / discussion 评论 隐藏为 spam(minimize)
新 issue possible-spam 标签 + 留言说明 + 锁帖
新 discussion 锁帖

可调开关(workflow 内 env:):NEW_ACCOUNT_MAX_AGE_DAYS(改月龄阈值)、MINIMIZE_COMMENTSLOCK_NEW_THREADSCLOSE_NEW_THREADS(默认关)、SPAM_LABEL

注意

  • ⚠️ 阈值放宽到 3 个月后,会连带挡到一些注册不久的正常新人(比如 2 个月前注册、第一次来提 issue 的用户)——他们的帖子会被锁、评论会被隐藏(均可逆)。若想温和些,把 LOCK_NEW_THREADS 设为 false(只打标签 + 留言、交人工复核)。
  • ⚠️ 本仓库目前 Discussions 未开启(has_discussions=false),discussion.* 触发器暂不会触发;开启后无需改动即自动生效。
  • workflow 必须合并到默认分支 main 后,discussion 等事件才会派发 —— 合并即激活。
  • 权限最小化:仅用 GITHUB_TOKENissues: write / discussions: write,无需任何额外 secret。

🤖 Generated with Claude Code

Auto-hides comments and locks issues/discussions created by accounts
younger than NEW_ACCOUNT_MAX_AGE_DAYS (default 90 = ~3 months) that are
not collaborators/members/prior contributors. Complements the repo
interaction limit (which only blocks <24h accounts on issues/PRs and
expires) by also covering Discussions and running permanently. All
actions are reversible.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@wuwangzhang1216 wuwangzhang1216 merged commit 8877c41 into main May 31, 2026
4 checks passed
@wuwangzhang1216 wuwangzhang1216 deleted the chore/spam-guard branch May 31, 2026 20:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant