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() {