81 lines
2.6 KiB
Python
81 lines
2.6 KiB
Python
|
|
# pfp_context.py
|
||
|
|
"""
|
||
|
|
Helper module for detecting when users ask about the profile picture
|
||
|
|
and injecting the description into context.
|
||
|
|
"""
|
||
|
|
|
||
|
|
import re
|
||
|
|
from typing import Optional
|
||
|
|
|
||
|
|
# Regex patterns to detect profile picture questions
|
||
|
|
PFP_PATTERNS = [
|
||
|
|
# Direct profile picture references
|
||
|
|
r'\b(?:your\s+)?(?:profile\s+)?(?:pic|picture|photo|image|avatar|pfp)\b',
|
||
|
|
|
||
|
|
# "What are you wearing" type questions
|
||
|
|
r'\bwhat\s+(?:are\s+)?you\s+wearing\b',
|
||
|
|
r'\bwhat\s+(?:is|are)\s+you\s+(?:dressed|wearing)\b',
|
||
|
|
r'\btell\s+me\s+about\s+(?:your\s+)?(?:outfit|clothes|dress|appearance)\b',
|
||
|
|
|
||
|
|
# "How do you look" type questions
|
||
|
|
r'\bhow\s+(?:do\s+)?you\s+look\b',
|
||
|
|
r'\bwhat\s+(?:do\s+)?you\s+look\s+like\b',
|
||
|
|
r'\bdescribe\s+(?:your\s+)?(?:appearance|look|outfit)\b',
|
||
|
|
|
||
|
|
# "Nice pfp/picture" type comments
|
||
|
|
r'\b(?:nice|cool|cute|beautiful|pretty|lovely|amazing|great)\s+(?:pfp|picture|pic|avatar|photo)\b',
|
||
|
|
r'\b(?:i\s+)?(?:like|love)\s+(?:your\s+)?(?:pfp|picture|pic|avatar|photo)\b',
|
||
|
|
|
||
|
|
# Direct appearance questions
|
||
|
|
r'\bwhat\s+(?:are\s+)?you\s+(?:dressed\s+)?(?:as|in)\b',
|
||
|
|
r'\b(?:show|showing)\s+me\s+(?:your\s+)?(?:outfit|appearance)\b',
|
||
|
|
|
||
|
|
# Icon/display picture references
|
||
|
|
r'\b(?:your\s+)?(?:display\s+)?(?:icon|display\s+picture)\b',
|
||
|
|
|
||
|
|
# "In your picture" references
|
||
|
|
r'\bin\s+(?:your\s+)?(?:picture|photo|pic|pfp|avatar)\b',
|
||
|
|
r'\bon\s+(?:your\s+)?(?:picture|photo|pic|pfp|avatar)\b',
|
||
|
|
]
|
||
|
|
|
||
|
|
# Compile patterns for efficiency
|
||
|
|
COMPILED_PATTERNS = [re.compile(pattern, re.IGNORECASE) for pattern in PFP_PATTERNS]
|
||
|
|
|
||
|
|
|
||
|
|
def is_asking_about_pfp(message: str) -> bool:
|
||
|
|
"""
|
||
|
|
Check if the user's message is asking about or referencing the profile picture.
|
||
|
|
|
||
|
|
Args:
|
||
|
|
message: User's message text
|
||
|
|
|
||
|
|
Returns:
|
||
|
|
True if message appears to be about the pfp
|
||
|
|
"""
|
||
|
|
if not message:
|
||
|
|
return False
|
||
|
|
|
||
|
|
# Check against all patterns
|
||
|
|
for pattern in COMPILED_PATTERNS:
|
||
|
|
if pattern.search(message):
|
||
|
|
return True
|
||
|
|
|
||
|
|
return False
|
||
|
|
|
||
|
|
|
||
|
|
def get_pfp_context_addition() -> Optional[str]:
|
||
|
|
"""
|
||
|
|
Get the profile picture description formatted for context injection.
|
||
|
|
|
||
|
|
Returns:
|
||
|
|
Formatted context string or None
|
||
|
|
"""
|
||
|
|
from utils.profile_picture_manager import profile_picture_manager
|
||
|
|
|
||
|
|
description = profile_picture_manager.get_current_description()
|
||
|
|
|
||
|
|
if description:
|
||
|
|
return f"\n\n📸 YOUR CURRENT PROFILE PICTURE:\n{description}\n(This is what you look like in your current Discord profile picture. When users ask about your appearance, picture, or outfit, refer to this description.)"
|
||
|
|
|
||
|
|
return None
|