initial commit
This commit is contained in:
commit
2f65200729
8 changed files with 1209 additions and 0 deletions
48
main.go
Normal file
48
main.go
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
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()
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue