dev #11
@@ -86,6 +86,11 @@ class AIModeration(commands.Cog):
|
|||||||
if not message.guild:
|
if not message.guild:
|
||||||
return
|
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
|
# Get config from YAML
|
||||||
config = self.bot.config_loader
|
config = self.bot.config_loader
|
||||||
if not config.get_setting("ai_moderation.enabled", True):
|
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)
|
# Check if should analyze (has images/embeds, not analyzed yet)
|
||||||
if not self._should_analyze(message):
|
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
|
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)
|
# Check rate limits (CRITICAL for cost control)
|
||||||
max_guild_per_hour = config.get_setting("ai_moderation.max_checks_per_hour_per_guild", 25)
|
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)
|
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"]:
|
if rate_limit_result["is_limited"]:
|
||||||
logger.warning(
|
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"(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})"
|
f"user: {rate_limit_result['user_checks_this_hour']}/{max_user_per_hour})"
|
||||||
)
|
)
|
||||||
return
|
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
|
# Get AI settings
|
||||||
sensitivity = config.get_setting("ai_moderation.sensitivity", 80)
|
sensitivity = config.get_setting("ai_moderation.sensitivity", 80)
|
||||||
nsfw_only_filtering = config.get_setting("ai_moderation.nsfw_only_filtering", True)
|
nsfw_only_filtering = config.get_setting("ai_moderation.nsfw_only_filtering", True)
|
||||||
|
|||||||
Reference in New Issue
Block a user