feat: Add user blocklist for instant media deletion

Add blocklist feature to automatically delete ALL media (images, GIFs,
embeds, URLs) from specific users without AI analysis.

Changes:
- Add blocked_user_ids config field to config.yml
- Implement blocklist check in ai_moderation.py (runs before AI checks)
- Update README.md with blocklist documentation

Benefits:
- No AI cost (instant deletion)
- Useful for known spam accounts or problematic users
- Blocks all media types: attachments, embeds, URLs
- Logged for moderation tracking
This commit is contained in:
2026-01-27 19:58:40 +01:00
parent df8da05f36
commit cb6049361e
3 changed files with 51 additions and 7 deletions

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()