-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
54 lines (50 loc) · 1.39 KB
/
main.go
File metadata and controls
54 lines (50 loc) · 1.39 KB
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
48
49
50
51
52
53
54
package main
import (
"fmt"
"github.com/rs/zerolog"
"github.com/rs/zerolog/log"
"os"
"time"
)
func main() {
if err := run(); err != nil {
log.Fatal().Err(err).Msg("Failed to start the Bot")
}
}
func run() error {
log.Logger = log.Output(zerolog.ConsoleWriter{Out: os.Stderr})
zerolog.SetGlobalLevel(zerolog.InfoLevel) // Uncomment this line for info mode
//zerolog.SetGlobalLevel(zerolog.DebugLevel) // Uncomment this line for debug mode
log.Info().Msg("bot stats")
/*err := godotenv.Load("./.env")
if err != nil {
log.Fatal().Msg("Error loading .env file")
}*/
botToken := os.Getenv("SLACK_BOT_TOKEN")
if len(botToken) == 0 {
return fmt.Errorf("the environment variable SLACK_BOT_TOKEN must be set")
}
appToken := os.Getenv("SLACK_APP_TOKEN")
if len(appToken) == 0 {
return fmt.Errorf("the environment variable SLACK_APP_TOKEN must be set")
}
authToken := os.Getenv("GITHUB_OAUTH_TOKEN")
if len(authToken) == 0 {
return fmt.Errorf("the environment GITHUB_OAUTH_TOKEN must be set")
}
githubOrg := os.Getenv("GITHUB_ORG")
if len(githubOrg) == 0 {
return fmt.Errorf("the environment variable GITHUB_ORG must be set")
}
githubRepo := os.Getenv("GITHUB_REPO")
if len(githubRepo) == 0 {
return fmt.Errorf("the environment variable GITHUB_REPO must be set")
}
bot := NewBot(botToken)
for {
if err := bot.Start(); err != nil {
return err
}
time.Sleep(5 * time.Second)
}
}