mirror of
https://github.com/abocn/TelegramBot-SpamWatch.git
synced 2025-03-10 04:39:57 +00:00
Python blocklist generator + modified .gitignore + WARN string on spamwatch.js
Signed-off-by: lucmsilva651 <lucmsilva651@gmail.com>
This commit is contained in:
parent
8fe6dce44d
commit
f0efeb63c4
4
.gitignore
vendored
4
.gitignore
vendored
@ -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
12
blocklist_gen/main.py
Normal 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
3
blocklist_gen/readme.txt
Normal file
@ -0,0 +1,3 @@
|
||||
pip install -r requirements.txt
|
||||
echo SW_KEY=APIKEY >> config.env # put your api key here
|
||||
python main.py
|
2
blocklist_gen/requirements.txt
Normal file
2
blocklist_gen/requirements.txt
Normal file
@ -0,0 +1,2 @@
|
||||
python-dotenv
|
||||
spamwatch
|
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user