mirror of
https://github.com/nexy7574/LCC-bot.git
synced 2024-09-19 10:03:40 +01:00
improvements
This commit is contained in:
parent
c4ec8035cb
commit
404421dee5
2 changed files with 17 additions and 5 deletions
|
@ -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):
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
Loading…
Reference in a new issue