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
import time
import traceback
from typing import List
import discord, json # type: ignore
import os
@ -70,6 +71,12 @@ def makeEmbed(title="", description="", footer="", image=None, color=0xffffff):
if image is not None:
embed.set_image(url=image)
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,28 +458,26 @@ async def on_message(message):
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")
await message.reply(content=f"{message.author.mention} Ласкаво просимо!\nУ вас тепер є повний доступ до всього сервера. Приємного спілкування!", delete_after=3)
await message.reply(content=f"{message.author.mention} Ласкаво просимо!\nУ вас тепер є повний доступ до всього сервера. Приємного спілкування!", delete_after=3)
await message.delete()
await rmMsg(configGet("captcha", "channels", "verification"), userdata[str(message.author.id)]["question_id"])
await message.delete()
await rmMsg(configGet("captcha", "channels", "verification"), userdata[str(message.author.id)]["question_id"])
await message.author.add_roles(getChan(message.guild.roles, configGet("verified", "roles")))
await message.author.add_roles(getChan(message.guild.roles, configGet("verified", "roles")))
await getChan(message.author.guild.channels, configGet("captcha_log", "channels", "verification")).send(embed=makeEmbed(title="✅ Юзера верифіковано", description=f"**Ім'я:** `{message.author.name}#{message.author.discriminator}`\n**Питання:** `{userdata[str(message.author.id)]['captcha']['question']}`\n**Відповіді:** `{str(userdata[str(message.author.id)]['captcha']['answer'])}`", color=0xffc300))
await getChan(message.author.guild.channels, configGet("captcha_log", "channels", "verification")).send(embed=makeEmbed(title="✅ Юзера верифіковано", description=f"**Ім'я:** `{message.author.name}#{message.author.discriminator}`\n**Питання:** `{userdata[str(message.author.id)]['captcha']['question']}`\n**Відповіді:** `{str(userdata[str(message.author.id)]['captcha']['answer'])}`", color=0xffc300))
await getChan(message.author.guild.channels, configGet("chat", "channels", "general")).send(content=f"У нас поповнення у вигляді {message.author.mention}. Познайомтесь :)")
await getChan(message.author.guild.channels, configGet("chat", "channels", "general")).send(content=f"У нас поповнення у вигляді {message.author.mention}. Познайомтесь :)")
del userdata[str(message.author.id)]["captcha"]
del userdata[str(message.author.id)]
del userdata[str(message.author.id)]["captcha"]
del userdata[str(message.author.id)]
jsonSave("data.json", userdata)
return
jsonSave("data.json", userdata)
return
if message.content.lower().replace(" ", "") in configGet("forbidden_answers"):