@@ -433,16 +433,16 @@ def process_async_slack_event(event: Dict[str, Any], event_id: str, client: WebC
433433 process_slack_message (event = event , event_id = event_id , client = client )
434434
435435
436- def process_async_slack_command (command : Dict [str , Any ], client : WebClient ) -> None :
437- logger .debug ("Processing async Slack command" , extra = {"command " : command })
436+ def process_async_slack_command (body : Dict [str , Any ], client : WebClient ) -> None :
437+ logger .debug ("Processing async Slack command" , extra = {"body " : body })
438438
439439 try :
440- command_arg = command .get ("command" , "" ).strip ()
440+ command_arg = body .get ("command" , "" ).strip ()
441441 if command_arg == "/test" :
442- process_command_test_request (command = command , client = client )
442+ process_command_test_request (body = body , client = client )
443443 except Exception as e :
444444 logger .error (f"Error processing test command: { e } " , extra = {"error" : traceback .format_exc ()})
445- post_error_message (channel = command ["channel_id" ], thread_ts = None , client = client )
445+ post_error_message (channel = body ["channel_id" ], thread_ts = None , client = client )
446446
447447
448448# ================================================================
@@ -474,7 +474,7 @@ def process_pull_request_slack_command(slack_command_data: Dict[str, Any]) -> No
474474 command = slack_command_data ["event" ]
475475 token = get_bot_token ()
476476 client = WebClient (token = token )
477- process_async_slack_command (command = command , client = client )
477+ process_async_slack_command (body = command , client = client )
478478 except Exception :
479479 # we cant post a reply to slack for this error as we may not have details about where to post it
480480 logger .error (processing_error_message , extra = {"error" : traceback .format_exc ()})
@@ -804,22 +804,23 @@ def _toggle_button_style(element: dict) -> bool:
804804# ================================================================
805805
806806
807- def process_command_test_request (command : Dict [str , Any ], client : WebClient ) -> None :
808- if "help" in command .get ("text" ):
809- process_command_test_help (command = command , client = client )
807+ def process_command_test_request (body : Dict [str , Any ], client : WebClient ) -> None :
808+ logger .info ("Processing Command Test Request" , extra = {"body" : body })
809+ if "help" in body .get ("text" ):
810+ process_command_test_help (body = body , client = client )
810811 else :
811- process_command_test_questions (command = command , client = client )
812+ process_command_test_questions (body = body , client = client )
812813
813814
814- def process_command_test_questions (command : Dict [str , Any ], client : WebClient ) -> None :
815+ def process_command_test_questions (body : Dict [str , Any ], client : WebClient ) -> None :
815816 # Prepare response
816817
817818 try :
818- acknowledgement_msg = f"<@{ command .get (" user_id" )} > has initiated testing."
819- logger .info (acknowledgement_msg , extra = {"command " : command })
819+ acknowledgement_msg = f"<@{ body .get (' user_id' )} > has initiated testing."
820+ logger .info (acknowledgement_msg , extra = {"body " : body })
820821
821822 # Extract parameters
822- params = extract_test_command_params (command .get ("text" ))
823+ params = extract_test_command_params (body .get ("text" ))
823824
824825 # Is the command targeting a PR
825826 pr = params .get ("pr" , "" ).strip ()
@@ -829,7 +830,7 @@ def process_command_test_questions(command: Dict[str, Any], client: WebClient) -
829830
830831 # Initial acknowledgment
831832 post_params = {
832- "channel" : command ["channel_id" ],
833+ "channel" : body ["channel_id" ],
833834 "text" : acknowledgement_msg ,
834835 }
835836 client .chat_postMessage (** post_params )
@@ -846,10 +847,10 @@ def process_command_test_questions(command: Dict[str, Any], client: WebClient) -
846847
847848 # Post query information (for reflection in future)
848849 post_params = {
849- "channel" : command ["channel_id" ],
850+ "channel" : body ["channel_id" ],
850851 "text" : acknowledgement_msg ,
851852 }
852- client .chat_postEphemeral (** post_params , user = command .get ("user_id" ))
853+ client .chat_postEphemeral (** post_params , user = body .get ("user_id" ))
853854
854855 # Retrieve sample questions
855856 test_questions = SampleQuestionBank ().get_questions (start = start - 1 , end = end - 1 )
@@ -876,7 +877,7 @@ def process_command_test_questions(command: Dict[str, Any], client: WebClient) -
876877 futures .append (future )
877878
878879 post_params ["text" ] = "Testing complete, generating file..."
879- client .chat_postEphemeral (** post_params , user = command .get ("user_id" ))
880+ client .chat_postEphemeral (** post_params , user = body .get ("user_id" ))
880881
881882 aggregated_results = []
882883 for i , future in enumerate (futures ):
@@ -897,7 +898,7 @@ def process_command_test_questions(command: Dict[str, Any], client: WebClient) -
897898
898899 # Upload the file to Slack
899900 client .files_upload_v2 (
900- channel = command ["channel_id" ],
901+ channel = body ["channel_id" ],
901902 content = final_file_content ,
902903 title = filename ,
903904 filename = filename ,
@@ -907,7 +908,7 @@ def process_command_test_questions(command: Dict[str, Any], client: WebClient) -
907908 except Exception as e :
908909 logger .error (
909910 f"Failed to attach feedback buttons: { e } " ,
910- extra = {"channel" : command ["channel_id" ], "error" : traceback .format_exc ()},
911+ extra = {"channel" : body ["channel_id" ], "error" : traceback .format_exc ()},
911912 )
912913
913914
@@ -939,8 +940,8 @@ def process_command_test_ai_request(question, response, output: bool, client: We
939940 return {"index" : f"{ question [0 ]} " , "text" : question [1 ], "response" : response_text }
940941
941942
942- def process_command_test_help (command : Dict [str , Any ], client : WebClient ) -> None :
943- logger .info ("Processing Command Test Help Message" , extra = {"command " : command })
943+ def process_command_test_help (body : Dict [str , Any ], client : WebClient ) -> None :
944+ logger .info ("Processing Command Test Help Message" , extra = {"body " : body })
944945 length = SampleQuestionBank ().length () + 1
945946 help_text = f"""
946947 Certainly! Here is some help testing me!
@@ -962,7 +963,7 @@ def process_command_test_help(command: Dict[str, Any], client: WebClient) -> Non
962963 - /test q10-16 --> Sends questions 10 to 16
963964 - /test .output -> Sends questions 1 to { length } and posts them to Slack
964965 """ # noqa: E501
965- client .chat_postEphemeral (channel = command ["channel_id" ], user = command ["user_id" ], text = help_text )
966+ client .chat_postEphemeral (channel = body ["channel_id" ], user = body ["user_id" ], text = help_text )
966967
967968
968969# ================================================================
0 commit comments