gottdad/main.go
2021-11-07 00:25:42 +08:00

57 lines
872 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{},
Status: &ServerStatusTTD{},
}
go srv.Start()
for {
time.Sleep(1 * time.Second)
}
}