diff --git a/apollo.py b/apollo.py index c0ee7a6..dbe921c 100644 --- a/apollo.py +++ b/apollo.py @@ -56,7 +56,7 @@ "cogs.database", "cogs.irc", "cogs.parallelism", - "cogs.welcome", + "cogs.welcome" ] diff --git a/cogs/bot_moderation.py b/cogs/bot_moderation.py index 6cc3351..af4c2f8 100644 --- a/cogs/bot_moderation.py +++ b/cogs/bot_moderation.py @@ -3,19 +3,21 @@ import discord 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 Database(Cog): +class BotModeration(Cog): 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 - 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 +25,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'<@&{CONFIG.UWCS_EXEC_ROLE_IDS[1]}>', 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): - 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.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 430beec..5695958 100644 --- a/config/config.py +++ b/config/config.py @@ -20,8 +20,9 @@ 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_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")