dev #11

Merged
Latte merged 12 commits from dev into main 2026-02-10 19:02:08 +00:00
Showing only changes of commit 269ba15165 - Show all commits

View File

@@ -86,6 +86,11 @@ class AIModeration(commands.Cog):
if not message.guild:
return
# Check bot permissions in this channel
if not message.channel.permissions_for(message.guild.me).manage_messages:
logger.debug(f"Missing Manage Messages permission in #{message.channel.name}")
return
# Get config from YAML
config = self.bot.config_loader
if not config.get_setting("ai_moderation.enabled", True):
@@ -123,8 +128,19 @@ class AIModeration(commands.Cog):
# Check if should analyze (has images/embeds, not analyzed yet)
if not self._should_analyze(message):
logger.debug(
f"Skipping analysis in #{message.channel.name}: "
f"already_analyzed={message.id in self._analyzed_messages}, "
f"has_media={bool(message.attachments or message.embeds)}"
)
return
# Log that we're about to check this message
logger.info(
f"Checking message from {message.author} in #{message.channel.name} "
f"({len(message.attachments)} attachments, {len(message.embeds)} embeds)"
)
# Check rate limits (CRITICAL for cost control)
max_guild_per_hour = config.get_setting("ai_moderation.max_checks_per_hour_per_guild", 25)
max_user_per_hour = config.get_setting("ai_moderation.max_checks_per_user_per_hour", 5)
@@ -138,12 +154,20 @@ class AIModeration(commands.Cog):
if rate_limit_result["is_limited"]:
logger.warning(
f"AI rate limit hit: {rate_limit_result['reason']} "
f"AI rate limit hit in #{message.channel.name}: {rate_limit_result['reason']} "
f"(guild: {rate_limit_result['guild_checks_this_hour']}/{max_guild_per_hour}, "
f"user: {rate_limit_result['user_checks_this_hour']}/{max_user_per_hour})"
)
return
# Check if AI provider is configured
if self.bot.ai_provider is None:
logger.warning(
f"AI provider not configured but ai_moderation.enabled=true. "
f"Set GUARDDEN_AI_PROVIDER in .env to 'anthropic' or 'openai'"
)
return
# Get AI settings
sensitivity = config.get_setting("ai_moderation.sensitivity", 80)
nsfw_only_filtering = config.get_setting("ai_moderation.nsfw_only_filtering", True)