Archived
1
This repository has been archived on 2022-11-04. You can view files and clone it, but cannot push or open issues or pull requests.
fwzookeeper/main.go
Vladimir Hodakov 0ba20b3ed5
Add battle announces to channel
Channel ID is configured in fw_zookeeper.yaml.
2018-11-29 22:15:21 +04:00

51 lines
1.1 KiB
Go

// Fantasy World Zookeeper Bot
// Copyright (c) 2018 Vladimir "fat0troll" Hodakov
package main
import (
"lab.wtfteam.pro/fat0troll/fw_zookeeper/context"
"lab.wtfteam.pro/fat0troll/fw_zookeeper/domains/battles/v1"
"lab.wtfteam.pro/fat0troll/fw_zookeeper/domains/commands/v1"
"lab.wtfteam.pro/fat0troll/fw_zookeeper/internal/router"
"lab.wtfteam.pro/fat0troll/fw_zookeeper/internal/telegram"
"os"
"os/signal"
"runtime"
"syscall"
)
func main() {
// Before any real work - lock to OS thread. We shouldn't leave it until
// shutdown
runtime.LockOSThread()
// Initializing context
c := context.NewContext()
c.Init()
c.InitConfiguration()
router.New(c)
commandsv1.New(c)
battlesv1.New(c)
telegram.New(c)
// CTRL+C handler.
interrupt := make(chan os.Signal, 1)
signal.Notify(interrupt)
shutdownDone := make(chan bool, 1)
go func() {
signalThing := <-interrupt
if signalThing == syscall.SIGTERM || signalThing == syscall.SIGINT {
c.Logger.Info().Msg("Got " + signalThing.String() + " signal, shutting down...")
shutdownDone <- true
}
}()
<-shutdownDone
os.Exit(0)
}