Update fediverse.py

This commit is contained in:
Namhyeon Go 2024-02-28 15:26:14 +09:00 committed by GitHub
parent 01d68c0100
commit 7d224047b8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -13,6 +13,7 @@
import io
import re
import requests
import os.path
from decouple import config
from PIL import Image
@ -22,16 +23,18 @@ from server import Filter
try:
truecaptcha_userid = config('TRUECAPTCHA_USERID') # truecaptcha.org
truecaptcha_apikey = config('TRUECAPTCHA_APIKEY') # truecaptcha.org
librey_apiurl = config("LIBREY_APIURL") # https://github.com/Ahwxorg/librey
except
pass
dictionary_file = config('DICTIONARY_FILE', default='words_alpha.txt') # https://github.com/dwyl/english-words
librey_apiurl = config('LIBREY_APIURL') # https://github.com/Ahwxorg/librey
except Exception as e:
print ("[*] Invaild configration: %s" % (str(e)))
class Fediverse(Filter):
def __init__(self):
# Load data to use KnownWords4 strategy
# Download data: https://github.com/dwyl/english-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()
self.known_words = [word.strip() for word in words if len(word.strip()) > 3]
print ("[*] Data loaded to use KnownWords4 strategy")