From 852874a12aa586e7603c37d14e7c83823e941e54 Mon Sep 17 00:00:00 2001 From: Noah Date: Wed, 27 Mar 2024 11:57:26 -0500 Subject: [PATCH] Add site stop chat command (fix #22) --- matrix.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/matrix.go b/matrix.go index 380bfbb..602acc7 100644 --- a/matrix.go +++ b/matrix.go @@ -150,6 +150,25 @@ func initMatrix() { return text + "\nšŸŸ¢ Successfully restarted site." }) + registerChatCommand("stop", "Stop 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 := "āšŖļø Stopping server..." + if derr := site.Stop(); derr.code != 0 { + derr.SendOverMatrix() + return text + "\nšŸ”“ Failed to stop site!" + } + return text + "\nšŸŸ¢ Successfully stopped site." + + }) + go func() { for range time.Tick(time.Second * 6) { log.Printf("Scanning for queued messages...")