Volume button gesture in manga #3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Extension Issue Handling | |
on: | |
issues: | |
types: [opened] | |
jobs: | |
check-extension-issue: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Fetch Extension Data | |
id: fetch-extensions | |
uses: actions/github-script@v6 | |
with: | |
script: | | |
const repos = [ | |
"https://kodjodevf.github.io/mangayomi-extensions/index.json", | |
"https://kodjodevf.github.io/mangayomi-extensions/anime_index.json" | |
]; | |
const extensionNames = new Set(); | |
for (const repo of repos) { | |
try { | |
const response = await fetch(repo); | |
const data = await response.json(); | |
data.forEach(extension => { | |
if (extension.name) { | |
extensionNames.add(extension.name.toLowerCase()); | |
} | |
}); | |
console.log(`✅ Successfully fetched extensions from ${repo}`); | |
} catch (error) { | |
console.error(`❌ Error fetching ${repo}:`, error); | |
} | |
} | |
console.log('📝 Found extensions:', Array.from(extensionNames).join(', ')); | |
core.setOutput('extension_names', Array.from(extensionNames).join(',')); | |
- name: Check Issue Content | |
id: check-issue | |
uses: actions/github-script@v6 | |
with: | |
script: | | |
function normalizeExtensionName(name) { | |
const original = name; | |
const normalized = name | |
.toLowerCase() | |
.replace(/[!@#$%^&*()_+\-=\[\]{};':"\\|,.<>/?]/g, ' ') | |
.replace(/\s+/g, ' ') | |
.trim() | |
.replace(/\d+/g, ''); | |
console.log(`🔍 Normalizing: "${original}" -> "${normalized}"`); | |
return normalized; | |
} | |
function findExtensionMatch(content, extensionNames) { | |
console.log('\n📖 Checking content:', content); | |
const normalizedContent = normalizeExtensionName(content); | |
for (const extension of extensionNames) { | |
console.log(`\n⚡ Checking against extension: ${extension}`); | |
const normalizedExtension = normalizeExtensionName(extension); | |
if (normalizedContent.includes(normalizedExtension)) { | |
console.log(`✅ Direct match found! "${extension}"`); | |
return extension; | |
} | |
const extensionParts = normalizedExtension.split(''); | |
let possibleSplits = ''; | |
for (let i = 0; i < extensionParts.length - 1; i++) { | |
possibleSplits += extensionParts[i] + ' '; | |
} | |
possibleSplits += extensionParts[extensionParts.length - 1]; | |
if (normalizedContent.includes(possibleSplits)) { | |
console.log(`✅ Split match found! "${extension}" (as "${possibleSplits}")`); | |
return extension; | |
} | |
} | |
console.log('❌ No extension match found'); | |
return null; | |
} | |
const extensionNames = process.env.EXTENSION_NAMES.split(','); | |
const issueTitle = context.payload.issue.title; | |
const issueBody = context.payload.issue.body || ''; | |
console.log('\n🎯 Checking Issue:'); | |
console.log('Title:', issueTitle); | |
console.log('Body:', issueBody); | |
const regexPatterns = [ | |
".*(extension|extensions|repo|repositories|source|sources|stream|server).*not working.*", | |
".*(extension|extensions|repo|repositories|source|sources|stream|server).*doesn't work.*", | |
".*(extension|extensions|repo|repositories|source|sources|stream|server).*does not work.*", | |
".*(extension|extensions|repo|repositories|source|sources|stream|server).*cant work.*", | |
".*(extension|extensions|repo|repositories|source|sources|stream|server).*can't work.*", | |
".*(no|can't find|cannot find|missing).*extension(s)?.*", | |
".*(no|can't find|cannot find|missing).*repo(s|sitories)?.*", | |
".*(no|can't find|cannot find|missing).*source(s)?.*", | |
".*(no|can't find|cannot find|missing).*stream(s)?.*", | |
".*(no|can't find|cannot find|missing).*server.*", | |
".*(server|stream).*not available.*", | |
".*(server|stream).*unavailable.*", | |
".*(server|stream).*down.*", | |
".*{.*}.*(extension|repo|repositories|source|sources).*not working.*", | |
".*{.*}.*(extension|repo|repositories|source|sources).*issue.*", | |
".*{.*}.*(extension|repo|repositories|source|sources).*problem.*", | |
".*(extension|extensions|repo|repositories|source|sources|stream|server).*not available.*", | |
".*(extension|extensions|repo|repositories|source|sources|stream|server).*missing.*", | |
".*nothing came up.*source.*look elsewhere.*", | |
".*no results.*source.*look somewhere else.*", | |
".*no content.*source.*" | |
]; | |
let isExtensionIssue = false; | |
let detectedExtension = null; | |
console.log('\n🔍 Checking for extension matches...'); | |
detectedExtension = findExtensionMatch(issueTitle, extensionNames) || | |
findExtensionMatch(issueBody, extensionNames); | |
if (detectedExtension) { | |
isExtensionIssue = true; | |
console.log('✅ Extension detected:', detectedExtension); | |
} else { | |
console.log('\n🔍 No specific extension found, checking regex patterns...'); | |
for (const pattern of regexPatterns) { | |
const regex = new RegExp(pattern, 'i'); | |
if (regex.test(issueTitle.toLowerCase())) { | |
console.log(`✅ Regex pattern matched in title: "${pattern}"`); | |
isExtensionIssue = true; | |
break; | |
} | |
if (regex.test(issueBody.toLowerCase())) { | |
console.log(`✅ Regex pattern matched in body: "${pattern}"`); | |
isExtensionIssue = true; | |
break; | |
} | |
} | |
} | |
console.log('\n📊 Final Results:'); | |
console.log('Is Extension Issue:', isExtensionIssue); | |
console.log('Detected Extension:', detectedExtension || 'Unknown Extension'); | |
core.setOutput('is_extension_issue', isExtensionIssue.toString()); | |
core.setOutput('detected_extension', detectedExtension || 'Unknown Extension'); | |
env: | |
EXTENSION_NAMES: ${{ steps.fetch-extensions.outputs.extension_names }} | |
- name: Comment and Close Extension Issue | |
if: steps.check-issue.outputs.is_extension_issue == 'true' | |
uses: actions/github-script@v6 | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
script: | | |
const issueNumber = context.issue.number; | |
const reportedExtension = "${{ steps.check-issue.outputs.detected_extension || 'Unknown Extension' }}"; | |
console.log('🔒 Closing issue:', issueNumber); | |
console.log('Extension reported:', reportedExtension); | |
const currentLabels = await github.rest.issues.listLabelsOnIssue({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
issue_number: issueNumber | |
}); | |
for (const label of currentLabels.data) { | |
await github.rest.issues.removeLabel({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
issue_number: issueNumber, | |
name: label.name | |
}); | |
} | |
await github.rest.issues.addLabels({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
issue_number: issueNumber, | |
labels: ['wontfix'] | |
}); | |
await github.rest.issues.createComment({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
issue_number: issueNumber, | |
body: `# Not Our Business! | |
AnymeX doesn't maintain extensions. | |
If the extension doesn't work, we cannot help you. | |
Contact the owner of the respective repository for extension-related problems.` | |
}); | |
await github.rest.issues.update({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
issue_number: issueNumber, | |
state: 'closed' | |
}); | |
console.log('✅ Issue processed and closed successfully'); |