Python blocklist generator + modified .gitignore + WARN string on spamwatch.js

Signed-off-by: lucmsilva651 <lucmsilva651@gmail.com>
This commit is contained in:
Lucas Gabriel 2024-08-31 21:20:49 -03:00
parent 8fe6dce44d
commit f0efeb63c4
No known key found for this signature in database
GPG Key ID: D9B075FC6DC93985
5 changed files with 22 additions and 1 deletions

4
.gitignore vendored
View File

@ -160,3 +160,7 @@ cython_debug/
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
# Specific to the Python blocklist generator
*.env
sw_blocklist.txt

12
blocklist_gen/main.py Normal file
View File

@ -0,0 +1,12 @@
import os
from dotenv import load_dotenv
import spamwatch
load_dotenv("config.env")
client = spamwatch.Client(os.getenv('SW_KEY'))
bans = client.get_bans_min()
with open('sw_blocklist.txt', 'w') as file:
for ban in bans:
file.write(f'{ban}\n')

3
blocklist_gen/readme.txt Normal file
View File

@ -0,0 +1,3 @@
pip install -r requirements.txt
echo SW_KEY=APIKEY >> config.env # put your api key here
python main.py

View File

@ -0,0 +1,2 @@
python-dotenv
spamwatch

View File

@ -11,7 +11,7 @@ const readBlocklist = () => {
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.\nUse your API key to push the blocklist to the file.');
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.');
fs.writeFileSync(blocklistPath, '');
} else {
console.error('WARN: Error reading SpamWatch blocklist:', error);