name: Issue moderator

on:
  issues:
    types: [opened, edited, reopened]
  issue_comment:
    types: [created]

jobs:
  moderate:
    runs-on: ubuntu-latest
    steps:
      - name: Moderate issues
        uses: tachiyomiorg/issue-moderator-action@v2
        with:
          repo-token: ${{ secrets.GITHUB_TOKEN }}
          duplicate-label: Duplicate

          auto-close-rules: |
            [
              {
                "type": "body",
                "regex": ".*DELETE THIS SECTION IF YOU HAVE READ AND ACKNOWLEDGED IT.*",
                "message": "The acknowledgment section was not removed."
              },
              {
                "type": "body",
                "regex": ".*\\* (Tachiyomi version|Android version|Device): \\?.*",
                "message": "Requested information in the template was not filled out."
              },
              {
                "type": "both",
                "regex": "^(?!.*myanimelist.*).*(aniyomi|anime).*$",
                "ignoreCase": true,
                "message": "Tachiyomi does not support anime, and has no plans to support anime. In addition Tachiyomi is not affiliated with Aniyomi https://github.com/jmir1/aniyomi"
              },
              {
                "type": "both",
                "regex": ".*(?:fail(?:ed|ure|s)?|can\\s*(?:no|')?t|(?:not|un).*able|(?<!n[o']?t )blocked by|error) (?:to )?(?:get past|by ?pass|penetrate)?.*cloud ?fl?are.*",
                "ignoreCase": true,
                "labels": ["Cloudflare protected"],
                "message": "Refer to the **Solving Cloudflare issues** section at https://tachiyomi.org/docs/guides/troubleshooting/#cloudflare. If it doesn't work, migrate to other sources or wait until they lower their protection."
              }
            ]
          auto-close-ignore-label: do-not-autoclose