mirror of
https://github.com/gnh1201/caterpillar.git
synced 2025-11-27 18:10:40 +00:00
Update fediverse.py
This commit is contained in:
parent
01d68c0100
commit
7d224047b8
|
|
@ -13,6 +13,7 @@
|
||||||
import io
|
import io
|
||||||
import re
|
import re
|
||||||
import requests
|
import requests
|
||||||
|
import os.path
|
||||||
|
|
||||||
from decouple import config
|
from decouple import config
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
|
|
@ -22,16 +23,18 @@ from server import Filter
|
||||||
try:
|
try:
|
||||||
truecaptcha_userid = config('TRUECAPTCHA_USERID') # truecaptcha.org
|
truecaptcha_userid = config('TRUECAPTCHA_USERID') # truecaptcha.org
|
||||||
truecaptcha_apikey = config('TRUECAPTCHA_APIKEY') # truecaptcha.org
|
truecaptcha_apikey = config('TRUECAPTCHA_APIKEY') # truecaptcha.org
|
||||||
librey_apiurl = config("LIBREY_APIURL") # https://github.com/Ahwxorg/librey
|
dictionary_file = config('DICTIONARY_FILE', default='words_alpha.txt') # https://github.com/dwyl/english-words
|
||||||
except
|
librey_apiurl = config('LIBREY_APIURL') # https://github.com/Ahwxorg/librey
|
||||||
pass
|
except Exception as e:
|
||||||
|
print ("[*] Invaild configration: %s" % (str(e)))
|
||||||
|
|
||||||
class Fediverse(Filter):
|
class Fediverse(Filter):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
# Load data to use KnownWords4 strategy
|
# Load data to use KnownWords4 strategy
|
||||||
# Download data: https://github.com/dwyl/english-words
|
# Download data: https://github.com/dwyl/english-words
|
||||||
self.known_words = []
|
self.known_words = []
|
||||||
with open("words_alpha.txt", "r") as file:
|
if dictionary_file != '' and os.path.isfile(dictionary_file):
|
||||||
|
with open(dictionary_file, "r") as file:
|
||||||
words = file.readlines()
|
words = file.readlines()
|
||||||
self.known_words = [word.strip() for word in words if len(word.strip()) > 3]
|
self.known_words = [word.strip() for word in words if len(word.strip()) > 3]
|
||||||
print ("[*] Data loaded to use KnownWords4 strategy")
|
print ("[*] Data loaded to use KnownWords4 strategy")
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user