From 9a1ba7e7f2cd52d4171c5cb5b3a998a266de7359 Mon Sep 17 00:00:00 2001 From: shoopea Date: Mon, 8 Nov 2021 14:27:49 +0800 Subject: [PATCH] update pause/unpause --- bot.go | 24 ++++++++++++++---------- version.go | 8 ++++---- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/bot.go b/bot.go index 8b7d3d2..f78fc34 100644 --- a/bot.go +++ b/bot.go @@ -78,15 +78,17 @@ func botPause(m *tb.Message) { if co, ok := srv.Status.Companies[cc.CompanyID]; ok { if clt, ok2 := srv.Status.Clients[co.ClientID]; ok2 { clt.Paused = true + if !srv.Status.Paused { + srv.Pause() + } else { + bot.SendChat(bot.Config.ChatID, "Game already paused.") + } + return } } } } - if !srv.Status.Paused { - srv.Pause() - } else { - bot.SendChat(bot.Config.ChatID, "Game already paused.") - } + bot.SendChat(bot.Config.ChatID, "You are not playing and cannot pause the game.") return } @@ -97,15 +99,17 @@ func botUnpause(m *tb.Message) { if co, ok := srv.Status.Companies[cc.CompanyID]; ok { if clt, ok2 := srv.Status.Clients[co.ClientID]; ok2 { clt.Paused = false + if !srv.NeedPause() { + srv.Unpause() + } else { + bot.SendChat(bot.Config.ChatID, fmt.Sprintf("Cannot unpause : %s", srv.NeedPauseReason())) + } + return } } } } - if !srv.NeedPause() { - srv.Unpause() - } else { - bot.SendChat(bot.Config.ChatID, fmt.Sprintf("Cannot unpause : %s", srv.NeedPauseReason())) - } + bot.SendChat(bot.Config.ChatID, "You are not playing and cannot unpause the game.") return } diff --git a/version.go b/version.go index 3f34a8b..616d774 100644 --- a/version.go +++ b/version.go @@ -1,6 +1,6 @@ // Code generated by version.sh (@generated) DO NOT EDIT. package main -var githash = "3194cb3" -var buildstamp = "2021-11-08_06:19:35" -var commits = "168" -var version = "3194cb3-b168 - 2021-11-08_06:19:35" +var githash = "7db13a7" +var buildstamp = "2021-11-08_06:27:36" +var commits = "169" +var version = "7db13a7-b169 - 2021-11-08_06:27:36"