Add site stop chat command (fix #22)
This commit is contained in:
parent
09ed6cc8c4
commit
852874a12a
19
matrix.go
19
matrix.go
@ -150,6 +150,25 @@ func initMatrix() {
|
|||||||
return text + "\n🟢 Successfully restarted site."
|
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() {
|
go func() {
|
||||||
for range time.Tick(time.Second * 6) {
|
for range time.Tick(time.Second * 6) {
|
||||||
log.Printf("Scanning for queued messages...")
|
log.Printf("Scanning for queued messages...")
|
||||||
|
Loading…
Reference in New Issue
Block a user