-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.go
50 lines (37 loc) · 1.19 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
46
47
48
49
50
package main
import (
"flag"
"log"
)
func main() {
port := 0
forceManage := false
flag.IntVar(&port, "port", 4532, "The port to run the management interface on.")
flag.BoolVar(&forceManage, "manage", false, "Force running the management interface, even if it's not needed.")
flag.StringVar(&API_MHS_ClientID, "mhs-client", "", "The client ID for MyHomeworkSpace.")
flag.StringVar(&API_Slack_ClientID, "slack-client-id", "", "The client ID for Slack.")
flag.StringVar(&API_Slack_ClientSecret, "slack-client-secret", "", "The client secret for Slack.")
flag.Parse()
log.Println("slack-status-bot")
if API_MHS_ClientID == "" {
log.Println("Please specify a MyHomeworkSpace client ID.")
return
}
if API_Slack_ClientID == "" || API_Slack_ClientSecret == "" {
log.Println("Please specify a Slack client ID and secret.")
return
}
Storage_Init()
API_MHS_Init()
API_Slack_Init()
needToManage := !Bot_CanActivate()
if forceManage || needToManage {
if needToManage {
log.Println("Some services aren't connected, starting management UI...")
}
log.Printf("Visit http://localhost:%d/ in your browser.", port)
Management_Init(port)
}
log.Println("Starting bot!")
Bot_Start()
}