Skip to content

feat: handle spam to vn lang #51

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
feat: handle spam to vn lang
  • Loading branch information
winverse committed Aug 28, 2024
commit b8c9dec439a6bc9d2e080214c92ba20ebbb87da9
7 changes: 7 additions & 0 deletions apps/cron/src/services/PostService/index.mts
Original file line number Diff line number Diff line change
Expand Up @@ -179,11 +179,18 @@ export class PostService implements Service {
): Promise<{ isSpam: boolean; reason: string }> {
const includesCN = /[\u4e00-\u9fa5]/.test(text)
const includesKR = /[ㄱ-ㅎ|ㅏ-ㅣ|가-힣]/.test(text)
const includesVN = /[àáâãèéêìíòóôõùúýăđĩũơưạảấầẩẫậắằẳẵặẹẻẽếềểễệỉịọỏốồổỗộớờởỡợụủứừửữựỳỵỷỹ]/.test(
text,
)

if (includesCN && !includesKR) {
return { isSpam: true, reason: 'includesCN' }
}

if (includesVN && !includesKR) {
return { isSpam: true, reason: 'includesVN' }
}

let replaced = text.replace(/```([\s\S]*?)```/g, '') // remove code blocks
// replace image markdown
replaced = replaced.replace(/!\[([\s\S]*?)\]\(([\s\S]*?)\)/g, '')
Expand Down