diff --git a/matrix.go b/matrix.go index ab08f3d..b5aedd9 100644 --- a/matrix.go +++ b/matrix.go @@ -131,6 +131,25 @@ func initMatrix() { return text }) + registerChatCommand("restart", "Restart 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 := "āšŖļø Restarting server..." + derr := site.Restart() + if derr.code != 0 { + derr.SendOverMatrix() + return text + "\nšŸ”“ Failed to restart site!" + } + return text + "\nšŸŸ¢ Successfully restarted site." + }) + go func() { for range time.Tick(time.Second * 6) { log.Printf("Scanning for queued messages...")