|
4 | 4 | from slack_bolt import Ack |
5 | 5 |
|
6 | 6 | from external.manman_experience_api.models import StdinCommandRequest |
7 | | -from external.old_manman_api.models.stdin_command_request import old_StdinCommandRequest |
8 | 7 | from friendly_computing_machine.bot.app import app |
9 | 8 | from friendly_computing_machine.bot.slack_client import SlackWebClientFCM |
10 | 9 | from friendly_computing_machine.bot.slack_enum import SlackActionRegistry |
@@ -64,37 +63,22 @@ def handle_restart_server(ack: Ack, body, client: SlackWebClientFCM, logger): |
64 | 63 |
|
65 | 64 | @app.action("send_stdin_custom_command") |
66 | 65 | def handle_custom_command(ack: Ack, body, client: SlackWebClientFCM, logger): |
67 | | - ack() |
68 | 66 | payload = ActionPayload.from_dict(body) |
69 | | - logger.debug(body) |
70 | | - |
71 | | - if payload.stdin_command_input is None: |
72 | | - logger.error("Custom command is None") |
73 | | - # message? |
74 | | - client.chat_postMessage( |
75 | | - channel=payload.user_id, text="Error: Custom command is empty." |
76 | | - ) |
| 67 | + # TODO - improve this |
| 68 | + raw_string = payload.action_body |
| 69 | + id, command = raw_string.split(";", 1) |
| 70 | + # TODO - pass in command_args as list instead of a single string |
| 71 | + mmexapi = ManManExperienceAPI.get_api() |
| 72 | + # TODO does work? |
| 73 | + if not command: |
| 74 | + logger.error("No command provided in stdin action") |
| 75 | + ack(text="No command provided") |
77 | 76 | return |
78 | | - |
79 | | - logger.info(f"Custom command: {payload.stdin_command_input}") |
80 | | - |
81 | | - # TODO - parse this? seems rather wrong to just take user input but whatever for now |
82 | | - req = old_StdinCommandRequest( |
83 | | - commands=[payload.stdin_command_input], |
| 77 | + mmexapi.stdin_game_server_gameserver_id_stdin_post( |
| 78 | + int(id), |
| 79 | + StdinCommandRequest(commands=[command]), |
84 | 80 | ) |
85 | | - try: |
86 | | - mapi = OldManManAPI.get_api() |
87 | | - game_server_instance_id = int(payload.action_body) |
88 | | - mapi.stdin_game_server_host_gameserver_id_stdin_post( |
89 | | - game_server_instance_id, |
90 | | - req, |
91 | | - ) |
92 | | - except Exception as e: |
93 | | - logger.exception(f"Failed to get ManMan API client: {e}") |
94 | | - # Optionally inform the user about the configuration issue |
95 | | - client.chat_postMessage( |
96 | | - channel=payload.user_id, text="Error: ManMan API error. Please try again" |
97 | | - ) |
| 81 | + ack() |
98 | 82 |
|
99 | 83 |
|
100 | 84 | @app.action(SlackActionRegistry.MANMAN_WORKER_STOP) |
@@ -155,7 +139,7 @@ def handle_manman_server_stop( |
155 | 139 | server_id = int(payload.action_body) |
156 | 140 | mmexapi = ManManExperienceAPI.get_api() |
157 | 141 | mmexapi.stop_game_server_gameserver_id_stop_post(server_id) |
158 | | - ack() |
| 142 | + ack(":( bye bye") |
159 | 143 |
|
160 | 144 | # TODO 6/10/25 |
161 | 145 | # something is wrong with the stop. It is being passed the right id I think |
|
0 commit comments