fix leaderboard looks, add OCR, make the captcha only show if you add a username and password

This commit is contained in:
csd4ni3l
2025-08-12 15:17:43 +02:00
parent 453250b862
commit 623bd155cb
10 changed files with 242 additions and 225 deletions

15
ocr_check.py Normal file
View File

@@ -0,0 +1,15 @@
import easyocr, difflib, random, string
from constants import OCR_CHALLENGE_LENGTH
from english_words import get_english_words_set
words = list(get_english_words_set(['gcide'], lower=True, alpha=True))
reader = easyocr.Reader(['en'])
def check_text_similarity(image_path, text):
result = reader.readtext(image_path, allowlist=string.ascii_letters + string.digits)
image_text = ''.join([text[1] for text in result]).lower()
similarity = difflib.SequenceMatcher(None, text, image_text).ratio()
return image_text, similarity
def generate_challenge(username):
return f"{username} {' '.join([random.choice(words) for _ in range(OCR_CHALLENGE_LENGTH)])}"