From b441028e15838a8b961a5a0a7313a86982d4ba89 Mon Sep 17 00:00:00 2001 From: shoopea Date: Sun, 21 Jun 2020 21:14:36 +0200 Subject: [PATCH] test --- main.go | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/main.go b/main.go index 4478f09..d3398b5 100644 --- a/main.go +++ b/main.go @@ -20,10 +20,11 @@ type Client struct { } var ( - bot *tb.Bot - clients map[uint32]*Client - paused bool = true - forcePaused bool = true + bot *tb.Bot + clients map[uint32]*Client + paused bool = true + forcePaused bool = true + forcePausedBy string githash string buildstamp string @@ -203,11 +204,11 @@ func main() { if sp.Message == "!unpause" { logInfoDebug("AdminPacketServerChat : Unpausing") forcePaused = false - sendChat(-436055948, fmt.Sprintf("Game unpaused by %s", clients[sp.ClientID].Name)) + forcePausedBy = clients[sp.ClientID].Name } else if sp.Message == "!pause" { logInfoDebug("AdminPacketServerChat : Pausing") forcePaused = true - sendChat(-436055948, fmt.Sprintf("Game paused by %s", clients[sp.ClientID].Name)) + forcePausedBy = clients[sp.ClientID].Name } else { logInfoDebug("AdminPacketServerChat :\n- ActionID: %d\n- DestinationID: %d\n- ClientID: %d\n- Message: %s\n- Amount: %d", sp.ActionID, sp.DestinationID, sp.ClientID, sp.Message, sp.Amount) } @@ -282,6 +283,11 @@ func main() { Command: "pause", } _, err = conn.Write(px.Bytes()) + logInfoDebug("Force pausing") + if pausedBy != "" { + sendChat(-436055948, fmt.Sprintf("Game paused by %s", pausedBy)) + pausedBy = "" + } } if paused && !forcePaused && len(clients) > 1 { // server is client #1 paused = false @@ -290,7 +296,11 @@ func main() { Command: "unpause", } _, err = conn.Write(px.Bytes()) - sendChat(-436055948, "Game unpaused.") + logInfoDebug("Force unpausing") + if pausedBy != "" { + sendChat(-436055948, fmt.Sprintf("Game unpaused by %s", pausedBy)) + pausedBy = "" + } } if !paused && len(clients) == 1 { // server is client #1 paused = true @@ -300,6 +310,8 @@ func main() { } _, err = conn.Write(px.Bytes()) logInfoDebug("Pausing") + sendChat(-436055948, "No players. Game paused.") + } }