tgbot_misaka_5882f7/main.go

49 lines
719 B
Go

package main
import (
"os"
"os/signal"
"syscall"
"go.uber.org/zap"
)
var logger *zap.SugaredLogger
func initLogger() {
l, err := zap.NewProduction()
if err != nil {
panic(err)
}
logger = l.Sugar()
}
func runBot() {
logger.Info("Bot initializing...")
bot, err := initBot()
if err != nil {
logger.Fatalw("Failed to initialize bot", "err", err)
}
go bot.Start()
logger.Info("Bot started")
// listen for shutdown signal
sigCh := make(chan os.Signal, 1)
signal.Notify(sigCh, os.Interrupt, syscall.SIGTERM)
<-sigCh
logger.Info("Bot shutdown...")
bot.Stop()
}
func main() {
initLogger()
if err := LoadCfg(); err != nil {
logger.Fatalw("Failed to load config", "err", err)
}
runBot()
}