Skip to content

Commit 52f4336

Browse files
committed
Add missing actions
1 parent 3f3e4ca commit 52f4336

File tree

2 files changed

+58
-0
lines changed

2 files changed

+58
-0
lines changed

src/actions/client/volume_down.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import asyncio
2+
from typing import TYPE_CHECKING, Any
3+
4+
from src.actions.base import ClientActionHandler, register_client_action
5+
from src.schema.frames import ClientFrame
6+
7+
if TYPE_CHECKING:
8+
from src.engine.connection_context import ConnectionContext
9+
10+
11+
@register_client_action("VOLUME_DOWN")
12+
class VolumeDownActionHandler(ClientActionHandler):
13+
"""Handle VOLUME_DOWN client action, which means 'NO'."""
14+
15+
action_type = "VOLUME_DOWN"
16+
context_template = "Client pressed volume DOWN to answer NO."
17+
18+
def to_context_str(self, payload: dict[str, Any]) -> str:
19+
intent = payload.get("intent", "deny")
20+
return f"[EVENT:VOLUME_DOWN] Client answered SILENTLY using hardware button. Intent: {intent.upper()} (NO)."
21+
22+
async def execute(
23+
self,
24+
frame: ClientFrame,
25+
_ctx: "ConnectionContext",
26+
content_queue: asyncio.Queue[dict[str, Any]],
27+
) -> None:
28+
context_str = self.to_context_str(frame.payload)
29+
await content_queue.put({"type": "text", "text": context_str})

src/actions/client/volume_up.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import asyncio
2+
from typing import TYPE_CHECKING, Any
3+
4+
from src.actions.base import ClientActionHandler, register_client_action
5+
from src.schema.frames import ClientFrame
6+
7+
if TYPE_CHECKING:
8+
from src.engine.connection_context import ConnectionContext
9+
10+
11+
@register_client_action("VOLUME_UP")
12+
class VolumeUpActionHandler(ClientActionHandler):
13+
"""Handle VOLUME_UP client action, which means 'YES'."""
14+
15+
action_type = "VOLUME_UP"
16+
context_template = "Client pressed volume UP to answer YES."
17+
18+
def to_context_str(self, payload: dict[str, Any]) -> str:
19+
intent = payload.get("intent", "confirm")
20+
return f"[EVENT:VOLUME_UP] Client answered SILENTLY using hardware button. Intent: {intent.upper()} (YES)."
21+
22+
async def execute(
23+
self,
24+
frame: ClientFrame,
25+
_ctx: "ConnectionContext",
26+
content_queue: asyncio.Queue[dict[str, Any]],
27+
) -> None:
28+
context_str = self.to_context_str(frame.payload)
29+
await content_queue.put({"type": "text", "text": context_str})

0 commit comments

Comments
 (0)