2024-07-28 13:31:24 -03:00
const fs = require ( 'fs' ) ;
const path = require ( 'path' ) ;
const blocklistPath = path . join ( _ _dirname , '../../props/sw_blocklist.txt' ) ;
let blocklist = [ ] ;
const readBlocklist = ( ) => {
try {
const data = fs . readFileSync ( blocklistPath , 'utf8' ) ;
blocklist = data . split ( '\n' ) . map ( id => id . trim ( ) ) . filter ( id => id !== '' ) ;
} catch ( error ) {
if ( error . code === 'ENOENT' ) {
2024-08-31 21:20:49 -03:00
console . log ( 'WARN: SpamWatch blocklist file not found. Creating a new, blank one.\nUse your own SpamWatch API key and our generator to push the blocklist to the file.' ) ;
2024-07-28 13:31:24 -03:00
fs . writeFileSync ( blocklistPath , '' ) ;
} else {
console . error ( 'WARN: Error reading SpamWatch blocklist:' , error ) ;
}
}
} ;
const isOnSpamWatch = ( userId ) => {
return blocklist . includes ( String ( userId ) ) ;
} ;
readBlocklist ( ) ;
module . exports = { isOnSpamWatch } ;