88from pybot .endpoints .slack .utils .action_messages import now
99from pybot .plugins .airtable .api import AirtableAPI
1010
11+ from .block_action import BlockAction
12+
1113
1214class BlockIndex (IntEnum ):
1315 SERVICE = 2
@@ -19,61 +21,10 @@ class BlockIndex(IntEnum):
1921 SUBMIT = 9
2022
2123
22- class MentorRequest (Action ):
24+ class MentorRequest (BlockAction ):
2325 def __init__ (self , raw_action : MutableMapping ):
2426 super ().__init__ (raw_action )
2527
26- if "original_message" not in self :
27- self ["original_message" ] = {}
28-
29- @property
30- def channel (self ):
31- return self ["channel" ]["id" ]
32-
33- @property
34- def original_message (self ):
35- return self ["message" ]
36-
37- @property
38- def blocks (self ):
39- return self .original_message ["blocks" ]
40-
41- @blocks .setter
42- def blocks (self , value ):
43- self .original_message ["blocks" ] = value
44-
45- @property
46- def attachments (self ):
47- return self .original_message .get ("attachments" , [])
48-
49- @attachments .setter
50- def attachments (self , value ):
51- self .original_message ["attachments" ] = value
52-
53- @property
54- def ts (self ):
55- return self .original_message ["ts" ]
56-
57- @property
58- def actions (self ):
59- return self ["actions" ]
60-
61- @property
62- def selected_option (self ):
63- if "selected_option" in self .actions [0 ]:
64- return self .actions [0 ]["selected_option" ]
65- return None
66-
67- def initial_option (self , index : BlockIndex ) -> str :
68- """
69- Each section uses the `initial_option` key to store the latest
70- option selected by the user
71- """
72- accessory = self .blocks [index ]["accessory" ]
73- if "initial_option" in accessory :
74- return accessory ["initial_option" ]["value" ]
75- return ""
76-
7728 @property
7829 def service (self ):
7930 return self .initial_option (BlockIndex .SERVICE )
@@ -141,15 +92,6 @@ def affiliation(self, new_affiliation: str) -> None:
14192 if self .validate_self ():
14293 self .clear_errors ()
14394
144- @property
145- def update_params (self ) -> dict :
146- return {
147- "channel" : self .channel ,
148- "ts" : self .ts ,
149- "blocks" : self .blocks ,
150- "attachments" : self .attachments ,
151- }
152-
15395 def validate_self (self ) -> bool :
15496 if not self .service or not self .affiliation :
15597 return False
@@ -201,7 +143,7 @@ def submission_complete(self, slack: SlackAPI) -> Coroutine[Any, Any, dict]:
201143 "accessory" : {
202144 "type" : "button" ,
203145 "action_id" : "cancel_btn" ,
204- "text" : {"type" : "plain_text" , "text" : "Dimiss " , "emoji" : True },
146+ "text" : {"type" : "plain_text" , "text" : "Dismiss " , "emoji" : True },
205147 "value" : "dismiss" ,
206148 },
207149 }
@@ -217,9 +159,6 @@ def clear_skillsets(self) -> None:
217159 def clear_errors (self ) -> None :
218160 self .attachments = []
219161
220- def update_message (self , slack : SlackAPI ) -> Coroutine [Any , Any , dict ]:
221- return slack .query (methods .CHAT_UPDATE , self .update_params )
222-
223162
224163class MentorRequestClaim (Action ):
225164 def __init__ (
0 commit comments