fix client config cleanup

This commit is contained in:
shoopea
2021-11-26 08:29:09 +08:00
parent 07c2ea7adb
commit d09710eb3d
3 changed files with 13 additions and 18 deletions

12
bot.go
View File

@@ -204,13 +204,19 @@ func botPlayers(m *tb.Message) {
online := ""
for _, cc := range cfg.Clients {
if cc.Online {
online = online + fmt.Sprintf(" - %s (%s) : %s", cc.Username, cc.TimeLeft, srv.Status.Companies[cc.CompanyID].Name) + "\r\n"
if co, ok := srv.Status.Companies[cc.CompanyID]; ok {
online = online + fmt.Sprintf(" - %s (%s) : %s", cc.Username, cc.TimeLeft, co.Name) + "\r\n"
} else {
online = online + fmt.Sprintf(" - %s (none) : %s", cc.Username, cc.TimeLeft) + "\r\n"
}
}
}
offline := ""
for _, cc := range cfg.Clients {
if _, ok := srv.Status.Companies[cc.CompanyID]; ok && !cc.Online {
offline = offline + fmt.Sprintf(" - %s (%s) : %s", cc.Username, cc.TimeLeft, srv.Status.Companies[cc.CompanyID].Name) + "\r\n"
if co, ok := srv.Status.Companies[cc.CompanyID]; ok && !cc.Online {
offline = offline + fmt.Sprintf(" - %s (%s) : %s", cc.Username, cc.TimeLeft, co.Name) + "\r\n"
} else {
offline = offline + fmt.Sprintf(" - %s (none) : %s", cc.Username, cc.TimeLeft) + "\r\n"
}
}