Add site stop chat command (fix #22)

This commit is contained in:
Noah 2024-03-27 11:57:26 -05:00
parent 09ed6cc8c4
commit 852874a12a

View File

@ -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...")