From 7ccd29bfb134c370c4a85ef3f3efedde88aeb21a Mon Sep 17 00:00:00 2001 From: Noah Date: Wed, 27 Mar 2024 12:03:12 -0500 Subject: [PATCH] Add site start chat command (fix #23) --- matrix.go | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/matrix.go b/matrix.go index 602acc7..b9806c1 100644 --- a/matrix.go +++ b/matrix.go @@ -150,6 +150,25 @@ func initMatrix() { return text + "\nšŸŸ¢ Successfully restarted site." }) + registerChatCommand("start", "Start a site.", func(ctx context.Context, evt *event.Event, args []string) string { + if len(args) < 2 { + return "šŸ”“ Invalid site." + } + site, found, err := getSite(args[1]) + if err != nil { + return "šŸ”“ Failed to get site " + args[2] + "!" + } else if !found { + return "šŸ”“ Invalid site." + } + + text := "āšŖļø Starting server..." + if derr := site.Start(); derr.code != 0 { + derr.SendOverMatrix() + return text + "\nšŸ”“ Failed to stop site!" + } + return text + "\nšŸŸ¢ Successfully started site." + }) + registerChatCommand("stop", "Stop a site.", func(ctx context.Context, evt *event.Event, args []string) string { if len(args) < 2 { return "šŸ”“ Invalid site." @@ -166,7 +185,6 @@ func initMatrix() { return text + "\nšŸ”“ Failed to stop site!" } return text + "\nšŸŸ¢ Successfully stopped site." - }) go func() {