Fixed checker behavior
This commit is contained in:
parent
526f4acef7
commit
9fb580ffb7
33
glorybot.py
33
glorybot.py
@ -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,28 +458,26 @@ 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")
|
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 message.author.add_roles(getChan(message.guild.roles, configGet("verified", "roles")))
|
||||||
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 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"]
|
jsonSave("data.json", userdata)
|
||||||
del userdata[str(message.author.id)]
|
return
|
||||||
|
|
||||||
jsonSave("data.json", userdata)
|
|
||||||
return
|
|
||||||
|
|
||||||
if message.content.lower().replace(" ", "") in configGet("forbidden_answers"):
|
if message.content.lower().replace(" ", "") in configGet("forbidden_answers"):
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user