Skip to content
Draft
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
12 changes: 10 additions & 2 deletions techsupport_bot/commands/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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:
Expand All @@ -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
Expand Down
4 changes: 4 additions & 0 deletions techsupport_bot/commands/duck.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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")
Expand Down
10 changes: 7 additions & 3 deletions techsupport_bot/commands/factoids.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)]
Expand All @@ -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",
Expand Down
3 changes: 3 additions & 0 deletions techsupport_bot/commands/kanye.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand Down
5 changes: 5 additions & 0 deletions techsupport_bot/commands/modmail.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions techsupport_bot/commands/news.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
15 changes: 15 additions & 0 deletions techsupport_bot/core/databases.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions techsupport_bot/functions/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Functions are commandless cogs"""

from .automod import *
from .holidays import *
from .nickname import *
10 changes: 10 additions & 0 deletions techsupport_bot/functions/holidays.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import discord

Check notice on line 1 in techsupport_bot/functions/holidays.py

View check run for this annotation

codefactor.io / CodeFactor

techsupport_bot/functions/holidays.py#L1

Missing module docstring (missing-module-docstring)


async def isGuildClosed(bot: object, guild: discord.Guild) -> bool:

Check notice on line 4 in techsupport_bot/functions/holidays.py

View check run for this annotation

codefactor.io / CodeFactor

techsupport_bot/functions/holidays.py#L4

Missing function or method docstring (missing-function-docstring)
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
Loading