diff --git a/bot/utils/core.py b/bot/utils/core.py index 2c56777..8d5a9f5 100644 --- a/bot/utils/core.py +++ b/bot/utils/core.py @@ -40,15 +40,16 @@ async def is_miku_addressed(message) -> bool: except Exception as e: logger.warning(f"Could not fetch referenced message: {e}") - cleaned = message.content.strip().lower() + cleaned = message.content.strip() + cleaned_lower = cleaned.lower() # Base names for Miku in different scripts base_names = [ 'miku', 'мику', 'みく', 'ミク', '未来' ] - # Japanese honorifics - all scripts combined for simpler matching - honorifics_all_scripts = [ + # Japanese honorifics - all scripts combined + honorifics = [ # Latin 'chan', 'san', 'kun', 'nyan', 'hime', 'tan', 'chin', 'heika', 'denka', 'kakka', 'shi', 'chama', 'kyun', 'dono', 'sensei', 'senpai', 'jou', @@ -59,51 +60,74 @@ async def is_miku_addressed(message) -> bool: 'チャン', 'サン', 'クン', 'ニャン', 'ヒメ', 'タン', 'チン', 'ヘイカ', 'デンカ', 'カッカ', 'シ', 'チャマ', 'キュン', 'ドノ', 'センセイ', 'センパイ', 'ジョウ', # Cyrillic - 'чан', 'сан', 'кун', 'ньян', 'химе', 'тан', 'чин', 'хэйка', - 'дэнка', 'какка', 'си', 'чама', 'кюн', 'доно', 'сэнсэй', 'сэнпай', 'жо' + 'чан', 'сан', 'кун', 'нян', 'химе', 'тан', 'чин', 'хейка', 'хеика', + 'денка', 'какка', 'си', 'чама', 'кюн', 'доно', 'сенсэй', 'сенсеи', 'сенпай', 'сенпаи', 'джо' ] - # Optional o- prefix in different scripts + # o- prefix variants o_prefixes = ['o-', 'о-', 'お', 'オ'] - # Strategy: Just check if any base name appears (case insensitive for latin/cyrillic) - # Then allow any honorific to optionally follow + # Build all possible name variations to check + name_patterns = [] for base in base_names: base_lower = base.lower() + base_escaped = re.escape(base_lower) - # Check for just the base name - if re.search(r'(?