Expand nickname generation for better name variations

Enhanced _generate_nicknames() to support more name variations:

Before (for 8-char name "Kenearos"):
- Generated: Kene (4 chars only)

After:
- Generates at 4, 6, 8, 10, 12 character positions
- For "kenearosmd": Kene, Kenear, Kenearos, kenearosmd
- Special handling: removes 'md' suffix if present
  (kenearosmd → also adds kenearos)

This allows users with longer usernames to be recognized:
- Bot name "kenearosmd" generates: kene, kenear, kenearos
- Bot responds to all variations and the full name

Fixes issue where users couldn't use their full username
if it was longer than the configured bot name.
This commit is contained in:
Claude 2026-01-02 22:18:41 +00:00
parent 11b928c242
commit 82a1687bde
No known key found for this signature in database

View file

@ -49,11 +49,16 @@ class MentionDetector:
"""Generate common nicknames from bot name""" """Generate common nicknames from bot name"""
nicknames = [] nicknames = []
# For kenearosmd, generate: Kene, Kenearos # Generate nicknames at 4, 6, 8, 10 character positions
if len(bot_name) >= 4: # For kenearosmd: Kene, Kenear, Kenearos, kenearosmd
nicknames.append(bot_name[:4]) # First 4 chars (Kene) for length in [4, 6, 8, 10, 12]:
if len(bot_name) >= 8: if len(bot_name) >= length:
nicknames.append(bot_name[:8]) # First 8 chars (Kenearos) nicknames.append(bot_name[:length])
# Also add common variations
# If name ends with 'md', add version without it
if bot_name.lower().endswith('md') and len(bot_name) > 2:
nicknames.append(bot_name[:-2]) # kenearos from kenearosmd
# Remove duplicates and the full name # Remove duplicates and the full name
nicknames = [n for n in set(nicknames) if n != bot_name] nicknames = [n for n in set(nicknames) if n != bot_name]