Skip to content
14 changes: 13 additions & 1 deletion src/bot/cogs/logging/logging_message_delete.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ def __init__(self, bot):
raise RuntimeError("Failed to fetch staff channel setting from API.")
self.staff_channel = setting["setting"]["value"]

setting = self.bot.api.get_one_setting("1") # Verification Channel ID
if setting["status"] != "ok":
raise RuntimeError("Failed to fetch verification channel setting from API.")
self.verification_channel = setting["setting"]["value"]
self.verification_command = f"{os.getenv('PREFIX')}verify"

self.chat_log = self.bot.api.get_one_log_setting("3") # chat_log
if self.chat_log["status"] != "ok":
raise RuntimeError("Failed to fetch chat log setting from API.")
Expand Down Expand Up @@ -125,10 +131,16 @@ async def on_message_delete(self, message) -> None:
)
return

if message.channel.id == self.staff_channel:
if message.channel.id == int(self.staff_channel):
logger.debug("Message delete in staff channel was ignored.")
return

if message.channel.id == int(self.verification_channel) and (
message.author.bot or message.content == self.verification_command
):
logger.debug("Message from verification process was ignored.")
return

audit_log = [entry async for entry in message.guild.audit_logs(limit=1)][0]
if self.chat_log["status"] == "ok":
if self.chat_log["log_setting"]["value"] == "0":
Expand Down
13 changes: 6 additions & 7 deletions src/bot/cogs/verification/verification_dropdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

import datetime
import logging
from time import sleep

import discord
from discord.ext import commands
Expand Down Expand Up @@ -97,13 +96,13 @@ async def callback(self, interaction: discord.Interaction):
"Someone is verifying, but there is no verification role set!"
)
else:
msg = await interaction.response.send_message("You are a robot? Nice try.")
await interaction.response.send_message(
"You are a robot? Nice try.", delete_after=3.0
)
await verification_log.send(
f"{interaction.user.display_name} admitted to being a robot, and was kicked. "
f"{interaction.user.display_name} admitted to being a robot, and was kicked."
)
sleep(3)
await interaction.user.kick(reason="User admitted to being a robot.")
Comment thread
kritarth2135 marked this conversation as resolved.
await msg.delete()


class DropdownView(discord.ui.View):
Expand Down Expand Up @@ -141,7 +140,7 @@ async def verify(self, ctx):
return

else:
if self.verified_role not in [role.id for role in ctx.author.roles]:
if int(self.verified_role) not in [role.id for role in ctx.author.roles]:
logger.debug(f"{ctx.author.name} is attempting to verify")
await ctx.send(
"# ~ Verification ~ \n"
Expand All @@ -151,7 +150,7 @@ async def verify(self, ctx):
delete_after=15.0,
)
else:
await ctx.send("You are already verified. Go away.")
await ctx.send("You are already verified. Go away.", delete_after=10.0)


async def setup(bot: commands.Bot) -> None:
Expand Down
65 changes: 37 additions & 28 deletions src/bot/cogs/verification/verification_on_join.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,34 +89,43 @@ async def on_member_join(self, member: discord.Member):
# Is being called even though it should not be.
# await self.kick_if_not_verified(member, 3600, verification_log)

# @commands.Cog.listener()
# async def on_message(self, message):
# """
# Keep verification clean again
# """
# if message.author.guild.id != int(os.getenv("MASTER_GUILD")):
# logger.warning("on_message in verification fired, but not in master guild. Ignoring event.")
# return
#
# if message.channel.id == int(self.verification_channel):
# if not message.author.bot:
# if f"{os.getenv('PREFIX')}verify" == message.content: # keep it exact
# # user is doing it right, and the verification_dropdown is triggered
# logger.debug(f"{message.author.name} started verification.")
# await sleep(3)
# await message.delete() # cleanup correct verification calls
# return
# else: # this covers any other message in the channel.
# await message.delete() # delete the user's incorrect message
# bot_message = await message.channel.send(
# f"You need to use the **{os.getenv('PREFIX')}verify** command.")
#
# logs_channel = await self.bot.fetch_channel(self.verification_log)
# await logs_channel.send(
# f"{message.author} is failing at life in {self.bot.get_channel(self.verification_channel)}")
#
# await sleep(8)
# bot_message.delete() # remove the message to correct people after 8? seconds
@commands.Cog.listener()
async def on_message(self, message):
Comment thread
kritarth2135 marked this conversation as resolved.
"""
Keep verification clean again
"""
if isinstance(message.channel, discord.channel.DMChannel):
logger.info("Skipping messages in DMs.")
return

if message.author.guild.id != int(os.getenv("MASTER_GUILD")):
logger.warning(
"on_message in verification fired, but not in master guild. Ignoring event."
)
return

if message.channel.id == int(self.verification_channel):
if not message.author.bot and not (
message.author.guild_permissions.administrator
or message.author.guild_permissions.ban_members
):
if f"{os.getenv('PREFIX')}verify" == message.content: # keep it exact
# user is doing it right, and the verification_dropdown is triggered
logger.debug(f"{message.author.name} started verification.")
await sleep(3)
await message.delete() # cleanup correct verification calls
return
else: # this covers any other message in the channel.
await message.delete() # delete the user's incorrect message
await message.channel.send(
f"You need to use the **{os.getenv('PREFIX')}verify** command.",
delete_after=8.0,
)

logs_channel = await self.bot.fetch_channel(self.verification_log)
await logs_channel.send(
f"{message.author} is failing at life in {self.bot.get_channel(int(self.verification_channel)).mention}"
)


async def setup(bot: commands.Bot) -> None:
Expand Down
Loading