From 26e6e1a39753b810cf6ff4b8245ec4b518fff40c Mon Sep 17 00:00:00 2001 From: lunazeta Date: Thu, 19 Mar 2026 13:34:52 +0000 Subject: [PATCH 1/6] Updated bot_moderation.py based on #296 --- cogs/bot_moderation.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cogs/bot_moderation.py b/cogs/bot_moderation.py index 6cc3351..4421903 100644 --- a/cogs/bot_moderation.py +++ b/cogs/bot_moderation.py @@ -7,7 +7,7 @@ from config import CONFIG -class Database(Cog): +class BotModeration(Cog): def __init__(self, bot: Bot): self.bot = bot @@ -30,7 +30,7 @@ async def on_message(self, message: discord.Message): ) await message.delete() - await channel.send(f'<@&{CONFIG.UWCS_EXEC_ROLE_IDS[1]}>', embed=embed) + await channel.send(f'{' '.join([f'<@&{exec_role}>' for exec_role in CONFIG.UWCS_EXEC_ROLE_IDS])}', embed=embed) await message.author.timeout(timedelta(days=1)) async def setup(bot: Bot): From 2bbd4290a09d4c924370e9fd8f037aef607a6a44 Mon Sep 17 00:00:00 2001 From: lunazeta Date: Thu, 19 Mar 2026 14:45:30 +0000 Subject: [PATCH 2/6] Made recommended changes based on #296 --- apollo.py | 76 +++++++++++++++++++++--------------------- cogs/bot_moderation.py | 19 ++++++----- config/config.py | 3 +- 3 files changed, 51 insertions(+), 47 deletions(-) diff --git a/apollo.py b/apollo.py index c0ee7a6..8de7e7a 100644 --- a/apollo.py +++ b/apollo.py @@ -19,44 +19,44 @@ # The command extensions to be loaded by the bot EXTENSIONS = [ - "cogs.commands.announce", - "cogs.commands.birthday", - "cogs.commands.chess", - "cogs.commands.counting", - "cogs.commands.chatgpt", - "cogs.commands.dalle", - "cogs.commands.date", - "cogs.commands.eightball", - "cogs.commands.event_sync", - "cogs.commands.flip", - "cogs.commands.karma_admin", - "cogs.commands.karma_blacklist", - "cogs.commands.karma", - "cogs.commands.lcalc", - "cogs.commands.misc", - "cogs.commands.onmessage", - "cogs.commands.openaiadmin", - "cogs.commands.quotes", - "cogs.commands.rolemenu", - "cogs.commands.reminders", - "cogs.commands.roll", - "cogs.commands.run", - "cogs.commands.roomsearch", - "cogs.commands.say", - "cogs.commands.summarise", - "cogs.commands.system", - "cogs.commands.tex", - "cogs.commands.vote", - "cogs.commands.widen", - "cogs.commands.xkcd", - "cogs.commands.market", - "cogs.commands.auction", - "cogs.bot_moderation", - "cogs.channel_checker", - "cogs.database", - "cogs.irc", - "cogs.parallelism", - "cogs.welcome", + # "cogs.commands.announce", + # "cogs.commands.birthday", + # "cogs.commands.chess", + # "cogs.commands.counting", + # "cogs.commands.chatgpt", + # "cogs.commands.dalle", + # "cogs.commands.date", + # "cogs.commands.eightball", + # "cogs.commands.event_sync", + # "cogs.commands.flip", + # "cogs.commands.karma_admin", + # "cogs.commands.karma_blacklist", + # "cogs.commands.karma", + # "cogs.commands.lcalc", + # "cogs.commands.misc", + # "cogs.commands.onmessage", + # "cogs.commands.openaiadmin", + # "cogs.commands.quotes", + # "cogs.commands.rolemenu", + # "cogs.commands.reminders", + # "cogs.commands.roll", + # "cogs.commands.run", + # "cogs.commands.roomsearch", + # "cogs.commands.say", + # "cogs.commands.summarise", + # "cogs.commands.system", + # "cogs.commands.tex", + # "cogs.commands.vote", + # "cogs.commands.widen", + # "cogs.commands.xkcd", + # "cogs.commands.market", + # "cogs.commands.auction", + "cogs.bot_moderation" + # "cogs.channel_checker", + # "cogs.database", + # "cogs.irc", + # "cogs.parallelism", + # "cogs.welcome", ] diff --git a/cogs/bot_moderation.py b/cogs/bot_moderation.py index 4421903..a8bde63 100644 --- a/cogs/bot_moderation.py +++ b/cogs/bot_moderation.py @@ -4,8 +4,11 @@ from discord import Color, Embed from discord.ext.commands import Bot, Cog +from pytz import timezone + from config import CONFIG +LONDON = timezone("Europe/London") class BotModeration(Cog): def __init__(self, bot: Bot): @@ -13,9 +16,9 @@ def __init__(self, bot: Bot): @Cog.listener() async def on_message(self, message: discord.Message): - joined_recently = message.author.joined_at > datetime.now() - timedelta(days=7) - contains_everyone = '@everyone' in message.content - is_giving_away = 'giving away' in message.content.lower() + joined_recently = message.author.joined_at > datetime.now(LONDON) - timedelta(days=7) + contains_everyone = "@everyone" in message.content + is_giving_away = "giving away" in message.content.lower() if not joined_recently or not (contains_everyone or is_giving_away): return @@ -23,15 +26,15 @@ async def on_message(self, message: discord.Message): channel = self.bot.get_channel(CONFIG.UWCS_BOT_LOG_CHANNEL_ID) embed_colour = Color.from_rgb(61, 83, 255) - embed_title = f'@{message.author.global_name}, ID: {message.author.id}' - embed_description = f'User suspected to be a bot, joined_recently: {joined_recently}, contains_everyone: {contains_everyone}, is_giving_away: {is_giving_away}' + embed_title = f"@{message.author.name}, ID: {message.author.id}" + embed_description = f"User suspected to be a bot, joined_recently: {joined_recently}, contains_everyone: {contains_everyone}, is_giving_away: {is_giving_away}" embed = Embed( - title=embed_title, color=embed_colour, embed_description=embed_description + title=embed_title, color=embed_colour, description=embed_description ) await message.delete() - await channel.send(f'{' '.join([f'<@&{exec_role}>' for exec_role in CONFIG.UWCS_EXEC_ROLE_IDS])}', embed=embed) + await channel.send(" ".join([f"<@&{exec_role}>" for exec_role in CONFIG.UWCS_EXEC_ROLE_IDS]), embed=embed) await message.author.timeout(timedelta(days=1)) async def setup(bot: Bot): - await bot.add_cog(Database(bot)) \ No newline at end of file + await bot.add_cog(BotModeration(bot)) \ No newline at end of file diff --git a/config/config.py b/config/config.py index 430beec..9b099fd 100644 --- a/config/config.py +++ b/config/config.py @@ -15,12 +15,13 @@ def __init__(self, filepath: str): self.DISCORD_TOKEN: str = parsed.get("discord_token") self.BOT_SECRET_KEY: str = parsed.get("db_secret_key") self.DATABASE_CONNECTION: str = parsed.get("database_connection") + self.TIMEZONE: str = parsed.get("timezone") # Optional self.UWCS_WELCOME_CHANNEL_ID: int = parsed.get("UWCS_welcome_channel_id") self.UWCS_ROLES_CHANNEL_ID: int = parsed.get("UWCS_roles_channel_id") self.UWCS_EXEC_SPAM_CHANNEL_ID: int = parsed.get("UWCS_exec_spam_channel_id") - self.UWCS_BOT_LOG_CHANNEL_ID: int = parsed.get("UWCS_message_log_channel_id") + self.UWCS_BOT_LOG_CHANNEL_ID: int = parsed.get("UWCS_bot_log_channel_id") self.UWCS_DISCORD_BRIDGE_BOT_ID: int = parsed.get("UWCS_discord_bridge_bot_id") self.OPENAI_API_KEY: str = parsed.get("openai_api_key") self.AI_INCLUDE_NAMES: bool = parsed.get("ai_include_names") From 336761df4d60280c386dd089bc3312ffbcc66a35 Mon Sep 17 00:00:00 2001 From: lunazeta Date: Thu, 19 Mar 2026 14:48:26 +0000 Subject: [PATCH 3/6] Same as previous commit --- cogs/bot_moderation.py | 2 +- config.example.yaml | 2 ++ config/config.py | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/cogs/bot_moderation.py b/cogs/bot_moderation.py index a8bde63..f868aaf 100644 --- a/cogs/bot_moderation.py +++ b/cogs/bot_moderation.py @@ -33,7 +33,7 @@ async def on_message(self, message: discord.Message): ) await message.delete() - await channel.send(" ".join([f"<@&{exec_role}>" for exec_role in CONFIG.UWCS_EXEC_ROLE_IDS]), embed=embed) + await channel.send(f"<@&{CONFIG.UWCS_BOT_PING_ROLE_ID}>", embed=embed) await message.author.timeout(timedelta(days=1)) async def setup(bot: Bot): diff --git a/config.example.yaml b/config.example.yaml index b210a57..1b20acb 100644 --- a/config.example.yaml +++ b/config.example.yaml @@ -24,6 +24,8 @@ config: UWCS_bot_log_channel_id: 1234 # IRC bridge bot ID UWCS_discord_bridge_bot_id: 1337 + # Role ID for bot pings + UWCS_bot_ping_role_id: 1234213 # API Key for chatgpt integration openai_api_key: openai # Whether to include usernames as part of a prompt diff --git a/config/config.py b/config/config.py index 9b099fd..9ecd239 100644 --- a/config/config.py +++ b/config/config.py @@ -23,6 +23,7 @@ def __init__(self, filepath: str): self.UWCS_EXEC_SPAM_CHANNEL_ID: int = parsed.get("UWCS_exec_spam_channel_id") self.UWCS_BOT_LOG_CHANNEL_ID: int = parsed.get("UWCS_bot_log_channel_id") self.UWCS_DISCORD_BRIDGE_BOT_ID: int = parsed.get("UWCS_discord_bridge_bot_id") + self.UWCS_BOT_PING_ROLE_ID: int = parsed.get("UWCS_bot_ping_role_id") self.OPENAI_API_KEY: str = parsed.get("openai_api_key") self.AI_INCLUDE_NAMES: bool = parsed.get("ai_include_names") self.AI_CHAT_CHANNELS: list[int] = parsed.get("ai_chat_channels") From 1a5924a6e5083c640b8938f83e427b24d91bbc90 Mon Sep 17 00:00:00 2001 From: lunazeta Date: Thu, 19 Mar 2026 14:51:40 +0000 Subject: [PATCH 4/6] Fixed import order --- cogs/bot_moderation.py | 1 - 1 file changed, 1 deletion(-) diff --git a/cogs/bot_moderation.py b/cogs/bot_moderation.py index f868aaf..af4c2f8 100644 --- a/cogs/bot_moderation.py +++ b/cogs/bot_moderation.py @@ -3,7 +3,6 @@ import discord from discord import Color, Embed from discord.ext.commands import Bot, Cog - from pytz import timezone from config import CONFIG From b188b7b7eec9f6dc519f197340299635623d5e09 Mon Sep 17 00:00:00 2001 From: lunazeta <70282650+lunazeta@users.noreply.github.com> Date: Thu, 19 Mar 2026 15:57:24 +0000 Subject: [PATCH 5/6] Uncomment extensions --- apollo.py | 76 +++++++++++++++++++++++++++---------------------------- 1 file changed, 38 insertions(+), 38 deletions(-) diff --git a/apollo.py b/apollo.py index 8de7e7a..dbe921c 100644 --- a/apollo.py +++ b/apollo.py @@ -19,44 +19,44 @@ # The command extensions to be loaded by the bot EXTENSIONS = [ - # "cogs.commands.announce", - # "cogs.commands.birthday", - # "cogs.commands.chess", - # "cogs.commands.counting", - # "cogs.commands.chatgpt", - # "cogs.commands.dalle", - # "cogs.commands.date", - # "cogs.commands.eightball", - # "cogs.commands.event_sync", - # "cogs.commands.flip", - # "cogs.commands.karma_admin", - # "cogs.commands.karma_blacklist", - # "cogs.commands.karma", - # "cogs.commands.lcalc", - # "cogs.commands.misc", - # "cogs.commands.onmessage", - # "cogs.commands.openaiadmin", - # "cogs.commands.quotes", - # "cogs.commands.rolemenu", - # "cogs.commands.reminders", - # "cogs.commands.roll", - # "cogs.commands.run", - # "cogs.commands.roomsearch", - # "cogs.commands.say", - # "cogs.commands.summarise", - # "cogs.commands.system", - # "cogs.commands.tex", - # "cogs.commands.vote", - # "cogs.commands.widen", - # "cogs.commands.xkcd", - # "cogs.commands.market", - # "cogs.commands.auction", - "cogs.bot_moderation" - # "cogs.channel_checker", - # "cogs.database", - # "cogs.irc", - # "cogs.parallelism", - # "cogs.welcome", + "cogs.commands.announce", + "cogs.commands.birthday", + "cogs.commands.chess", + "cogs.commands.counting", + "cogs.commands.chatgpt", + "cogs.commands.dalle", + "cogs.commands.date", + "cogs.commands.eightball", + "cogs.commands.event_sync", + "cogs.commands.flip", + "cogs.commands.karma_admin", + "cogs.commands.karma_blacklist", + "cogs.commands.karma", + "cogs.commands.lcalc", + "cogs.commands.misc", + "cogs.commands.onmessage", + "cogs.commands.openaiadmin", + "cogs.commands.quotes", + "cogs.commands.rolemenu", + "cogs.commands.reminders", + "cogs.commands.roll", + "cogs.commands.run", + "cogs.commands.roomsearch", + "cogs.commands.say", + "cogs.commands.summarise", + "cogs.commands.system", + "cogs.commands.tex", + "cogs.commands.vote", + "cogs.commands.widen", + "cogs.commands.xkcd", + "cogs.commands.market", + "cogs.commands.auction", + "cogs.bot_moderation", + "cogs.channel_checker", + "cogs.database", + "cogs.irc", + "cogs.parallelism", + "cogs.welcome" ] From ac0402c2efe9d8e500cbff2a9b8c316a67dd44f8 Mon Sep 17 00:00:00 2001 From: lunazeta <70282650+lunazeta@users.noreply.github.com> Date: Thu, 19 Mar 2026 15:57:55 +0000 Subject: [PATCH 6/6] Remove unnecessary config --- config/config.py | 1 - 1 file changed, 1 deletion(-) diff --git a/config/config.py b/config/config.py index 9ecd239..5695958 100644 --- a/config/config.py +++ b/config/config.py @@ -15,7 +15,6 @@ def __init__(self, filepath: str): self.DISCORD_TOKEN: str = parsed.get("discord_token") self.BOT_SECRET_KEY: str = parsed.get("db_secret_key") self.DATABASE_CONNECTION: str = parsed.get("database_connection") - self.TIMEZONE: str = parsed.get("timezone") # Optional self.UWCS_WELCOME_CHANNEL_ID: int = parsed.get("UWCS_welcome_channel_id")