time display rounded
This commit is contained in:
parent
cd98db8489
commit
3b878e0641
22
bot.go
22
bot.go
@ -201,24 +201,24 @@ func botPlayers(m *tb.Message) {
|
|||||||
d1 := time.Now().Sub(cfg.Game.StartDate)
|
d1 := time.Now().Sub(cfg.Game.StartDate)
|
||||||
days := int(time.Duration(d1.Hours()) / 24)
|
days := int(time.Duration(d1.Hours()) / 24)
|
||||||
d2 := time.Duration(days+1)*(time.Hour)*24 - d1
|
d2 := time.Duration(days+1)*(time.Hour)*24 - d1
|
||||||
str := fmt.Sprintf("Update in %s\r\n", d2)
|
str := fmt.Sprintf("Update in %s\r\n", d2.Round(time.Second))
|
||||||
|
|
||||||
online := ""
|
online := ""
|
||||||
for _, cc := range cfg.Clients {
|
for _, cc := range cfg.Clients {
|
||||||
if cc.Online {
|
if cc.Online {
|
||||||
if co, ok := srv.Status.Companies[cc.CompanyID]; ok {
|
if co, ok := srv.Status.Companies[cc.CompanyID]; ok {
|
||||||
online = online + fmt.Sprintf(" - %s (%s) : %s", cc.Username, cc.TimeLeft, co.Name) + "\r\n"
|
online = online + fmt.Sprintf(" - %s (%s) : %s", cc.Username, cc.TimeLeft.Round(time.Second), co.Name) + "\r\n"
|
||||||
} else {
|
} else {
|
||||||
online = online + fmt.Sprintf(" - %s (%s) : none", cc.Username, cc.TimeLeft) + "\r\n"
|
online = online + fmt.Sprintf(" - %s (%s) : none", cc.Username, cc.TimeLeft.Round(time.Second)) + "\r\n"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
offline := ""
|
offline := ""
|
||||||
for _, cc := range cfg.Clients {
|
for _, cc := range cfg.Clients {
|
||||||
if co, 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, co.Name) + "\r\n"
|
offline = offline + fmt.Sprintf(" - %s (%s) : %s", cc.Username, cc.TimeLeft.Round(time.Second), co.Name) + "\r\n"
|
||||||
} else {
|
} else {
|
||||||
offline = offline + fmt.Sprintf(" - %s (%s) : none", cc.Username, cc.TimeLeft) + "\r\n"
|
offline = offline + fmt.Sprintf(" - %s (%s) : none", cc.Username, cc.TimeLeft.Round(time.Second)) + "\r\n"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -267,7 +267,7 @@ func botGive(m *tb.Message) {
|
|||||||
cc := cfg.Clients[u]
|
cc := cfg.Clients[u]
|
||||||
cc.TimeLeft += d
|
cc.TimeLeft += d
|
||||||
|
|
||||||
bot.SendChat(m.Chat.ID, fmt.Sprintf("@%s now has %s left.", uStr, cc.TimeLeft))
|
bot.SendChat(m.Chat.ID, fmt.Sprintf("@%s now has %s left.", uStr, cc.TimeLeft.Round(time.Second)))
|
||||||
}
|
}
|
||||||
|
|
||||||
func botTransfer(m *tb.Message) {
|
func botTransfer(m *tb.Message) {
|
||||||
@ -309,7 +309,7 @@ func botTransfer(m *tb.Message) {
|
|||||||
ccTo.TimeLeft += d
|
ccTo.TimeLeft += d
|
||||||
ccFrom.TimeLeft -= d
|
ccFrom.TimeLeft -= d
|
||||||
|
|
||||||
bot.SendChat(m.Chat.ID, fmt.Sprintf("@%s now has %s left.\r\n@%s has %s left.", uStr, ccTo.TimeLeft, ccFrom.Username, ccFrom.TimeLeft))
|
bot.SendChat(m.Chat.ID, fmt.Sprintf("@%s now has %s left.\r\n@%s has %s left.", uStr, ccTo.TimeLeft.Round(time.Second), ccFrom.Username, ccFrom.TimeLeft.Round(time.Second)))
|
||||||
}
|
}
|
||||||
|
|
||||||
func botTake(m *tb.Message) {
|
func botTake(m *tb.Message) {
|
||||||
@ -348,7 +348,7 @@ func botTake(m *tb.Message) {
|
|||||||
cc := cfg.Clients[u]
|
cc := cfg.Clients[u]
|
||||||
cc.TimeLeft -= d
|
cc.TimeLeft -= d
|
||||||
|
|
||||||
bot.SendChat(m.Chat.ID, fmt.Sprintf("@%s now has %s left.", uStr, cc.TimeLeft))
|
bot.SendChat(m.Chat.ID, fmt.Sprintf("@%s now has %s left.", uStr, cc.TimeLeft.Round(time.Second)))
|
||||||
}
|
}
|
||||||
|
|
||||||
func botHelp(m *tb.Message) {
|
func botHelp(m *tb.Message) {
|
||||||
@ -442,13 +442,13 @@ func botDeregister(m *tb.Message) {
|
|||||||
for coID, co := range srv.Status.Companies {
|
for coID, co := range srv.Status.Companies {
|
||||||
if coID == cc.CompanyID {
|
if coID == cc.CompanyID {
|
||||||
cc.CompanyID = 255
|
cc.CompanyID = 255
|
||||||
bot.SendChat(m.Chat.ID, fmt.Sprintf("Deregistered from %s. %s playable left.", co.Name, cc.TimeLeft))
|
bot.SendChat(m.Chat.ID, fmt.Sprintf("Deregistered from %s. %s playable left.", co.Name, cc.TimeLeft.Round(time.Second)))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
logInfoAlert("botRegister : %s : no such CompanyID : %d", cc.Username, cc.CompanyID)
|
logInfoAlert("botRegister : %s : no such CompanyID : %d", cc.Username, cc.CompanyID)
|
||||||
cc.CompanyID = 255
|
cc.CompanyID = 255
|
||||||
bot.SendChat(m.Chat.ID, fmt.Sprintf("Registered company didn't exist anymore. %s playable left.", cc.TimeLeft))
|
bot.SendChat(m.Chat.ID, fmt.Sprintf("Registered company didn't exist anymore. %s playable left.", cc.TimeLeft.Round(time.Second)))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
@ -530,7 +530,7 @@ func botRegister(m *tb.Message) {
|
|||||||
days := int(time.Now().Sub(cfg.Game.StartDate).Hours() / 24)
|
days := int(time.Now().Sub(cfg.Game.StartDate).Hours() / 24)
|
||||||
cc.TimeLeft = cfg.Game.StartingAllotment + cfg.Game.DailyAllotment*time.Duration(days)
|
cc.TimeLeft = cfg.Game.StartingAllotment + cfg.Game.DailyAllotment*time.Duration(days)
|
||||||
}
|
}
|
||||||
bot.SendChat(m.Chat.ID, fmt.Sprintf("@%s registered %s (with %s playable)", cc.Username, srv.Status.Companies[cc.CompanyID].Name, cc.TimeLeft))
|
bot.SendChat(m.Chat.ID, fmt.Sprintf("@%s registered %s (with %s playable)", cc.Username, srv.Status.Companies[cc.CompanyID].Name, cc.TimeLeft.Round(time.Second)))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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 = "9614fcc"
|
var githash = "cd98db8"
|
||||||
var buildstamp = "2021-11-28_10:31:27"
|
var buildstamp = "2021-11-28_13:25:25"
|
||||||
var commits = "208"
|
var commits = "209"
|
||||||
var version = "9614fcc-b208 - 2021-11-28_10:31:27"
|
var version = "cd98db8-b209 - 2021-11-28_13:25:25"
|
||||||
|
Loading…
Reference in New Issue
Block a user