diff --git a/.gitignore b/.gitignore index 82f9275..496c380 100644 --- a/.gitignore +++ b/.gitignore @@ -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 diff --git a/blocklist_gen/main.py b/blocklist_gen/main.py new file mode 100644 index 0000000..370b671 --- /dev/null +++ b/blocklist_gen/main.py @@ -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') \ No newline at end of file diff --git a/blocklist_gen/readme.txt b/blocklist_gen/readme.txt new file mode 100644 index 0000000..5edee5c --- /dev/null +++ b/blocklist_gen/readme.txt @@ -0,0 +1,3 @@ +pip install -r requirements.txt +echo SW_KEY=APIKEY >> config.env # put your api key here +python main.py \ No newline at end of file diff --git a/blocklist_gen/requirements.txt b/blocklist_gen/requirements.txt new file mode 100644 index 0000000..989a366 --- /dev/null +++ b/blocklist_gen/requirements.txt @@ -0,0 +1,2 @@ +python-dotenv +spamwatch \ No newline at end of file diff --git a/spamwatch.js b/spamwatch.js index 042f99d..9b7c4d2 100644 --- a/spamwatch.js +++ b/spamwatch.js @@ -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);