Skip to content

Commit

Permalink
Fix spam
Browse files Browse the repository at this point in the history
Backport of musescore#24238
  • Loading branch information
cbjeukendrup authored and Jojo-Schmitz committed Aug 27, 2024
1 parent 081b930 commit 083be18
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/issues_delete_spam.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Delete spam comments

on:
issue_comment:
types: [created]

permissions:
issues: write

jobs:
delete_spam_comment:
runs-on: ubuntu-latest
steps:
- name: "Delete spam comment"
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const payload = context.payload;
const comment = payload.comment;
const commentBody = comment.body;
const isSpam = commentBody.includes('Download')
&& commentBody.includes('https://www.mediafire.com/file')
&& commentBody.includes('password: changeme')
&& commentBody.includes('In the installer menu, select "gcc."');
if (isSpam) {
console.log('Deleting spam comment');
await github.rest.issues.deleteComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: comment.id
});
github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: 'The previous comment was preventively deleted because it was identified as spam. As long as you have not clicked the link in this comment, you are safe.'
});
} else {
console.log('Comment is not spam');
}

0 comments on commit 083be18

Please sign in to comment.