From c2f847d45eb1ddd4ae1026e8f1a710a47c1ddd8f Mon Sep 17 00:00:00 2001 From: ajax146 <31014239+ajax146@users.noreply.github.com> Date: Wed, 15 Oct 2025 16:55:21 -0400 Subject: [PATCH 1/4] Crops factoid info to prevent logs factoids from erroring --- techsupport_bot/commands/factoids.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/techsupport_bot/commands/factoids.py b/techsupport_bot/commands/factoids.py index 5c0fd44c..4ed5f46a 100644 --- a/techsupport_bot/commands/factoids.py +++ b/techsupport_bot/commands/factoids.py @@ -1634,7 +1634,7 @@ async def info( # Adds all fields to the embed embed.add_field(name="Aliases", value=alias_list) embed.add_field(name="Embed", value=bool(factoid.embed_config)) - embed.add_field(name="Contents", value=factoid.message) + embed.add_field(name="Contents", value=factoid.message[:1020]) embed.add_field(name="Date of creation", value=factoid.time) # Get all the special properties of a factoid, if any are set From 9db7056224036c525f09a7480e013e66aa89445a Mon Sep 17 00:00:00 2001 From: ajax146 <31014239+ajax146@users.noreply.github.com> Date: Wed, 15 Oct 2025 17:09:31 -0400 Subject: [PATCH 2/4] Start of auto holiday closure --- techsupport_bot/commands/application.py | 12 ++++++++++-- techsupport_bot/commands/duck.py | 4 ++++ techsupport_bot/commands/factoids.py | 12 ++++++++---- techsupport_bot/commands/kanye.py | 3 +++ techsupport_bot/commands/news.py | 3 +++ techsupport_bot/core/databases.py | 15 +++++++++++++++ techsupport_bot/functions/__init__.py | 1 + 7 files changed, 44 insertions(+), 6 deletions(-) diff --git a/techsupport_bot/commands/application.py b/techsupport_bot/commands/application.py index 70530850..952b3999 100644 --- a/techsupport_bot/commands/application.py +++ b/techsupport_bot/commands/application.py @@ -12,6 +12,7 @@ import ui from core import auxiliary, cogs, extensionconfig from discord import app_commands +from functions import holidays if TYPE_CHECKING: import bot @@ -182,6 +183,8 @@ async def execute(self: Self, config: munch.Munch, guild: discord.Guild) -> None config (munch.Munch): The guild config for the executing loop guild (discord.Guild): The guild the loop is executing for """ + if holidays.isGuildClosed(self.bot, guild): + return channels = config.extensions.application.notification_channels.value for channel in channels: channel = guild.get_channel(int(channel)) @@ -719,6 +722,9 @@ async def check_if_can_apply(self: Self, applicant: discord.Member) -> bool: Returns: bool: True if they can apply, False if they cannot apply """ + if holidays.isGuildClosed(self.bot, applicant.guild): + return False + config = self.bot.guild_configs[str(applicant.guild.id)] role = applicant.guild.get_role( int(config.extensions.application.application_role.value) @@ -992,7 +998,8 @@ async def execute(self: Self, config: munch.Munch, guild: discord.Guild) -> None embed.description = f"{embed.description}\n{event}" else: embed.description = f"{event}" - await channel.send(embed=embed) + if not holidays.isGuildClosed(self.bot, guild): + await channel.send(embed=embed) apps = await self.get_applications_by_status(ApplicationStatus.PENDING, guild) if not apps: @@ -1012,7 +1019,8 @@ async def execute(self: Self, config: munch.Munch, guild: discord.Guild) -> None embed.description = "\n".join(list_of_applicants) - await channel.send(embed=embed) + if not holidays.isGuildClosed(self.bot, guild): + await channel.send(embed=embed) async def wait(self: Self, config: munch.Munch, guild: discord.Guild) -> None: """The queues the pending application reminder based on the cron config diff --git a/techsupport_bot/commands/duck.py b/techsupport_bot/commands/duck.py index 8820e2ea..ca5da744 100644 --- a/techsupport_bot/commands/duck.py +++ b/techsupport_bot/commands/duck.py @@ -16,6 +16,7 @@ from core import auxiliary, cogs, extensionconfig, moderation from discord import Color as embed_colors from discord.ext import commands +from functions import holidays if TYPE_CHECKING: import bot @@ -157,6 +158,9 @@ async def execute( banned_user (discord.User, optional): A user that is not allowed to claim the duck. Defaults to None. """ + if holidays.isGuildClosed(self.bot, guild): + return + if not channel: config = self.bot.guild_configs[str(guild.id)] log_channel = config.get("logging_channel") diff --git a/techsupport_bot/commands/factoids.py b/techsupport_bot/commands/factoids.py index 4ed5f46a..4cbca3d7 100644 --- a/techsupport_bot/commands/factoids.py +++ b/techsupport_bot/commands/factoids.py @@ -35,6 +35,7 @@ from croniter import CroniterBadCronError from discord import app_commands from discord.ext import commands +from functions import holidays if TYPE_CHECKING: import bot @@ -1176,7 +1177,8 @@ async def cronjob( content = factoid.message try: - message = await channel.send(content=content, embed=embed) + if not holidays.isGuildClosed(self.bot, ctx.guild): + message = await channel.send(content=content, embed=embed) except discord.errors.HTTPException as exception: config = self.bot.guild_configs[str(ctx.guild.id)] @@ -1189,9 +1191,11 @@ async def cronjob( exception=exception, ) # Sends the raw factoid instead of the embed as fallback - message = await channel.send(content=factoid.message) + if not holidays.isGuildClosed(self.bot, ctx.guild): + message = await channel.send(content=factoid.message) - await self.send_to_irc(channel, message, factoid.message) + if not holidays.isGuildClosed(self.bot, ctx.guild): + await self.send_to_irc(channel, message, factoid.message) @commands.group( brief="Executes a factoid command", @@ -1634,7 +1638,7 @@ async def info( # Adds all fields to the embed embed.add_field(name="Aliases", value=alias_list) embed.add_field(name="Embed", value=bool(factoid.embed_config)) - embed.add_field(name="Contents", value=factoid.message[:1020]) + embed.add_field(name="Contents", value=factoid.message) embed.add_field(name="Date of creation", value=factoid.time) # Get all the special properties of a factoid, if any are set diff --git a/techsupport_bot/commands/kanye.py b/techsupport_bot/commands/kanye.py index 66e21e34..8aac652e 100644 --- a/techsupport_bot/commands/kanye.py +++ b/techsupport_bot/commands/kanye.py @@ -10,6 +10,7 @@ import munch from core import auxiliary, cogs, extensionconfig from discord.ext import commands +from functions import holidays if TYPE_CHECKING: import bot @@ -100,6 +101,8 @@ async def execute(self: Self, config: munch.Munch, guild: discord.Guild) -> None config (munch.Munch): The guild config where the loop is taking place guild (discord.Guild): The guild where the loop is taking place """ + if holidays.isGuildClosed(self.bot, guild): + return quote = await self.get_quote() embed = self.generate_themed_embed(quote=quote) diff --git a/techsupport_bot/commands/news.py b/techsupport_bot/commands/news.py index 957d1262..d8d1c562 100644 --- a/techsupport_bot/commands/news.py +++ b/techsupport_bot/commands/news.py @@ -12,6 +12,7 @@ from botlogging import LogContext, LogLevel from core import cogs, extensionconfig from discord import app_commands +from functions import holidays if TYPE_CHECKING: import bot @@ -180,6 +181,8 @@ async def execute(self: Self, config: munch.Munch, guild: discord.Guild) -> None config (munch.Munch): The guild config for the guild looping guild (discord.Guild): The guild where the loop is running """ + if holidays.isGuildClosed(self.bot, guild): + return channel = guild.get_channel(int(config.extensions.news.channel.value)) if not channel: return diff --git a/techsupport_bot/core/databases.py b/techsupport_bot/core/databases.py index 7f5be522..87ebe171 100644 --- a/techsupport_bot/core/databases.py +++ b/techsupport_bot/core/databases.py @@ -192,6 +192,20 @@ class Grab(bot.db.Model): ) nsfw: bool = bot.db.Column(bot.db.Boolean, default=False) + class HolidayClose(bot.db.Model): + """The postgres table for holiday closures + Currently used in holidays.py + + Attributes: + pk (int): The automatic primary key + guild_id (str): The ID of the user banned from modmail + """ + + __tablename__ = "holiday_closeda" + + pk = bot.db.Column(bot.db.Integer, primary_key=True, autoincrement=True) + guild_id: str = bot.db.Column(bot.db.String, default=None) + class IRCChannelMapping(bot.db.Model): """The postgres table for IRC->discord maps Currently used in relay.py @@ -371,6 +385,7 @@ class Votes(bot.db.Model): bot.models.Factoid = Factoid bot.models.FactoidJob = FactoidJob bot.models.Grab = Grab + bot.models.HolidayClose = HolidayClose bot.models.IRCChannelMapping = IRCChannelMapping bot.models.ModmailBan = ModmailBan bot.models.UserNote = UserNote diff --git a/techsupport_bot/functions/__init__.py b/techsupport_bot/functions/__init__.py index df256aa0..7dae9ff5 100644 --- a/techsupport_bot/functions/__init__.py +++ b/techsupport_bot/functions/__init__.py @@ -1,4 +1,5 @@ """Functions are commandless cogs""" from .automod import * +from .holidays import * from .nickname import * From 4fc70e77cf6174a5d06968cf01fa98d4b501c65f Mon Sep 17 00:00:00 2001 From: ajax146 <31014239+ajax146@users.noreply.github.com> Date: Wed, 15 Oct 2025 17:09:43 -0400 Subject: [PATCH 3/4] Add holidays.py --- techsupport_bot/functions/holidays.py | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 techsupport_bot/functions/holidays.py diff --git a/techsupport_bot/functions/holidays.py b/techsupport_bot/functions/holidays.py new file mode 100644 index 00000000..63f9827a --- /dev/null +++ b/techsupport_bot/functions/holidays.py @@ -0,0 +1,10 @@ +import discord + + +async def isGuildClosed(bot: object, guild: discord.Guild) -> bool: + db_enty = await bot.models.HolidayClose.query.where( + bot.models.HolidayClose.guild_id == str(guild.id) + ).gino.first() + if db_enty: + return True + return False From 76ecdc4da2a27631059bf2652bdbaa00cf2f61ae Mon Sep 17 00:00:00 2001 From: ajax146 <31014239+ajax146@users.noreply.github.com> Date: Wed, 15 Oct 2025 18:10:34 -0400 Subject: [PATCH 4/4] Close modmail --- techsupport_bot/commands/modmail.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/techsupport_bot/commands/modmail.py b/techsupport_bot/commands/modmail.py index 86f6301a..b41a2081 100644 --- a/techsupport_bot/commands/modmail.py +++ b/techsupport_bot/commands/modmail.py @@ -24,6 +24,7 @@ import ui from core import auxiliary, cogs, extensionconfig from discord.ext import commands +from functions import holidays if TYPE_CHECKING: import bot @@ -86,6 +87,10 @@ async def on_message(self: Self, message: discord.Message) -> None: Args: message (discord.Message): Every sent message, gets filtered to only dms """ + channel = Ts_client.get_channel(MODMAIL_FORUM_ID) + if holidays.isGuildClosed(Ts_client, channel.guild): + await message.add_reaction("🎄") + return if isinstance(message.channel, discord.DMChannel) and not message.author.bot: # Log all DMs regardless of what happens to them