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
1 change: 1 addition & 0 deletions apollo.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
"cogs.commands.xkcd",
"cogs.commands.market",
"cogs.commands.auction",
"cogs.bot_moderation",
"cogs.channel_checker",
"cogs.database",
"cogs.irc",
Expand Down
37 changes: 37 additions & 0 deletions cogs/bot_moderation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
from datetime import datetime, timedelta

import discord
from discord import Color, Embed
from discord.ext.commands import Bot, Cog

from config import CONFIG


class Database(Cog):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is the cog called database?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fuck, that's actually my bad

def __init__(self, bot: Bot):
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
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the text in the message for an @ everyone actually come out as @ everyone? I know pings of roles/people are <@12356789>?

Copy link
Copy Markdown
Contributor Author

@lunazeta lunazeta Mar 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes it does, as if they don't have the permission it just formats to @ everyone, in terms of actual @ everyone pings, it does the same

is_giving_away = 'giving away' in message.content.lower()

if not joined_recently or not (contains_everyone or is_giving_away):
return

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 = Embed(
title=embed_title, color=embed_colour, embed_description=embed_description
)

await message.delete()
await channel.send(f'<@&{CONFIG.UWCS_EXEC_ROLE_IDS[1]}>', embed=embed)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why take the 2nd role? That feels unintuitive at best - create a separate config param if you want it to be a specific role (that isn't just exec)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i don't know? ask whoever put the exec role as the second role in the list...

await message.author.timeout(timedelta(days=1))

async def setup(bot: Bot):
await bot.add_cog(Database(bot))
2 changes: 2 additions & 0 deletions config.example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ config:
UWCS_roles_channel_id: 123
# Channel for the channel movement checker
UWCS_exec_spam_channel_id: 1234
# Channel for message logs
UWCS_bot_log_channel_id: 1234
# IRC bridge bot ID
UWCS_discord_bridge_bot_id: 1337
# API Key for chatgpt integration
Expand Down
1 change: 1 addition & 0 deletions config/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ def __init__(self, filepath: str):
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_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")
Expand Down
Loading