go fmt and support monthly/yearly commands
This commit is contained in:
parent
8abf5c7af3
commit
2a715ac172
17
pkg/admin.go
17
pkg/admin.go
@ -14,7 +14,6 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
type OpenTTDServer struct {
|
type OpenTTDServer struct {
|
||||||
connection net.Conn
|
connection net.Conn
|
||||||
rconDaily []string
|
rconDaily []string
|
||||||
@ -154,9 +153,25 @@ func ( server *OpenTTDServer ) RegisterDateChange (period string, command string
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (server *OpenTTDServer) dateChanged(dt time.Time) {
|
func (server *OpenTTDServer) dateChanged(dt time.Time) {
|
||||||
|
// do every daily one
|
||||||
for _, rconCommand := range server.rconDaily {
|
for _, rconCommand := range server.rconDaily {
|
||||||
server.rconCommand(rconCommand)
|
server.rconCommand(rconCommand)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// monthly ones on the 1st
|
||||||
|
if dt.Day() == 1 {
|
||||||
|
for _, rconCommand := range server.rconMonthly {
|
||||||
|
server.rconCommand(rconCommand)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// yearly on the 1st of jan
|
||||||
|
if dt.Day() == 1 && dt.Month() == 1 {
|
||||||
|
for _, rconCommand := range server.rconYearly {
|
||||||
|
server.rconCommand(rconCommand)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (server OpenTTDServer) rconCommand(command string) {
|
func (server OpenTTDServer) rconCommand(command string) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user