Randomize hash choice
This commit is contained in:
parent
f2438bee94
commit
20374bb5b8
1 changed files with 12 additions and 19 deletions
|
@ -106,12 +106,12 @@ welcome_footer = (
|
||||||
""",
|
""",
|
||||||
)
|
)
|
||||||
|
|
||||||
hidden_term_line = ' • When you have finished reading all of the rules, send a message in this channel that includes the SHA1 hash of your discord "name#discriminator" (for example, SHA1(User#1234)), and we\'ll grant you access to the other channels. You can find your "name#discriminator" (your username followed by a ‘#’ and four numbers) under the discord channel list.'
|
hidden_term_line = ' • When you have finished reading all of the rules, send a message in this channel that includes the {0} hash of your discord "name#discriminator" (for example, {0}(User#1234)), and we\'ll grant you access to the other channels. You can find your "name#discriminator" (your username followed by a ‘#’ and four numbers) under the discord channel list.'
|
||||||
|
|
||||||
|
|
||||||
class Verification(Cog):
|
class Verification(Cog):
|
||||||
def __init__(self, bot):
|
def __init__(self, bot, hash_choice):
|
||||||
self.bot = bot
|
self.bot = bot
|
||||||
|
self.hash_choice = random.choice(tuple(hashlib.algorithms_guaranteed))
|
||||||
|
|
||||||
@commands.check(check_if_staff)
|
@commands.check(check_if_staff)
|
||||||
@commands.command()
|
@commands.command()
|
||||||
|
@ -128,7 +128,7 @@ class Verification(Cog):
|
||||||
rules = ['**{}**. {}'.format(i, cleandoc(r)) for i, r in
|
rules = ['**{}**. {}'.format(i, cleandoc(r)) for i, r in
|
||||||
enumerate(welcome_rules, 1)]
|
enumerate(welcome_rules, 1)]
|
||||||
rule_choice = random.randint(2, len(rules))
|
rule_choice = random.randint(2, len(rules))
|
||||||
rules[rule_choice - 1] += '\n' + hidden_term_line
|
rules[rule_choice - 1] += '\n' + hidden_term_line.format(self.hash_choice.upper())
|
||||||
msg = f"🗑 **Reset**: {ctx.author.mention} cleared {limit} messages "\
|
msg = f"🗑 **Reset**: {ctx.author.mention} cleared {limit} messages "\
|
||||||
f" in {ctx.channel.mention}"
|
f" in {ctx.channel.mention}"
|
||||||
msg += f"\n💬 __Current challenge location__: under rule {rule_choice}"
|
msg += f"\n💬 __Current challenge location__: under rule {rule_choice}"
|
||||||
|
@ -199,25 +199,13 @@ class Verification(Cog):
|
||||||
close_names += [(cn + '\r') for cn in close_names]
|
close_names += [(cn + '\r') for cn in close_names]
|
||||||
|
|
||||||
# Finally, hash the stuff so that we can access them later :)
|
# Finally, hash the stuff so that we can access them later :)
|
||||||
sha1_allow = [hashlib.sha1(name.encode('utf-8')).hexdigest()
|
hash_allow = [hashlib.new(self.hash_choice, name.encode('utf-8')).hexdigest()
|
||||||
for name in allowed_names]
|
for name in allowed_names]
|
||||||
md5_allow = [hashlib.md5(name.encode('utf-8')).hexdigest()
|
|
||||||
for name in allowed_names]
|
|
||||||
sha256_allow = [hashlib.sha256(name.encode('utf-8')).hexdigest()
|
|
||||||
for name in allowed_names]
|
|
||||||
sha1_close = [hashlib.sha1(name.encode('utf-8')).hexdigest()
|
|
||||||
for name in close_names]
|
|
||||||
|
|
||||||
# I'm not even going to attempt to break those into lines jfc
|
# I'm not even going to attempt to break those into lines jfc
|
||||||
if any(allow in mcl for allow in sha1_allow):
|
if any(allow in mcl for allow in hash_allow):
|
||||||
await member.add_roles(success_role)
|
await member.add_roles(success_role)
|
||||||
await chan.purge(limit=100, check=lambda m: m.author == message.author or (m.author == self.bot.user and message.author.mention in m.content))
|
await chan.purge(limit=100, check=lambda m: m.author == message.author or (m.author == self.bot.user and message.author.mention in m.content))
|
||||||
elif any(close in mcl for close in sha1_close):
|
|
||||||
await chan.send(f"{message.author.mention} :no_entry: Close, but incorrect. You got the process right, but you're not doing it on your name and discriminator properly. Please re-read the rules carefully and look up any terms you are not familiar with.")
|
|
||||||
elif any(allow in mcl for allow in md5_allow):
|
|
||||||
await chan.send(f"{message.author.mention} :no_entry: Close, but incorrect. You're processing your name and discriminator properly, but you're not using the right process. Please re-read the rules carefully and look up any terms you are not familiar with.")
|
|
||||||
elif any(allow in mcl for allow in sha256_allow):
|
|
||||||
await chan.send(f"{message.author.mention} :no_entry: Close, but incorrect. You're processing your name and discriminator properly, but you're not using the right process. Please re-read the rules carefully and look up any terms you are not familiar with.")
|
|
||||||
elif full_name in message.content or str(member.id) in message.content or member.name in message.content or discrim in message.content:
|
elif full_name in message.content or str(member.id) in message.content or member.name in message.content or discrim in message.content:
|
||||||
no_text = ":no_entry: Incorrect. You need to do something *specific* with your name and discriminator instead of just posting it. Please re-read the rules carefully and look up any terms you are not familiar with."
|
no_text = ":no_entry: Incorrect. You need to do something *specific* with your name and discriminator instead of just posting it. Please re-read the rules carefully and look up any terms you are not familiar with."
|
||||||
rand_num = random.randint(1, 100)
|
rand_num = random.randint(1, 100)
|
||||||
|
@ -229,6 +217,11 @@ class Verification(Cog):
|
||||||
no_text = "\"The definition of insanity is doing the same thing over and over again, but expecting different results.\"\n-Albert Einstein"
|
no_text = "\"The definition of insanity is doing the same thing over and over again, but expecting different results.\"\n-Albert Einstein"
|
||||||
await chan.send(f"{message.author.mention} {no_text}")
|
await chan.send(f"{message.author.mention} {no_text}")
|
||||||
|
|
||||||
|
# Tell the user if they use the wrong hash algorithm
|
||||||
|
for w in hashlib.algorithms_guaranteed - {self.hash_choice}:
|
||||||
|
if hashlib.new(w, name.encode('utf-8')).hexdigest() in message.content.lower():
|
||||||
|
await chan.send(f"{message.author.mention} :no_entry: Close, but not quite. Go back and re-read!")
|
||||||
|
|
||||||
@Cog.listener()
|
@Cog.listener()
|
||||||
async def on_message(self, message):
|
async def on_message(self, message):
|
||||||
if message.author.bot:
|
if message.author.bot:
|
||||||
|
|
Loading…
Reference in a new issue