Implemented SpamWatch blocklist
This commit is contained in:
parent
1bc99afe87
commit
0cdcc28d3e
5 changed files with 46 additions and 2 deletions
28
spamwatch.js
Normal file
28
spamwatch.js
Normal file
|
@ -0,0 +1,28 @@
|
|||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
const blocklistPath = path.join(__dirname, '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') {
|
||||
console.log('WARN: SpamWatch blocklist file not found. Creating a new, blank one.');
|
||||
fs.writeFileSync(blocklistPath, '');
|
||||
} else {
|
||||
console.error('WARN: Error reading SpamWatch blocklist:', error);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const isOnSpamWatch = (userId) => {
|
||||
return blocklist.includes(String(userId));
|
||||
};
|
||||
|
||||
readBlocklist();
|
||||
|
||||
module.exports = { isOnSpamWatch };
|
Loading…
Add table
Add a link
Reference in a new issue