Skip to content

TakePOS : confirmation screen before validating payment #2405

TakePOS : confirmation screen before validating payment

TakePOS : confirmation screen before validating payment #2405

Workflow file for this run

# Github action to experiment automatic moderation
name: Moderation Bot
on:
issue_comment:
types: [created, edited]
pull_request_review_comment:
types: [created, edited]
permissions:
issues: write
pull-requests: write
jobs:
moderate:
runs-on: ubuntu-latest
steps:
- name: Install franc
run: npm install franc
- name: Moderate comments
uses: actions/github-script@v9
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const forbiddenPatterns = [
'music.youtube.com',
'youtu.be',
'youtube.com/watch'
]
const profanityList = JSON.parse(process.env.PROFANITY_LIST || '[]')
const offTopicKeywords = JSON.parse(process.env.OFFTOPIC_LIST || '[]')
const comment = context.payload.comment.body || ''
const commentAuthor = context.payload.comment.user.login
const repoOwner = context.repo.owner
const isOwner = commentAuthor === repoOwner
const isForbidden = forbiddenPatterns.some(p => comment.toLowerCase().includes(p))
const isProfane = profanityList.some(word => new RegExp(`\\b${word}\\b`, 'i').test(comment))
const isOffTopic = offTopicKeywords.some(kw => comment.toLowerCase().includes(kw.toLowerCase()))
async function isEnglishFunc(text) {
try {
const { franc } = await import('franc');
const lang = franc(text);
return lang.startsWith('eng') || lang.startsWith('sco');
} catch (e) {
console.log('Language detection failed:', e)
return true;
}
}
let isEnglish = await isEnglishFunc(comment)
if ((isForbidden || isProfane || isOffTopic || !isEnglish) && !isOwner) {
try {
const issueNumber = context.payload.issue?.number || context.payload.pull_request?.number
const reason = !isEnglish ? 'non-English comment' :
isForbidden ? 'forbidden link' :
isProfane ? 'profanity' : 'off-topic content'
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issueNumber,
body: `Comment auto removed: ${reason} violates repository guidelines.`
})
await github.rest.issues.deleteComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: context.payload.comment.id
})
} catch (error) {
console.error('Moderation error:', error)
throw error
}
}