Fixed checker behavior

This commit is contained in:
Profitroll 2023-04-10 23:12:22 +02:00
parent 526f4acef7
commit 9fb580ffb7

View File

@ -3,6 +3,7 @@ from datetime import datetime
from random import choice from random import choice
import time import time
import traceback import traceback
from typing import List
import discord, json # type: ignore import discord, json # type: ignore
import os import os
@ -70,6 +71,12 @@ def makeEmbed(title="", description="", footer="", image=None, color=0xffffff):
if image is not None: if image is not None:
embed.set_image(url=image) embed.set_image(url=image)
return embed return embed
async def is_correct_answer(answer: str, correct: List[str]) -> bool:
for entry in correct:
if (answer.lower().replace(" ", "").replace(",", "").replace(".", "").replace("", "-").replace("", "-")).startswith(entry.lower().replace(" ", "")):
return True
return False
#========================================================================================================================= #=========================================================================================================================
@ -451,9 +458,7 @@ async def on_message(message):
if message.author != client.user: if message.author != client.user:
for answer in userdata[str(message.author.id)]["captcha"]["answer"]: if await is_correct_answer(message.content, userdata[str(message.author.id)]["captcha"]["answer"]):
if answer.lower().replace(" ", "") in message.content.lower().replace(" ", "").replace(",", "").replace(".", ""):
logWrite(f"User {message.author.name}#{message.author.discriminator} verified") logWrite(f"User {message.author.name}#{message.author.discriminator} verified")