Skip to content

[Patch] Close a large number of issues from Chinese gambling ads. #25685

Description

@Fgaoxing

@tomtaylor @walf443 @bpot @frsyuki @mscdex

#!/usr/bin/env python3
import requests

REST_URL = "https://api.github.com"

OWNER = "YOUR_OWNER"
REPO = "YOUR_REPO_NAME"

TOKEN = "YOUR_GITHUB_TOKEN"
HEADERS = {
    "Authorization": f"Bearer {TOKEN}",
    "Accept": "application/vnd.github+json",
    "Content-Type": "application/json"
}


def close_issue(owner: str, repo: str, issue_number: int) -> bool:
    try:
        response = requests.patch(
            f"{REST_URL}/repos/{owner}/{repo}/issues/{issue_number}",
            headers=HEADERS,
            json={"state": "closed"},
            timeout=30
        )
        return response.status_code == 200
    except requests.exceptions.RequestException:
        return False


def list_issues() -> list:
    response = requests.get(
        f"{REST_URL}/search/issues?q=repo:{OWNER}/{REPO}%20%22%E6%89%A3%EF%BC%9A63923%22%20OR%20%22%EF%BC%98%20%EF%BC%97%20%EF%BC%92%20%EF%BC%96%20%C2%B7%20%EF%BC%A3%20%EF%BC%A3%22%20OR%20%223764%20%C2%B7%20CC%22%20OR%20%22%EF%BC%92%EF%BC%90%EF%BC%92%EF%BC%96%E4%B8%96%E7%95%8C%E6%9D%AF%EF%BC%8C%E7%90%83%E8%BF%B7%E7%8B%82%E6%AC%A2%EF%BC%81%22%20OR%20%22%E6%89%A3:%2063923%22%20created:2026-03-27..2026-03-29",
        headers=HEADERS,
        timeout=30
    )
    return response.json()["items"]


if __name__ == "__main__":
    issues = list_issues()
    for issue in issues:
        print(issue["number"], issue["title"])
        close_issue(OWNER, REPO, issue["number"])

This patch was developed by a Chinese developer.
I don't have the permission, so I can't test it. I hope it works well.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions