Skip to content

Commit 973aa53

Browse files
committed
a
1 parent a8a7a94 commit 973aa53

1 file changed

Lines changed: 14 additions & 30 deletions

File tree

  • src/friendly_computing_machine/bot/handlers

src/friendly_computing_machine/bot/handlers/actions.py

Lines changed: 14 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
from slack_bolt import Ack
55

66
from external.manman_experience_api.models import StdinCommandRequest
7-
from external.old_manman_api.models.stdin_command_request import old_StdinCommandRequest
87
from friendly_computing_machine.bot.app import app
98
from friendly_computing_machine.bot.slack_client import SlackWebClientFCM
109
from friendly_computing_machine.bot.slack_enum import SlackActionRegistry
@@ -64,37 +63,22 @@ def handle_restart_server(ack: Ack, body, client: SlackWebClientFCM, logger):
6463

6564
@app.action("send_stdin_custom_command")
6665
def handle_custom_command(ack: Ack, body, client: SlackWebClientFCM, logger):
67-
ack()
6866
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")
7776
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]),
8480
)
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()
9882

9983

10084
@app.action(SlackActionRegistry.MANMAN_WORKER_STOP)
@@ -155,7 +139,7 @@ def handle_manman_server_stop(
155139
server_id = int(payload.action_body)
156140
mmexapi = ManManExperienceAPI.get_api()
157141
mmexapi.stop_game_server_gameserver_id_stop_post(server_id)
158-
ack()
142+
ack(":( bye bye")
159143

160144
# TODO 6/10/25
161145
# something is wrong with the stop. It is being passed the right id I think

0 commit comments

Comments
 (0)