-
Notifications
You must be signed in to change notification settings - Fork 38
/
main.go
42 lines (31 loc) · 916 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
package main
import (
"embed"
"flag"
"github.com/gempir/justlog/api"
"github.com/gempir/justlog/archiver"
"github.com/gempir/justlog/bot"
"github.com/gempir/justlog/config"
"github.com/gempir/justlog/filelog"
"github.com/gempir/justlog/helix"
)
// content holds our static web server content.
//
//go:embed web/dist/*
var assets embed.FS
func main() {
configFile := flag.String("config", "config.json", "json config file")
flag.Parse()
cfg := config.NewConfig(*configFile)
fileLogger := filelog.NewFileLogger(cfg.LogsDirectory)
helixClient := helix.NewClient(cfg.ClientID, cfg.ClientSecret)
go helixClient.StartRefreshTokenRoutine()
if cfg.Archive {
archiver := archiver.NewArchiver(cfg.LogsDirectory)
go archiver.Boot()
}
bot := bot.NewBot(cfg, &helixClient, &fileLogger)
apiServer := api.NewServer(cfg, bot, &fileLogger, &helixClient, assets)
go apiServer.Init()
bot.Connect()
}