dev #11

Merged
Latte merged 12 commits from dev into main 2026-02-10 19:02:08 +00:00
3 changed files with 51 additions and 7 deletions
Showing only changes of commit cb6049361e - Show all commits

View File

@@ -138,6 +138,10 @@ ai_moderation:
check_video_thumbnails: false # Skip video thumbnails
url_image_check_enabled: false # Skip URL image downloads
# User blocklist (blocks ALL media from specific users)
blocked_user_ids:
- 123456789012345678 # Discord user ID to block
# Known NSFW video domains (auto-block)
nsfw_video_domains:
- pornhub.com
@@ -160,6 +164,12 @@ nsfw_video_domains:
- `duplicate_threshold`: How many duplicate messages trigger action
- `mention_limit`: Max @mentions allowed per message
**User Blocklist:**
- `blocked_user_ids`: List of Discord user IDs to block
- Automatically deletes ALL images, GIFs, embeds, and URLs from these users
- No AI cost - instant deletion
- Useful for known problematic users or spam accounts
**Cost Controls:**
The bot includes multiple layers of cost control:
- Rate limiting (25 AI checks/hour/guild, 5/hour/user by default)
@@ -222,6 +232,12 @@ guardden/
## How It Works
### User Blocklist (Instant, No AI Cost)
1. Checks if message author is in `blocked_user_ids` list
2. If message contains ANY media (images, embeds, URLs), instantly deletes it
3. No AI analysis needed - immediate action
4. Useful for known spam accounts or problematic users
### Spam Detection
1. Bot monitors message rate per user
2. Detects duplicate messages
@@ -229,12 +245,13 @@ guardden/
4. Violations result in message deletion + timeout
### NSFW Image Detection
1. Bot checks attachments and embeds for images
2. Applies rate limiting and deduplication
3. Downloads image and sends to AI provider
4. AI analyzes for NSFW content categories
5. Violations result in message deletion + timeout
6. Optionally checks known NSFW video domain links
1. Checks user blocklist first (instant deletion if matched)
2. Checks NSFW video domain blocklist (instant deletion)
3. Bot checks attachments and embeds for images
4. Applies rate limiting and deduplication
5. Downloads image and sends to AI provider
6. AI analyzes for NSFW content categories
7. Violations result in message deletion + timeout
### Cost Management
The bot includes aggressive cost controls for AI usage:

View File

@@ -36,6 +36,12 @@ ai_moderation:
check_video_thumbnails: false # Skip video thumbnails (disabled per user request)
url_image_check_enabled: false # Skip URL image downloads (disabled per user request)
# User Blocklist (No AI cost)
# Block all images, GIFs, embeds, and URLs from these users
# Add Discord user IDs here
blocked_user_ids:
# Example: - 123456789012345678
# NSFW Video Domain Blocklist (No AI cost)
# These domains are blocked instantly without AI analysis
nsfw_video_domains:

View File

@@ -92,7 +92,28 @@ class AIModeration(commands.Cog):
if not config.get_setting("ai_moderation.enabled", True):
return
# Check NSFW video domain blocklist first (no AI cost)
# Check user blocklist first (blocks ALL media from specific users)
blocked_users = config.get_setting("blocked_user_ids", [])
if message.author.id in blocked_users:
# Check if message has any media content (images, embeds, URLs)
has_media = (
bool(message.attachments) or
bool(message.embeds) or
bool(URL_PATTERN.search(message.content))
)
if has_media:
try:
await message.delete()
logger.info(
f"Deleted media content from blocked user {message.author} "
f"({message.author.id}) in {message.guild.name}"
)
except (discord.Forbidden, discord.NotFound):
logger.warning(f"Failed to delete message from blocked user {message.author.id}")
return
# Check NSFW video domain blocklist (no AI cost)
if self._has_nsfw_video_link(message.content):
try:
await message.delete()