fix client config cleanup
This commit is contained in:
parent
07c2ea7adb
commit
d09710eb3d
12
bot.go
12
bot.go
@ -204,13 +204,19 @@ func botPlayers(m *tb.Message) {
|
|||||||
online := ""
|
online := ""
|
||||||
for _, cc := range cfg.Clients {
|
for _, cc := range cfg.Clients {
|
||||||
if cc.Online {
|
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 := ""
|
offline := ""
|
||||||
for _, cc := range cfg.Clients {
|
for _, cc := range cfg.Clients {
|
||||||
if _, ok := srv.Status.Companies[cc.CompanyID]; ok && !cc.Online {
|
if co, 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"
|
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"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
11
ttd.go
11
ttd.go
@ -138,7 +138,6 @@ func (s *ServerTTD) HeartBeat(stop chan struct{}) {
|
|||||||
s.UpdateDate()
|
s.UpdateDate()
|
||||||
s.UpdateClients()
|
s.UpdateClients()
|
||||||
s.UpdateCompanies()
|
s.UpdateCompanies()
|
||||||
s.UpdateConfigClients()
|
|
||||||
s.PruneClients()
|
s.PruneClients()
|
||||||
s.PruneCompanies()
|
s.PruneCompanies()
|
||||||
s.ComputeClientTime()
|
s.ComputeClientTime()
|
||||||
@ -566,16 +565,6 @@ func (s *ServerTTD) UpdateCompanies() {
|
|||||||
s.Status.UpdateCompanies = time.Now()
|
s.Status.UpdateCompanies = time.Now()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *ServerTTD) UpdateConfigClients() {
|
|
||||||
for _, cc := range cfg.Clients {
|
|
||||||
if cc.CompanyID != 255 {
|
|
||||||
if _, ok := srv.Status.Companies[cc.CompanyID]; !ok {
|
|
||||||
cc.CompanyID = 255
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *ServerTTD) PruneClients() {
|
func (s *ServerTTD) PruneClients() {
|
||||||
for cltID, clt := range s.Status.Clients {
|
for cltID, clt := range s.Status.Clients {
|
||||||
if clt.LastSeen.Add(2 * updateHeartBeat).Before(time.Now()) {
|
if clt.LastSeen.Add(2 * updateHeartBeat).Before(time.Now()) {
|
||||||
|
@ -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 = "d312644"
|
var githash = "07c2ea7"
|
||||||
var buildstamp = "2021-11-26_00:22:05"
|
var buildstamp = "2021-11-26_00:28:51"
|
||||||
var commits = "205"
|
var commits = "206"
|
||||||
var version = "d312644-b205 - 2021-11-26_00:22:05"
|
var version = "07c2ea7-b206 - 2021-11-26_00:28:51"
|
||||||
|
Loading…
Reference in New Issue
Block a user