Add verification
god i hate this so much
This commit is contained in:
parent
701d5ba084
commit
fc7c0f89d6
4 changed files with 105 additions and 43 deletions
|
@ -11,8 +11,9 @@ Based on https://gitlab.com/ao/dpybotbase
|
||||||
|
|
||||||
- [x] .py configs
|
- [x] .py configs
|
||||||
- [x] membercount command
|
- [x] membercount command
|
||||||
- [ ] Verification: Actual verification system
|
- [x] Verification: Actual verification system
|
||||||
- [x] Verification: Reset command
|
- [x] Verification: Reset command
|
||||||
|
- [ ] Verification: Using log module from akbbot for logging attempts and removing old attempts
|
||||||
- [ ] Logging: joins
|
- [ ] Logging: joins
|
||||||
- [ ] Logging: leaves
|
- [ ] Logging: leaves
|
||||||
- [ ] Logging: role changes
|
- [ ] Logging: role changes
|
||||||
|
|
|
@ -41,6 +41,7 @@ initial_extensions = ['cogs.common',
|
||||||
'cogs.admin',
|
'cogs.admin',
|
||||||
'cogs.basic',
|
'cogs.basic',
|
||||||
"cogs.err",
|
"cogs.err",
|
||||||
|
"cogs.verification",
|
||||||
'cogs.links',
|
'cogs.links',
|
||||||
'cogs.mod',
|
'cogs.mod',
|
||||||
'cogs.meme']
|
'cogs.meme']
|
||||||
|
|
|
@ -5,6 +5,7 @@ import config
|
||||||
import random
|
import random
|
||||||
from inspect import cleandoc
|
from inspect import cleandoc
|
||||||
import config
|
import config
|
||||||
|
import hashlib
|
||||||
|
|
||||||
|
|
||||||
welcome_header = """
|
welcome_header = """
|
||||||
|
@ -149,55 +150,113 @@ class Verification:
|
||||||
for x in welcome_footer:
|
for x in welcome_footer:
|
||||||
await ctx.send(cleandoc(x))
|
await ctx.send(cleandoc(x))
|
||||||
|
|
||||||
@commands.guild_only()
|
async def process_message(self, message):
|
||||||
@commands.command()
|
"""Big code that makes me want to shoot myself
|
||||||
async def verify(self, ctx, *, verification_string: str):
|
Not really a rewrite but more of a port
|
||||||
"""Does verification.
|
|
||||||
|
|
||||||
See text on top of #verification for more info."""
|
Git blame tells me that I should blame/credit Robin Lambertz"""
|
||||||
|
if message.channel.id == config.welcome_channel:
|
||||||
|
# Assign common stuff into variables to make stuff less of a mess
|
||||||
|
member = message.author
|
||||||
|
full_name = str(member)
|
||||||
|
discrim = str(member.discriminator)
|
||||||
|
guild = message.guild
|
||||||
|
chan = message.channel
|
||||||
|
mcl = message.content.lower()
|
||||||
|
|
||||||
await ctx.message.delete()
|
# Get the role we will give in case of success
|
||||||
|
success_role = guild.get_role(config.participant_role)
|
||||||
|
|
||||||
veriflogs_channel = ctx.guild.get_channel(config.veriflogs_chanid)
|
# Get a list of stuff we'll allow and will consider close
|
||||||
verification_role = ctx.guild.get_role(config.read_rules_roleid)
|
allowed_names = [f"@{full_name}", full_name, str(member.id)]
|
||||||
verification_wanted = config.verification_code\
|
close_names = [f"@{member.name}", member.name, discrim,
|
||||||
.replace("[discrim]", ctx.author.discriminator)
|
f"#{discrim}"]
|
||||||
|
# Now add the same things but with newlines at the end of them
|
||||||
|
allowed_names += [(an + '\n') for an in allowed_names]
|
||||||
|
close_names += [(cn + '\n') for cn in close_names]
|
||||||
|
|
||||||
# Do checks on if the user can even attempt to verify
|
# Finally, hash the stuff so that we can access them later :)
|
||||||
if ctx.channel.id != config.verification_chanid:
|
sha1_allow = [hashlib.sha1(name.encode('utf-8')).hexdigest()
|
||||||
resp = await ctx.send("This command can only be used "
|
for name in allowed_names]
|
||||||
f"on <#{config.verification_chanid}>.")
|
md5_allow = [hashlib.md5(name.encode('utf-8')).hexdigest()
|
||||||
await asyncio.sleep(config.sleep_secs)
|
for name in allowed_names]
|
||||||
return await resp.delete()
|
sha1_close = [hashlib.sha1(name.encode('utf-8')).hexdigest()
|
||||||
|
for name in close_names]
|
||||||
|
|
||||||
if verification_role in ctx.author.roles:
|
# I'm not even going to attempt to break those into lines jfc
|
||||||
resp = await ctx.send("This command can only by those without "
|
if any(allow in mcl for allow in sha1_allow):
|
||||||
f"<@&{config.read_rules_roleid}> role.")
|
await member.add_roles(success_role)
|
||||||
await asyncio.sleep(config.sleep_secs)
|
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))
|
||||||
return await resp.delete()
|
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 full_name in message.content or str(member.id) in message.content or member.name in message.content or discrim in message.content:
|
||||||
|
await chan.send(f"{message.author.mention} :no_entry: Incorrect. You need to do something 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.")
|
||||||
|
|
||||||
# Log verification attempt
|
async def on_message(self, message):
|
||||||
await self.bot.update_logs("Verification Attempt",
|
try:
|
||||||
ctx.author.id,
|
await self.process_message(message)
|
||||||
veriflogs_channel,
|
except discord.errors.Forbidden:
|
||||||
log_text=verification_string,
|
chan = self.bot.get_channel(message.channel)
|
||||||
digdepth=50, result=-1)
|
await chan.send("💢 I don't have permission to do this.")
|
||||||
|
|
||||||
# Check verification code
|
async def on_message_edit(self, before, after):
|
||||||
if verification_string.lower().strip() == verification_wanted:
|
try:
|
||||||
resp = await ctx.send("Success! Welcome to the "
|
await self.process_message(after)
|
||||||
f"club, {str(ctx.author)}.")
|
except discord.errors.Forbidden:
|
||||||
await self.bot.update_logs("Verification Attempt",
|
chan = self.bot.get_channel(after.channel)
|
||||||
ctx.author.id,
|
await chan.send("💢 I don't have permission to do this.")
|
||||||
veriflogs_channel,
|
|
||||||
digdepth=50, result=0)
|
# @commands.guild_only()
|
||||||
await asyncio.sleep(config.sleep_secs)
|
# @commands.command()
|
||||||
await ctx.author.add_roles(verification_role)
|
# async def verify(self, ctx, *, verification_string: str):
|
||||||
await resp.delete()
|
# """Does verification.
|
||||||
else:
|
|
||||||
resp = await ctx.send(f"Incorrect password, {str(ctx.author)}.")
|
# See text on top of #verification for more info."""
|
||||||
await asyncio.sleep(config.sleep_secs)
|
|
||||||
await resp.delete()
|
# await ctx.message.delete()
|
||||||
|
|
||||||
|
# veriflogs_channel = ctx.guild.get_channel(config.veriflogs_chanid)
|
||||||
|
# verification_role = ctx.guild.get_role(config.read_rules_roleid)
|
||||||
|
# verification_wanted = config.verification_code\
|
||||||
|
# .replace("[discrim]", ctx.author.discriminator)
|
||||||
|
|
||||||
|
# # Do checks on if the user can even attempt to verify
|
||||||
|
# if ctx.channel.id != config.verification_chanid:
|
||||||
|
# resp = await ctx.send("This command can only be used "
|
||||||
|
# f"on <#{config.verification_chanid}>.")
|
||||||
|
# await asyncio.sleep(config.sleep_secs)
|
||||||
|
# return await resp.delete()
|
||||||
|
|
||||||
|
# if verification_role in ctx.author.roles:
|
||||||
|
# resp = await ctx.send("This command can only by those without "
|
||||||
|
# f"<@&{config.read_rules_roleid}> role.")
|
||||||
|
# await asyncio.sleep(config.sleep_secs)
|
||||||
|
# return await resp.delete()
|
||||||
|
|
||||||
|
# # Log verification attempt
|
||||||
|
# await self.bot.update_logs("Verification Attempt",
|
||||||
|
# ctx.author.id,
|
||||||
|
# veriflogs_channel,
|
||||||
|
# log_text=verification_string,
|
||||||
|
# digdepth=50, result=-1)
|
||||||
|
|
||||||
|
# # Check verification code
|
||||||
|
# if verification_string.lower().strip() == verification_wanted:
|
||||||
|
# resp = await ctx.send("Success! Welcome to the "
|
||||||
|
# f"club, {str(ctx.author)}.")
|
||||||
|
# await self.bot.update_logs("Verification Attempt",
|
||||||
|
# ctx.author.id,
|
||||||
|
# veriflogs_channel,
|
||||||
|
# digdepth=50, result=0)
|
||||||
|
# await asyncio.sleep(config.sleep_secs)
|
||||||
|
# await ctx.author.add_roles(verification_role)
|
||||||
|
# await resp.delete()
|
||||||
|
# else:
|
||||||
|
# resp = await ctx.send(f"Incorrect password, {str(ctx.author)}.")
|
||||||
|
# await asyncio.sleep(config.sleep_secs)
|
||||||
|
# await resp.delete()
|
||||||
|
|
||||||
|
|
||||||
def setup(bot):
|
def setup(bot):
|
||||||
|
|
|
@ -18,3 +18,4 @@ staff_role_ids = [526384077679624192, # Team role in NotSwitched
|
||||||
|
|
||||||
modlog_channel = 526377735908491284 # Log channel in NotSwitched
|
modlog_channel = 526377735908491284 # Log channel in NotSwitched
|
||||||
welcome_channel = 526372470752673792 # rules-info channel in NotSwitched
|
welcome_channel = 526372470752673792 # rules-info channel in NotSwitched
|
||||||
|
participant_role = 526378358129557506 # participant role in NotSwitched
|
||||||
|
|
Loading…
Reference in a new issue