Make radio secondary now-playing message self-only
This commit is contained in:
@@ -27,7 +27,7 @@ def secondary_use_item(item: WorldItem, _nickname: str, _clock_formatter: Callab
|
||||
if item.params.get("enabled") is False:
|
||||
return ItemUseResult(
|
||||
self_message=f"{item.title} is off.",
|
||||
others_message=f"{item.title} is off.",
|
||||
others_message="",
|
||||
)
|
||||
|
||||
station_name = str(item.params.get("stationName", "")).strip()
|
||||
@@ -40,4 +40,4 @@ def secondary_use_item(item: WorldItem, _nickname: str, _clock_formatter: Callab
|
||||
message = f"Playing from {station_name}."
|
||||
else:
|
||||
message = "No now playing data."
|
||||
return ItemUseResult(self_message=message, others_message=message)
|
||||
return ItemUseResult(self_message=message, others_message="")
|
||||
|
||||
@@ -1708,10 +1708,11 @@ class SignalingServer:
|
||||
item.version += 1
|
||||
self._request_state_save()
|
||||
await self._broadcast_item(item)
|
||||
await self._broadcast(
|
||||
BroadcastChatMessagePacket(type="chat_message", message=secondary_result.others_message, system=True),
|
||||
exclude=client.websocket,
|
||||
)
|
||||
if secondary_result.others_message.strip():
|
||||
await self._broadcast(
|
||||
BroadcastChatMessagePacket(type="chat_message", message=secondary_result.others_message, system=True),
|
||||
exclude=client.websocket,
|
||||
)
|
||||
await self._send_item_result(client, True, "secondary_use", secondary_result.self_message, item.id)
|
||||
return
|
||||
|
||||
|
||||
@@ -118,12 +118,13 @@ async def test_item_secondary_use_radio_reports_now_playing(monkeypatch: pytest.
|
||||
server.item_service.add_item(radio)
|
||||
|
||||
send_payloads: list[object] = []
|
||||
broadcast_payloads: list[object] = []
|
||||
|
||||
async def fake_send(websocket: ServerConnection, packet: object) -> None:
|
||||
send_payloads.append(packet)
|
||||
|
||||
async def fake_broadcast(packet: object, exclude: ServerConnection | None = None) -> None:
|
||||
return None
|
||||
broadcast_payloads.append(packet)
|
||||
|
||||
monkeypatch.setattr(server, "_send", fake_send)
|
||||
monkeypatch.setattr(server, "_broadcast", fake_broadcast)
|
||||
@@ -135,6 +136,7 @@ async def test_item_secondary_use_radio_reports_now_playing(monkeypatch: pytest.
|
||||
assert results[-1].ok is True
|
||||
assert results[-1].action == "secondary_use"
|
||||
assert "Playing Song Y from Station X." in results[-1].message
|
||||
assert broadcast_payloads == []
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
|
||||
Reference in New Issue
Block a user