-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
45 lines (34 loc) · 1.07 KB
/
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
package main
import (
"os"
"strconv"
"github.com/bb4L/rpi-radio-alarm-go-library/api"
"github.com/bb4L/rpi-radio-alarm-go-library/storage"
server "github.com/bb4L/rpi-radio-alarm-go/apiserver"
"github.com/bb4L/rpi-radio-alarm-go/constants"
"github.com/bb4L/rpi-radio-alarm-go-library/logging"
"github.com/bb4L/rpi-radio-alarm-go/runner"
bot "github.com/bb4L/rpi-radio-alarm-telegrambot-go/bot"
)
var logger = logging.GetLogger(os.Stdout, constants.DefaultPrefix, "main")
var storageHelper storage.Helper = storage.Helper{}
func main() {
settings, err := storageHelper.GetSettings()
if err != nil {
logger.Fatalln("error on getting stored data")
}
if settings.RunAPI {
logger.Println("start api server")
go server.StartAPIServer(&storageHelper)
}
if settings.RunTelegrambot {
apiHelper := api.Helper{AlarmURL: "http://localhost:" + strconv.Itoa(settings.Port), ExtraHeader: "", ExtreaHeaderValue: ""}
go bot.StartTelegramBot(&apiHelper)
}
if settings.RunDiscordbot {
go func() {
logger.Println("run dicordbot")
}()
}
runner.Runner(&storageHelper)
}