Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -113,3 +113,5 @@ poetry.lock

# mypy
.mypy_cache/

config/
16 changes: 12 additions & 4 deletions bot/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def __init__(self, prefix="t.", *args, **kwargs):
"mod_mail": True,
"bug_report": False,
"suggestions": False,
"staff_application": False,
"staff_application": True,
}
self.suppressed_deletes = set()
self._status_cycle = itertools.cycle([
Expand Down Expand Up @@ -125,12 +125,20 @@ async def send_restart_message(self: commands.Bot):
embed = simple_embed(message=f"Build version: [{commit_hash}]({github_repo_link}/commit/{commit_hash})",
title="")
embed.set_footer(text=commit_message)
# await self.sys_log_channel.send(
# embed=embed,
# )
await self.sys_log_channel.send(
embed=embed,
)
except discord.Forbidden:
pass

async def log(self, content: str, embed: discord.Embed) -> bool:
try:
await self.sys_log_channel.send(content=content, embed=embed)
return True
except (discord.Forbidden, discord.HTTPException):
return False


@staticmethod
async def safe_send(
target: Messageable,
Expand Down
9 changes: 7 additions & 2 deletions bot/cogs/anti_raid.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ async def on_message(self, message: discord.Message):
[(now, message.channel.id, "[Mentioned @everyone]", message.id)],
)
self.message_log[guild.id].pop(member.id, None)
await self.bot.progression_manager.set_ban_status(
user_id=member.id,
guild_id=guild.id,
status=True
)
return

# BAIT CHANNEL: IMMEDIATE BAN
Expand Down Expand Up @@ -143,7 +148,7 @@ async def handle_bot_trap_raid(self, member: discord.Member):
await guild.ban(
member,
reason=self.BOT_TRAP_BAN_REASON,
delete_message_days=1,
delete_message_seconds=65
)
await self.bot.progression_manager.set_ban_status(
user_id=member.id,
Expand Down Expand Up @@ -174,7 +179,7 @@ async def handle_raid(
await guild.ban(
member,
reason=self.BAN_REASON,
delete_message_days=1,
delete_message_seconds=65,
)
except discord.Forbidden:
return
Expand Down
22 changes: 17 additions & 5 deletions bot/cogs/button_utility.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,15 @@ def __init__(self, cog: "TortoiseDM"):
options = [
discord.SelectOption(
label="Accidentally Selected 'I am Bot' Option",
value="accidental_trap_victim",
value="accidental_trap_option_victim",
description="I accidentally selected 'I am Bot' option while joining.",
emoji="🤖"
emoji="<:pepebot:1510994481309155388>"
),
discord.SelectOption(
label="Accidentally Sent Message in '#do-not-send-message' Channel",
value="accidental_trap_channel_victim",
description="I accidentally sent a message in the bot trap channel.",
emoji="<:pepe_with_gun2:731169353533227108>"
),
discord.SelectOption(label="Unfair Ban", value="unfair_ban", description="I feel my ban was unjust.",
emoji="⚖️"),
Expand All @@ -45,7 +51,8 @@ async def callback(self, interaction: discord.Interaction):
reason = self.values[0]

reason_mappings = {
"accidental_trap_victim": "Accidentally Selected 'I am Bot' Option",
"accidental_trap_option_victim": "Accidentally Selected 'I am Bot' Option",
"accidental_trap_channel_victim": "Accidentally Sent Message in '#do-not-send-message' Channel",
"unfair_ban": "Unfair Ban Appeal",
"apology": "Apology / Second Chance Request",
"compromised": "Compromised Account Appeal",
Expand All @@ -55,7 +62,7 @@ async def callback(self, interaction: discord.Interaction):

self.disabled = True

if reason == "accidental_trap_victim":
if reason == "accidental_trap_option_victim" or reason == "accidental_trap_channel_victim":
await interaction.response.edit_message(view=self.view)

is_banned = await self.cog.bot.progression_manager.is_auto_banned(user_id=user.id,
Expand All @@ -80,12 +87,17 @@ async def callback(self, interaction: discord.Interaction):
"Welcome back to Tortoise Programming Community!",
)
)
await self.cog.bot.log(
embed=info(
f"`{target_user}` just unbanned themselves via appeal.", self.cog.bot.user, ""
)
)

await self.cog.bot.progression_manager.set_ban_status(user_id=user.id,
guild_id=tortoise_guild_id,
status=False)

await interaction.followup.send(f"✅ Successfully unbanned. You may rejoin!", ephemeral=True)
await interaction.followup.send(f"✅ Successfully unbanned. You may rejoin!\n\n{server_link}", ephemeral=True)

except discord.NotFound:
await interaction.followup.send("You are not currently recorded on the server ban list.",
Expand Down
4 changes: 2 additions & 2 deletions bot/cogs/giveaway.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from discord import app_commands

from bot.utils.embed_handler import info, warning, success
from bot.utils.checks import check_if_tortoise_staff
from bot.utils.checks import check_if_tortoise_mod


class QuestionModal(discord.ui.Modal, title='Add Question'):
Expand Down Expand Up @@ -214,7 +214,7 @@ async def cog_load(self):

@app_commands.command(name='giveaway_create', description='Start a new giveaway')
@app_commands.describe(duration_minutes="How long the giveaway lasts", winners="Number of winners to pick")
@app_commands.check(check_if_tortoise_staff)
@app_commands.check(check_if_tortoise_mod)
async def giveaway_create(
self,
interaction: discord.Interaction,
Expand Down
30 changes: 24 additions & 6 deletions bot/cogs/join_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ def __init__(self, bot):
self.introduction_channel = None
self.retention = bot.retention_manager
self.custom_welcome_content = None
self.ban_appeal_channel = None


def get_unbanned_embed(self):
Expand All @@ -43,6 +44,7 @@ async def on_ready(self):
self.log_channel = self.bot.get_channel(constants.system_log_channel_id)
self.welcome_role = self.guild.get_role(constants.new_member_role_id)
self.introduction_channel = self.guild.get_channel(constants.introduction_channel_id)
self.ban_appeal_channel = self.ban_appeal_guild.get_channel(constants.ban_appeal_channel_id)

self.bot.loop.create_task(self.tracker.refresh_invite_cache())
if not self.daily_retention_report.is_running():
Expand Down Expand Up @@ -108,6 +110,12 @@ async def handle_ban_appeal_server_join(self, member: Member):

await member.kick(reason="Not banned from Tortoise Programming Community")
await asyncio.sleep(3)
if is_banned:
await self.ban_appeal_channel.send(
member.mention,
delete_after=5,
)


@staticmethod
def get_post_intro_message() -> str:
Expand Down Expand Up @@ -149,15 +157,25 @@ async def on_message(self, message: Message):
[
"👋", "🔥", "👍", "😄", "😸",
"🌟", "🫶", "🤝", "👌", "✌️",
"<:upvote:741202481090002994>"
"<:upvote:741202481090002994>",
"<:hi:706045497810485288>",
]
)
)
embed = embed_handler.info(
self.get_post_intro_message(),
self.bot.user,
""
)
if len(message.clean_content) < 15:
embed = embed_handler.info(
f"Your introduction message looks small, No worries! You can still edit it!\n\n"
f"Once you are done, head over to <#{constants.general_channel_id}> and "
f"start chatting with everyone.",
self.bot.user,
""
)
else:
embed = embed_handler.info(
self.get_post_intro_message(),
self.bot.user,
""
)
await asyncio.sleep(0.7)
await message.channel.send(embed=embed, delete_after=30)

Expand Down
Loading
Loading