From aac2a274b92f713b6a51fd2f758d998ad2bc8faf Mon Sep 17 00:00:00 2001 From: shoopea Date: Mon, 8 Nov 2021 21:51:21 +0800 Subject: [PATCH] update players --- bot.go | 16 +++++++++++----- version.go | 8 ++++---- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/bot.go b/bot.go index f78fc34..f5f878f 100644 --- a/bot.go +++ b/bot.go @@ -72,7 +72,6 @@ func (b *Bot) BotHandlers() { } func botPause(m *tb.Message) { - PrintText(m) for userID, cc := range cfg.Clients { if userID == m.Sender.ID { if co, ok := srv.Status.Companies[cc.CompanyID]; ok { @@ -83,11 +82,13 @@ func botPause(m *tb.Message) { } else { bot.SendChat(bot.Config.ChatID, "Game already paused.") } + botPlayers(m) return } } } } + botPlayers(m) bot.SendChat(bot.Config.ChatID, "You are not playing and cannot pause the game.") return } @@ -104,11 +105,13 @@ func botUnpause(m *tb.Message) { } else { bot.SendChat(bot.Config.ChatID, fmt.Sprintf("Cannot unpause : %s", srv.NeedPauseReason())) } + botPlayers(m) return } } } } + botPlayers(m) bot.SendChat(bot.Config.ChatID, "You are not playing and cannot unpause the game.") return } @@ -143,6 +146,11 @@ func botClients(m *tb.Message) { } func botPlayers(m *tb.Message) { + t := time.Now().Sub(cfg.Game.StartDate) + days := int(time.Duration(t.Hours()) / 24) + t = time.Duration(days+1)*(time.Hour)*24 - t + str := fmt.Sprintf("Update in %s\r\n", t) + online := "" for _, cc := range cfg.Clients { if cc.Online { @@ -155,16 +163,14 @@ func botPlayers(m *tb.Message) { offline = offline + fmt.Sprintf(" - @%s (%s) : %s", cc.Username, cc.TimeLeft, srv.Status.Companies[cc.CompanyID].Name) + "\r\n" } } - str := "" + if len(online) > 0 { str = str + "Players online :\r\n" + online } if len(offline) > 0 { str = str + "Players offline :\r\n" + offline } - if str == "" { - str = "No players." - } + bot.SendChat(m.Chat.ID, str) } diff --git a/version.go b/version.go index 616d774..8d65a63 100644 --- a/version.go +++ b/version.go @@ -1,6 +1,6 @@ // Code generated by version.sh (@generated) DO NOT EDIT. package main -var githash = "7db13a7" -var buildstamp = "2021-11-08_06:27:36" -var commits = "169" -var version = "7db13a7-b169 - 2021-11-08_06:27:36" +var githash = "9a1ba7e" +var buildstamp = "2021-11-08_13:51:05" +var commits = "170" +var version = "9a1ba7e-b170 - 2021-11-08_13:51:05"