-
Notifications
You must be signed in to change notification settings - Fork 14
/
slack.go
39 lines (31 loc) · 804 Bytes
/
slack.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 (
"fmt"
"github.com/nlopes/slack"
)
var (
apiToken = ""
)
// this is for testing.
func startSlackConnection() {
var (
postAsUserName string
postAsUserID string
postToUserName string
postToUserID string
postToChannelID string
)
api := slack.New(apiToken)
authTest, err := api.AuthTest()
if err != nil {
fmt.Printf("Error getting channels: %s\n", err)
return
}
// Post as the authenticated user.
postAsUserName = authTest.User
postAsUserID = authTest.UserID
// Posting to DM with self causes a conversation with slackbot.
postToUserName = authTest.User
postToUserID = authTest.UserID
Log.Info(fmt.Sprintf("Posting as %s (%s) in DM with %s (%s), channel %s\n", postAsUserName, postAsUserID, postToUserName, postToUserID, postToChannelID))
}