Fix: Cache regular Miku avatar URL to prevent pfp bleed in bipolar arguments

When Evil Mode activates, the bot's Discord account avatar is changed to evil_pfp.png.
Previously, get_persona_avatar_urls() would read this swapped avatar and pass it to
the Miku webhook, causing both webhooks to display Evil Miku's pfp.

Now caching the regular Miku CDN URL before Evil Mode changes the bot's avatar.
When Evil Mode is active, the cached URL is used instead of reading from the bot
account. Discord CDN URLs remain valid after avatar changes, so this reliably
preserves the correct pfp for both regular and Evil Miku webhooks during arguments.

- Added MIKU_NORMAL_AVATAR_URL global in bot/globals.py
- Updated get_persona_avatar_urls() to cache and return the cached URL
- Save the normal avatar URL before Evil Mode switches the bot's avatar
This commit is contained in:
2026-03-30 14:30:34 +03:00
parent e6529f1bc3
commit 08fb465c67
3 changed files with 21 additions and 11 deletions

View File

@@ -75,6 +75,7 @@ EVIL_AVAILABLE_MOODS = ["aggressive", "cunning", "sarcastic", "evil_neutral", "b
BIPOLAR_MODE = False
BIPOLAR_WEBHOOKS = {} # guild_id -> {"miku_webhook_url": str, "evil_webhook_url": str}
BIPOLAR_ARGUMENT_IN_PROGRESS = {} # channel_id -> {"active": bool, "exchange_count": int, "current_speaker": str}
MIKU_NORMAL_AVATAR_URL = None # Cached CDN URL of the regular Miku pfp (valid even after evil mode swaps the bot avatar)
# MOOD_EMOJIS removed — canonical source is utils/moods.py
# bipolar_mode.py now imports from there directly