From 404421dee5822d5fccd5387ff9c097624d7f3d04 Mon Sep 17 00:00:00 2001 From: EEKIM10 Date: Wed, 12 Oct 2022 18:01:37 +0100 Subject: [PATCH] improvements --- cogs/verify.py | 5 +++-- utils/_email.py | 17 ++++++++++++++--- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/cogs/verify.py b/cogs/verify.py index f23f5fd..7585200 100644 --- a/cogs/verify.py +++ b/cogs/verify.py @@ -1,9 +1,7 @@ import discord import orm -import re from discord.ext import commands from utils import VerifyCode, Student, VerifyView, get_or_none -import config class VerifyCog(commands.Cog): @@ -39,6 +37,7 @@ class VerifyCog(commands.Cog): if role and role < ctx.me.top_role: await user.remove_roles(role, reason=f"De-verified by {ctx.author}") + await ctx.message.delete(delay=10) return await ctx.reply(f"\N{white heavy check mark} De-verified {user}.") @commands.command(name="verify") @@ -51,6 +50,7 @@ class VerifyCog(commands.Cog): if role and role < ctx.me.top_role: member = await ctx.guild.fetch_member(ctx.author.id) await member.add_roles(role, reason="Verified") + await ctx.message.delete(delay=10) return await ctx.reply( "\N{white heavy check mark} Verification complete!", ) @@ -82,6 +82,7 @@ class VerifyCog(commands.Cog): await student.update(user_id=user.id) return await ctx.message.add_reaction("\N{white heavy check mark}") await ctx.message.add_reaction("\N{cross mark}") + await ctx.message.delete(delay=10) def setup(bot): diff --git a/utils/_email.py b/utils/_email.py index a37beeb..7243e8c 100644 --- a/utils/_email.py +++ b/utils/_email.py @@ -10,20 +10,31 @@ gmail_cfg = {"addr": "smtp.gmail.com", "username": config.email, "password": con TOKEN_LENGTH = 16 +class _FakeUser: + def __init__(self): + with open("/etc/dictionaries-common/words") as file: + names = file.readlines() + names = [x.strip() for x in names if not x.strip().endswith("'s")] + self.names = names + + def __str__(self): + import random + return f"{random.choice(self.names)}#{str(random.randint(1, 9999)).zfill(4)}" + + async def send_verification_code(user: discord.User, student_number: str, **kwargs) -> str: """Sends a verification code, returning said verification code, to the student.""" code = secrets.token_hex(TOKEN_LENGTH) text = ( - f"Hey {user} ({student_number})! The code to join the Unscrupulous Nonsense is '{code}'.\n\n" + f"Hey {user} ({student_number})! The code to join Unscrupulous Nonsense is '{code}'.\n\n" f"Go back to the #verify channel, and click 'I have a verification code!', and put {code} in the modal" f" that pops up\n\n" f"If you have any issues getting in, feel free to reply to this email, or DM eek#7574.\n" f"~Nex" ) msg = EmailMessage() - msg["From"] = "B593764@my.leedscitycollege.ac.uk" + msg["From"] = msg["bcc"] = "B593764@my.leedscitycollege.ac.uk" msg["To"] = f"{student_number}@my.leedscitycollege.ac.uk" - msg["Bcc"] = gmail_cfg["username"] msg["Subject"] = "Server Verification" msg.set_content(text)