-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
51 lines (44 loc) · 1.01 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
51
package main
import (
"log"
"os"
"strings"
"github.com/Scrin/siikabot/bot"
)
func main() {
homeserverURL := ""
userID := ""
accessToken := ""
hookSecret := ""
dataPath := ""
admin := ""
for _, e := range os.Environ() {
split := strings.SplitN(e, "=", 2)
switch split[0] {
case "SIIKABOT_HOMESERVER_URL":
homeserverURL = split[1]
case "SIIKABOT_USER_ID":
userID = split[1]
case "SIIKABOT_ACCESS_TOKEN":
accessToken = split[1]
case "SIIKABOT_HOOK_SECRET":
hookSecret = split[1]
case "SIIKABOT_DATA_PATH":
dataPath = split[1]
case "SIIKABOT_ADMIN":
admin = split[1]
}
}
if len(os.Args) > 6 {
homeserverURL = os.Args[1]
userID = os.Args[2]
accessToken = os.Args[3]
hookSecret = os.Args[4]
dataPath = os.Args[5]
admin = os.Args[6]
}
if homeserverURL == "" || userID == "" || accessToken == "" || hookSecret == "" || dataPath == "" || admin == "" {
log.Fatal("invalid config")
}
log.Fatal(bot.Run(homeserverURL, userID, accessToken, hookSecret, dataPath, admin))
}