-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
47 lines (37 loc) · 879 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package main
import (
"os"
"os/signal"
"syscall"
"github.com/Brawl345/gobot/utils"
_ "github.com/joho/godotenv/autoload"
"github.com/Brawl345/gobot/bot"
"github.com/Brawl345/gobot/logger"
"github.com/Brawl345/gobot/model/sql"
)
var log = logger.New("main")
func main() {
versionInfo, err := utils.ReadVersionInfo()
if err != nil {
log.Err(err).Send()
} else {
log.Info().Msgf("Gobot-%s, %v", versionInfo.Revision, versionInfo.LastCommit)
}
db, err := sql.New()
if err != nil {
log.Fatal().Err(err).Send()
}
b, err := bot.New(db)
if err != nil {
log.Fatal().Err(err).Send()
}
log.Info().Msgf("Logged in as @%s (%d)", b.GoTgBot.Username, b.GoTgBot.Id)
channel := make(chan os.Signal)
signal.Notify(channel, os.Interrupt, syscall.SIGTERM, syscall.SIGINT)
go func() {
<-channel
log.Info().Msg("Stopping...")
os.Exit(0)
}()
b.Start()
}