UNPKG

safety-safe

Version:

Firewall cerdas untuk Bot WhatsApp untuk mendeteksi dan memfilter pesan bug/crash/spam (Baileys).

38 lines (32 loc) 1.08 kB
import checkContentLength from './checks/checkContentLength.js'; import checkMentionCount from './checks/checkMentionCount.js'; import checkDocumentProperties from './checks/checkDocumentProperties.js'; import checkLocationValues from './checks/checkLocationValues.js'; import checkCharacterFlood from './checks/checkCharacterFlood.js'; const allChecks = [ checkContentLength, checkMentionCount, checkDocumentProperties, checkLocationValues, checkCharacterFlood ]; const defaultConfig = { maxTextLength: 10000, maxMentions: 100, maxFileLength: 2 * 1024 * 1024 * 1024, maxPageCount: 10000, maxCharacterFlood: 20000 }; export function analyzeMessage(message, userOptions = {}) { if (!message) { return { isMalicious: false, reason: null, severity: null, threatType: null }; } const config = { ...defaultConfig, ...userOptions }; for (const check of allChecks) { const result = check(message, config); if (result.isMalicious) { return result; } } return { isMalicious: false, reason: null, severity: null, threatType: null }; }