update players
This commit is contained in:
parent
9a1ba7e7f2
commit
aac2a274b9
16
bot.go
16
bot.go
@ -72,7 +72,6 @@ func (b *Bot) BotHandlers() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func botPause(m *tb.Message) {
|
func botPause(m *tb.Message) {
|
||||||
PrintText(m)
|
|
||||||
for userID, cc := range cfg.Clients {
|
for userID, cc := range cfg.Clients {
|
||||||
if userID == m.Sender.ID {
|
if userID == m.Sender.ID {
|
||||||
if co, ok := srv.Status.Companies[cc.CompanyID]; ok {
|
if co, ok := srv.Status.Companies[cc.CompanyID]; ok {
|
||||||
@ -83,11 +82,13 @@ func botPause(m *tb.Message) {
|
|||||||
} else {
|
} else {
|
||||||
bot.SendChat(bot.Config.ChatID, "Game already paused.")
|
bot.SendChat(bot.Config.ChatID, "Game already paused.")
|
||||||
}
|
}
|
||||||
|
botPlayers(m)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
botPlayers(m)
|
||||||
bot.SendChat(bot.Config.ChatID, "You are not playing and cannot pause the game.")
|
bot.SendChat(bot.Config.ChatID, "You are not playing and cannot pause the game.")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -104,11 +105,13 @@ func botUnpause(m *tb.Message) {
|
|||||||
} else {
|
} else {
|
||||||
bot.SendChat(bot.Config.ChatID, fmt.Sprintf("Cannot unpause : %s", srv.NeedPauseReason()))
|
bot.SendChat(bot.Config.ChatID, fmt.Sprintf("Cannot unpause : %s", srv.NeedPauseReason()))
|
||||||
}
|
}
|
||||||
|
botPlayers(m)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
botPlayers(m)
|
||||||
bot.SendChat(bot.Config.ChatID, "You are not playing and cannot unpause the game.")
|
bot.SendChat(bot.Config.ChatID, "You are not playing and cannot unpause the game.")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -143,6 +146,11 @@ func botClients(m *tb.Message) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func botPlayers(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 := ""
|
online := ""
|
||||||
for _, cc := range cfg.Clients {
|
for _, cc := range cfg.Clients {
|
||||||
if cc.Online {
|
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"
|
offline = offline + fmt.Sprintf(" - @%s (%s) : %s", cc.Username, cc.TimeLeft, srv.Status.Companies[cc.CompanyID].Name) + "\r\n"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
str := ""
|
|
||||||
if len(online) > 0 {
|
if len(online) > 0 {
|
||||||
str = str + "Players online :\r\n" + online
|
str = str + "Players online :\r\n" + online
|
||||||
}
|
}
|
||||||
if len(offline) > 0 {
|
if len(offline) > 0 {
|
||||||
str = str + "Players offline :\r\n" + offline
|
str = str + "Players offline :\r\n" + offline
|
||||||
}
|
}
|
||||||
if str == "" {
|
|
||||||
str = "No players."
|
|
||||||
}
|
|
||||||
bot.SendChat(m.Chat.ID, str)
|
bot.SendChat(m.Chat.ID, str)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
// Code generated by version.sh (@generated) DO NOT EDIT.
|
// Code generated by version.sh (@generated) DO NOT EDIT.
|
||||||
package main
|
package main
|
||||||
var githash = "7db13a7"
|
var githash = "9a1ba7e"
|
||||||
var buildstamp = "2021-11-08_06:27:36"
|
var buildstamp = "2021-11-08_13:51:05"
|
||||||
var commits = "169"
|
var commits = "170"
|
||||||
var version = "7db13a7-b169 - 2021-11-08_06:27:36"
|
var version = "9a1ba7e-b170 - 2021-11-08_13:51:05"
|
||||||
|
Loading…
Reference in New Issue
Block a user