gottdad/main.go
2021-12-04 13:24:45 +08:00

59 lines
903 B
Go

package main
import (
"flag"
"time"
_ "embed"
)
var (
cfg *Config
srv *ServerTTD
bot *Bot
configFlag = flag.String("config", "config.json", "config file")
initFlag = flag.Bool("init", false, "init config")
)
func main() {
var err error
flag.Parse()
cfg = &Config{}
if *initFlag {
logInfoWarn("Initializing configuration..")
err = cfg.Init()
failError(err, "Cannot init config")
err = cfg.Save(*configFlag)
failError(err, "Cannot save config")
} else {
err = cfg.Load(*configFlag)
failError(err, "Cannot open config")
}
logInfoWarn("Starting up (%s) ...", version)
// Registering bot
bot = &Bot{
Config: cfg.Telegram,
}
go bot.Start()
time.Sleep(1 * time.Second)
srv = &ServerTTD{
Config: cfg.Server,
Data: &ServerDataTTD{
Started: cfg.Game.Started,
},
Status: &ServerStatusTTD{},
}
go srv.Start()
for {
time.Sleep(1 * time.Second)
}
}