Discord: several radio streams per voice channel; adding never overwrites (#213)
Owner-reported on live: adding a radio channel for a server + voice channel that already had one (different label, system, even bot) overwrote the existing stream and made its bot leave, because stream_id was guild:channel. - New streams get guild:channel:<12 hex> ids (leases.new_stream_id); old guild:channel docs keep working for read/stop/remove/node reports. Route validators accept both (leases.STREAM_ID_PATTERN). - start_stream: no stream_id = ADD. Same system already on in that channel is idempotent (already_on, label/mode untouched); a stopped one of that system is restarted; anything else is a new doc. stream_id = explicit restart/edit (admin Start button, reconciler), incl. moving to another bot. - preferred_token_id is strict: bot already in this server -> 409 preferred_busy naming the stream; on another node -> preferred_other_node; unusable -> preferred_unavailable. No silent swap. pool_exhausted now says one-bot-per-server and to add + invite another bot. - One-token-per-guild was already enforced inside the lease transaction; now covered by race tests. Per-guild asyncio lock serialises the already-on / server-cap check with the create (guild half of #223). - Stop by stream_id (POST /discord/guilds/{id}/stop {stream_id}); admin UI Stop/Start/Remove act on the row's stream; node picker lists every stream in a channel and adds beside other systems. - Bot: /leave stream: (autocomplete) stops one; /leave channel: with several streams asks which unless all:True; bare /leave still stops the server. /status and /join name each stream's bot. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
16a609e35b
commit
8af410aede
@@ -67,12 +67,14 @@ class C2Client:
|
||||
return None
|
||||
|
||||
async def stop_guild(self, guild_id: int | str, channel_id: Optional[str] = None,
|
||||
reason: str = "leave") -> Optional[list]:
|
||||
reason: str = "leave", stream_id: Optional[str] = None) -> Optional[list]:
|
||||
"""Stop radio in one server: everything, one voice channel (every
|
||||
stream in it), or one stream by id. C2 never reaches past the guild."""
|
||||
try:
|
||||
async with httpx.AsyncClient(timeout=30) as client:
|
||||
r = await client.post(
|
||||
f"{self.base}/discord/guilds/{guild_id}/stop",
|
||||
json={"channel_id": channel_id, "reason": reason},
|
||||
json={"channel_id": channel_id, "stream_id": stream_id, "reason": reason},
|
||||
headers=self._headers(),
|
||||
)
|
||||
r.raise_for_status()
|
||||
|
||||
Reference in New Issue
Block a user