1- from typing import Optional , Union
1+ from typing import Optional , Union , Any
22from ..main .monomer import BaseMonoBehavior , Monomer
33from ..main .protocol import AbstractProtocol
44from .medium import Message , Request , DictMedium
@@ -11,7 +11,7 @@ def activate(self):
1111 self .protocol = self .io .metadata .protocol
1212
1313 async def revoke (self , medium : Message , target_message_id : int = None ):
14- await self .protocol .push_medium (
14+ await self .protocol .screen . push_medium (
1515 DictMedium ().create (
1616 self .io ,
1717 {
@@ -20,10 +20,10 @@ async def revoke(self, medium: Message, target_message_id: int = None):
2020 "MessageRevoke"
2121 )
2222 )
23- await self .protocol .data_parser_dispatch ( "post" )
23+ await self .protocol .execution_handle ( )
2424
25- async def nudge (self , target : Union [str , Monomer ], ** rest ):
26- await self .protocol .push_medium (
25+ async def nudge (self , target : Union [str , Monomer , None ], ** rest ):
26+ await self .protocol .screen . push_medium (
2727 DictMedium ().create (
2828 self .io ,
2929 {
@@ -33,7 +33,7 @@ async def nudge(self, target: Union[str, Monomer], **rest):
3333 "NudgeSend"
3434 )
3535 )
36- await self .protocol .data_parser_dispatch ( "post" )
36+ await self .protocol .execution_handle ( )
3737
3838 async def send_with (
3939 self ,
@@ -47,7 +47,7 @@ async def send_with(
4747 if nudge :
4848 await self .nudge (target .metadata .pure_id , ** rest )
4949
50- resp = await self .protocol .push_medium (
50+ resp = await self .protocol .screen . push_medium (
5151 DictMedium ().create (
5252 self .io ,
5353 {
@@ -59,17 +59,17 @@ async def send_with(
5959 "MessageSend"
6060 )
6161 )
62- await self .protocol .data_parser_dispatch ( "post" )
62+ await self .protocol .execution_handle ( )
6363 resp_data : DictMedium = await resp .wait_response ()
64- self .protocol .scene .edoves .logger .info (
65- f"{ self .protocol .scene .protagonist .metadata .pure_id } : "
64+ self .protocol .screen .edoves .logger .info (
65+ f"{ self .protocol .current_scene .protagonist .metadata .pure_id } : "
6666 f"{ resp_data .type } ({ resp_data .content ['id' ]} )"
6767 f" <- { medium .content .to_text ()} "
6868 )
6969 return resp_data .content .get ('messageId' )
7070
7171 async def request_accept (self , medium : Request , msg : str = None ):
72- await self .protocol .push_medium (
72+ await self .protocol .screen . push_medium (
7373 DictMedium ().create (
7474 self .io ,
7575 {
@@ -82,10 +82,10 @@ async def request_accept(self, medium: Request, msg: str = None):
8282 "Accept"
8383 )
8484 )
85- await self .protocol .data_parser_dispatch ( "post" )
85+ await self .protocol .execution_handle ( )
8686
8787 async def request_reject (self , medium : Request , msg : str = None ):
88- await self .protocol .push_medium (
88+ await self .protocol .screen . push_medium (
8989 DictMedium ().create (
9090 self .io ,
9191 {
@@ -98,11 +98,11 @@ async def request_reject(self, medium: Request, msg: str = None):
9898 "Reject"
9999 )
100100 )
101- await self .protocol .data_parser_dispatch ( "post" )
101+ await self .protocol .execution_handle ( )
102102
103103 async def relationship_remove (self , target : Union [str , Monomer ], relationship : str = None ):
104104 target = await self .relationship_get (target , relationship ) if isinstance (target , str ) else target
105- await self .protocol .push_medium (
105+ await self .protocol .screen . push_medium (
106106 DictMedium ().create (
107107 self .io ,
108108 {
@@ -112,10 +112,10 @@ async def relationship_remove(self, target: Union[str, Monomer], relationship:
112112 "RelationshipRemove"
113113 )
114114 )
115- await self .protocol .data_parser_dispatch ( "post" )
115+ await self .protocol .execution_handle ( )
116116
117117 async def relationship_get (self , target : str , relationship : str , ** rest ):
118- resp = await self .protocol .push_medium (
118+ resp = await self .protocol .screen . push_medium (
119119 DictMedium ().create (
120120 self .io ,
121121 {
@@ -126,11 +126,11 @@ async def relationship_get(self, target: str, relationship: str, **rest):
126126 "RelationshipGet"
127127 )
128128 )
129- await self .protocol .data_parser_dispatch ( "post" )
129+ await self .protocol .execution_handle ( )
130130 return await resp .wait_response ()
131131
132132 async def change_monomer_status (self , target : Monomer , status : str , ** rest ):
133- await self .protocol .push_medium (
133+ await self .protocol .screen . push_medium (
134134 DictMedium ().create (
135135 self .io ,
136136 {
@@ -141,18 +141,24 @@ async def change_monomer_status(self, target: Monomer, status: str, **rest):
141141 "ChangeMonomerStatus"
142142 )
143143 )
144- await self .protocol .data_parser_dispatch ( "post" )
144+ await self .protocol .execution_handle ( )
145145
146- async def change_monomer_metadata (self , target : Monomer , meta : str , ** rest ):
147- await self .protocol .push_medium (
146+ async def change_metadata (
147+ self ,
148+ meta : str ,
149+ value : Any ,
150+ target : Optional ["Monomer" ] = None ,
151+ ** addition
152+ ):
153+ await self .protocol .screen .push_medium (
148154 DictMedium ().create (
149155 self .io ,
150156 {
151- "target" : target ,
157+ "target" : target or self . io ,
152158 "meta" : meta ,
153- "rest" : rest ,
159+ "rest" : addition ,
154160 },
155161 "ChangeMonomerMetadata"
156162 )
157163 )
158- await self .protocol .data_parser_dispatch ( "post" )
164+ await self .protocol .execution_handle ( )
0 commit comments