-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
63 lines (49 loc) · 1.14 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
52
53
54
55
56
57
58
59
60
61
62
63
package main
import (
"log"
"os"
"github.com/traP-jp/members_bot/handler"
repoimpl "github.com/traP-jp/members_bot/repository/impl"
"github.com/traP-jp/members_bot/repository/impl/schema"
"github.com/traP-jp/members_bot/service/impl"
traqwsbot "github.com/traPtitech/traq-ws-bot"
)
func main() {
botToken, ok := os.LookupEnv("TRAQ_BOT_TOKEN")
if !ok {
panic("TRAQ_BOT_TOKEN is not set")
}
orgName, ok := os.LookupEnv("GITHUB_ORG_NAME")
if !ok {
panic("GITHUB_ORG_NAME is not set")
}
bot, err := traqwsbot.NewBot(&traqwsbot.Options{
AccessToken: botToken,
})
if err != nil {
panic(err)
}
tc := impl.NewTraq(bot.API())
gh, err := impl.NewGitHub(orgName)
if err != nil {
panic(err)
}
db, err := repoimpl.NewDB()
if err != nil {
panic(err)
}
if err := schema.Migrate(db); err != nil {
panic(err)
}
ir := repoimpl.NewInvitation(db)
bh, err := handler.NewBotHandler(tc, gh, ir)
if err != nil {
panic(err)
}
bot.OnError(func(message string) {
log.Println("Received ERROR message: " + message)
})
bot.OnMessageCreated(bh.MessageCreated)
bot.OnBotMessageStampsUpdated(bh.AcceptOrReject)
log.Fatal(bot.Start())
}