Implemented blocklist + some code changes
This commit is contained in:
parent
945182329e
commit
4b0e188467
13 changed files with 48 additions and 12 deletions
28
src/blocklist.js
Normal file
28
src/blocklist.js
Normal file
|
@ -0,0 +1,28 @@
|
|||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
const blocklistPath = path.join(__dirname, '../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: Blocklist file not found. Creating a new one.');
|
||||
fs.writeFileSync(blocklistPath, ''); // Create an empty blocklist file
|
||||
} else {
|
||||
console.error('WARN: Error reading blocklist:', error);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const isBlocked = (userId) => {
|
||||
return blocklist.includes(String(userId));
|
||||
};
|
||||
|
||||
readBlocklist();
|
||||
|
||||
module.exports = { isBlocked };
|
Loading…
Add table
Add a link
Reference in a new issue