File tree Expand file tree Collapse file tree 2 files changed +58
-0
lines changed
Expand file tree Collapse file tree 2 files changed +58
-0
lines changed Original file line number Diff line number Diff line change 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 })
Original file line number Diff line number Diff line change 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 })
You can’t perform that action at this time.
0 commit comments