add ingame msg

This commit is contained in:
shoopea 2021-11-13 14:27:29 +08:00
parent ccd41c2e1b
commit 54d777934b
2 changed files with 18 additions and 6 deletions

16
ttd.go
View File

@ -608,10 +608,22 @@ func (s *ServerTTD) ComputeClientTime() {
for _, cc := range cfg.Clients {
if cc.Online {
if cc.TimeLeft > 0 && cc.TimeLeft < diff {
bot.SendChat(cfg.Telegram.ChatID, fmt.Sprintf("@%s got not time left. Grace period of %s.", cc.Username, cfg.Game.Threshold))
msg := fmt.Sprintf("@%s got not time left. Grace period of %s.", cc.Username, cfg.Game.Threshold)
bot.SendChat(cfg.Telegram.ChatID, msg)
px := PacketAdminRCon{
Packet: Packet{PType: AdminPacketAdminRCon},
Command: fmt.Sprintf("say %s", msg),
}
srv.Send(px.Bytes())
}
if (cc.TimeLeft+cfg.Game.Threshold) > 0 && (cc.TimeLeft+cfg.Game.Threshold) < diff {
bot.SendChat(cfg.Telegram.ChatID, fmt.Sprintf("@%s got not time left. Grace period over.", cc.Username))
msg := fmt.Sprintf("@%s got not time left. Grace period over.", cc.Username)
bot.SendChat(cfg.Telegram.ChatID, msg)
px := PacketAdminRCon{
Packet: Packet{PType: AdminPacketAdminRCon},
Command: fmt.Sprintf("say %s", msg),
}
srv.Send(px.Bytes())
}
cc.TimeLeft = cc.TimeLeft - diff
}

View File

@ -1,6 +1,6 @@
// Code generated by version.sh (@generated) DO NOT EDIT.
package main
var githash = "11ec55b"
var buildstamp = "2021-11-13_06:23:25"
var commits = "197"
var version = "11ec55b-b197 - 2021-11-13_06:23:25"
var githash = "ccd41c2"
var buildstamp = "2021-11-13_06:27:18"
var commits = "198"
var version = "ccd41c2-b198 - 2021-11-13_06:27:18"