-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
39 lines (31 loc) · 857 Bytes
/
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
package main
import (
"os"
"github.com/evandroflores/claimr/cmd"
"github.com/evandroflores/claimr/database"
"github.com/evandroflores/claimr/model"
"github.com/shomali11/slacker"
log "github.com/sirupsen/logrus"
)
func main() {
log.SetLevel(log.InfoLevel)
token := os.Getenv("CLAIMR_TOKEN")
if token == "" {
log.Fatal("Claimr slack bot token unset. Set CLAIMR_TOKEN to continue.")
}
bot := slacker.NewClient(token)
log.Debug("Loading commands...")
for _, command := range cmd.CommandList() {
log.Infof("%s - %s", command.Usage, command.Description)
bot.Command(command.Usage, command.Description, command.Handler)
}
bot.Default(cmd.Default)
bot.Help(cmd.Help)
log.Infof("Commands loaded. (%d)", len(cmd.CommandList()))
model.LoadAdmins(bot)
err := bot.Listen()
if err != nil {
log.Fatal(err)
}
defer database.Close()
}