-
Notifications
You must be signed in to change notification settings - Fork 8
/
main.go
46 lines (35 loc) · 1.13 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
package main
import (
"os"
"xnok/slack-go-demo/controllers"
"xnok/slack-go-demo/drivers"
"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.NewsSocketmodeHandler(client)
// This if for Separate articles and demos. You can run there separatly or all together
// Build a Slack App Home in Golang Using Socket Mode
controllers.NewAppHomeController(socketmodeHandler)
// Properly Welcome Users in Slack with Golang using Socket Mode
controllers.NewGreetingController(socketmodeHandler)
// Build Slack Slash Command in Golang Using Socket Mode
controllers.NewSlashCommandController(socketmodeHandler)
socketmodeHandler.RunEventLoop()
}