|
| 1 | +import * as github from '@actions/github'; |
| 2 | +import * as core from "@actions/core"; |
| 3 | + |
| 4 | +const otherModTerms = [ |
| 5 | + "feather", |
| 6 | + "labymod", |
| 7 | + "lunar", |
| 8 | + "optifabric", |
| 9 | + "optifine", |
| 10 | + "pojav", |
| 11 | + "tlauncher" |
| 12 | +]; |
| 13 | + |
| 14 | +const anticheatTerms = [ |
| 15 | + "aac", |
| 16 | + "anti xray", |
| 17 | + "anti aura", |
| 18 | + "anticheataddition", |
| 19 | + "bypass", |
| 20 | + "disabler", |
| 21 | + "donut", |
| 22 | + "godseye", |
| 23 | + "grim", |
| 24 | + "matrix", |
| 25 | + "ncp", |
| 26 | + "nocheat plus", |
| 27 | + "spartan", |
| 28 | + "vulcan", |
| 29 | + "watchdog", |
| 30 | + "wraith" |
| 31 | +]; |
| 32 | + |
| 33 | +const featureTerms = [ |
| 34 | + ".panic", |
| 35 | + "anti vanish", |
| 36 | + "dupe", |
| 37 | + "force op", |
| 38 | + "god mode", |
| 39 | + "infinite reach", |
| 40 | + "ping bypass", |
| 41 | + "portal godmode", |
| 42 | + "tp aura" |
| 43 | +] |
| 44 | + |
| 45 | +const token = process.env.GITHUB_TOKEN; |
| 46 | +const octokit = github.getOctokit(token); |
| 47 | +const context = github.context |
| 48 | + |
| 49 | +const title = context.payload.issue.title; |
| 50 | +const body = context.payload.issue.body; |
| 51 | + |
| 52 | +async function run() { |
| 53 | + const issueText = `${title} ${body}`.toLowerCase(); |
| 54 | + |
| 55 | + for (const term of otherModTerms) { |
| 56 | + if (!checkTerm(issueText, term)) continue; |
| 57 | + |
| 58 | + const otherModMessage = |
| 59 | + 'Meteor does not offer support for "legit clients" like Lunar or Feather, or for launchers that ' + |
| 60 | + 'support cracked accounts, or work on non-desktop devices. The mod likely won\'t run in tandem with ' + |
| 61 | + 'them, and if you experience any issues while doing so you must troubleshoot any issues yourself.' |
| 62 | + |
| 63 | + await closeIssue(otherModMessage, octokit, context, term); |
| 64 | + return; |
| 65 | + } |
| 66 | + |
| 67 | + for (const term of anticheatTerms) { |
| 68 | + if (!checkTerm(issueText, term)) continue; |
| 69 | + |
| 70 | + const anticheatMessage = |
| 71 | + 'Meteor is intended to be used as a utility client on servers that explicitly allow its use. ' + |
| 72 | + 'We do not intend to add workarounds for specific anticheats unless it falls within that scope.' |
| 73 | + |
| 74 | + await closeIssue(anticheatMessage, octokit, context, term); |
| 75 | + return; |
| 76 | + } |
| 77 | + |
| 78 | + for (const term of featureTerms) { |
| 79 | + if (!checkTerm(issueText, term)) continue; |
| 80 | + |
| 81 | + const featureMessage = |
| 82 | + 'This feature is either impossible to make, associated with cheating/griefing, or falls outside ' + |
| 83 | + 'the scope of this project. We do not plan on adding this feature.' |
| 84 | + |
| 85 | + await closeIssue(featureMessage, octokit, context, term); |
| 86 | + return; |
| 87 | + } |
| 88 | + |
| 89 | + if (checkTerm(issueText, "old version")) { |
| 90 | + const oldVersionMessage = |
| 91 | + 'Our [archive page](https://www.meteorclient.com/archive) stores major Meteor versions for Minecraft ' + |
| 92 | + 'versions starting at 1.21.4. If you wish to use older builds on older versions of Minecraft, you will ' + |
| 93 | + 'need to build them yourself. **You will not receive support for issues with old versions of Meteor!**' |
| 94 | + |
| 95 | + await closeIssue(oldVersionMessage, octokit, context, "old version"); |
| 96 | + return; |
| 97 | + } |
| 98 | + |
| 99 | + if (checkTerm(issueText, "forge")) { |
| 100 | + const forgeMessage = |
| 101 | + 'Porting Meteor to Forge would take a great amount of time and effort, and would require rewriting major ' + |
| 102 | + 'parts of the client to accommodate different APIs. Meteor does not plan to port to Forge in the future.' |
| 103 | + |
| 104 | + await closeIssue(forgeMessage, octokit, context, "forge"); |
| 105 | + } |
| 106 | +} |
| 107 | + |
| 108 | +function checkTerm(text, term) { |
| 109 | + if (text.includes(term)) return true; |
| 110 | + if (text.includes(term.replaceAll(' ', '-'))) return true; |
| 111 | + return text.includes(term.replaceAll(' ', '')); |
| 112 | +} |
| 113 | + |
| 114 | +async function closeIssue(message, octokit, context, foundTerm) { |
| 115 | + const issueNumber = context.payload.issue.number; |
| 116 | + const owner = context.repo.owner; |
| 117 | + const repo = context.repo.repo; |
| 118 | + |
| 119 | + let closeMessage = '### This issue is being automatically closed.\n' + |
| 120 | + `${message}` |
| 121 | + |
| 122 | + if (foundTerm !== '') closeMessage += |
| 123 | + '\n' + |
| 124 | + '\n' + |
| 125 | + `_This issue was closed because you used the term "${foundTerm}". ` + |
| 126 | + 'If you believe your issue is not associated with the given reason ' + |
| 127 | + 'you may reopen it._' |
| 128 | + |
| 129 | + // IDE for whatever reason can't find the rest property yippee |
| 130 | + |
| 131 | + try { |
| 132 | + await octokit['rest'].issues.createComment({ |
| 133 | + owner, repo, issue_number: issueNumber, body: closeMessage |
| 134 | + }); |
| 135 | + |
| 136 | + core.info('Comment added successfully.'); |
| 137 | + } catch (error) { |
| 138 | + core.error(`Failed to add comment: ${error.message}`); |
| 139 | + } |
| 140 | + |
| 141 | + try { |
| 142 | + await octokit['rest'].issues.update({ |
| 143 | + owner, repo, issue_number: issueNumber, state: 'closed', state_reason: 'not_planned' |
| 144 | + }); |
| 145 | + |
| 146 | + core.info('Closed issue successfully.'); |
| 147 | + } catch (error) { |
| 148 | + core.setFailed(`Failed to close issue: ${error.message}`); |
| 149 | + } |
| 150 | +} |
| 151 | + |
| 152 | +run(); |
| 153 | + |
0 commit comments