fix: let extra bots see peer music state for !similar/!tags
Some checks failed
CI / gitleaks (push) Failing after 3s
CI / lint (push) Failing after 23s
CI / test (3.11) (push) Has been skipped
CI / test (3.12) (push) Has been skipped
CI / test (3.13) (push) Has been skipped
CI / build (push) Has been skipped

_current_meta now checks registry._bots for peer bot music state
when the current bot has nothing playing. Fixes merlin reporting
"Nothing playing" while derp is actively streaming.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
user
2026-02-23 22:17:29 +01:00
parent ad12843e75
commit c851e82990
2 changed files with 41 additions and 8 deletions

View File

@@ -109,15 +109,23 @@ def _current_meta(bot) -> tuple[str, str]:
"""Extract artist and title from the currently playing track.
Returns (artist, title). Either or both may be empty.
Tries the music plugin's current track metadata, falling back to
splitting the title on common separators.
Tries the music plugin's current track metadata on this bot first,
then checks peer bots (shared registry) so extra bots can see what
the music bot is playing.
"""
music_ps = bot._pstate.get("music", {})
current = music_ps.get("current")
if current is None:
return ("", "")
raw_title = current.title or ""
return _parse_title(raw_title)
# Check this bot first, then peers
candidates = [bot]
for peer in getattr(getattr(bot, "registry", None), "_bots", {}).values():
if peer is not bot:
candidates.append(peer)
for b in candidates:
music_ps = getattr(b, "_pstate", {}).get("music", {})
current = music_ps.get("current")
if current is not None:
raw_title = current.title or ""
if raw_title:
return _parse_title(raw_title)
return ("", "")
# -- Discovery orchestrator --------------------------------------------------