-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.go
40 lines (32 loc) · 831 Bytes
/
app.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
package main
import (
"os"
"github.com/rs/zerolog"
"github.com/rs/zerolog/log"
"github.com/rs/zerolog/pkgerrors"
)
func main() {
bot := New(
os.Getenv("TELEGRAM_ADMINS"),
os.Getenv("TELEGRAM_CHATS"),
)
// default level is info, unless debug flag is present
zerolog.SetGlobalLevel(zerolog.InfoLevel)
if envLogLevel, ok := os.LookupEnv("LOG_LEVEL"); ok {
zerologLevel, err := zerolog.ParseLevel(envLogLevel)
if err == nil {
zerolog.SetGlobalLevel(zerologLevel)
}
}
zerolog.TimeFieldFormat = zerolog.TimeFormatUnix
zerolog.ErrorStackMarshaler = pkgerrors.MarshalStack
// init clients
err := bot.InitMonoClients(os.Getenv("MONO_TOKENS"))
if err != nil {
log.Panic().Err(err)
}
go bot.TelegramStart(os.Getenv("TELEGRAM_TOKEN"))
go bot.ProcessingStart()
// run http server
bot.WebhookStart()
}