generated from xNok/slack-go-demo-socketmode
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
42 lines (31 loc) · 917 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
40
41
42
package main
import (
"h3rby7/orbo/controllers"
"h3rby7/orbo/drivers"
"os"
"github.com/joho/godotenv"
"github.com/rs/zerolog"
"github.com/rs/zerolog/log"
"github.com/slack-go/slack/socketmode"
)
func main() {
log.Logger = log.Output(zerolog.ConsoleWriter{Out: os.Stderr})
err := godotenv.Load("./test_slack.env")
if err != nil {
log.Fatal().Msg("Error loading .env file")
}
// Instanciate deps
client, err := drivers.ConnectToSlackViaSocketmode()
if err != nil {
log.Error().
Str("error", err.Error()).
Msg("Unable to connect to slack")
os.Exit(1)
}
// Inject Deps in router
socketmodeHandler := socketmode.NewSocketmodeHandler(client)
// This if for Separate articles and demos. You can run there separatly or all together
// Build Slack Slash Command in Golang Using Socket Mode
controllers.NewSlashCommandController(socketmodeHandler)
socketmodeHandler.RunEventLoop()
}