"""Thread-safe in-memory store for the last Claude response per channel. Router.py updates this after every Claude response; fast_commands.cmd_audio reads from it when /audio is called without arguments. """ import threading _lock = threading.Lock() _store: dict[str, str] = {} # channel_id → last response text def set_last(channel_id: str, text: str) -> None: """Store the most recent Claude response for a channel.""" if not channel_id or not text: return with _lock: _store[channel_id] = text def get_last(channel_id: str) -> str | None: """Return the last stored response for a channel, or None if missing.""" if not channel_id: return None with _lock: return _store.get(channel_id)