-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
50 lines (38 loc) · 1.1 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
package main
import (
"fmt"
"os"
"github.com/Zanda256/slack-retriever/slack"
)
func main() {
allGood := slack.ParseArgs()
if !allGood {
fmt.Println("cannot parse arguments, ChannelID and API token are both required.")
}
//Initialize rate limited http client
c := slack.NewClient()
//Initialize elasticsearch Client
// es7, err := slack.NewESClient()
// checkError(err)
myFetcher := slack.NewFetcher("slack", "1.0", c, slack.Archives, 0)
channelInfo, err := myFetcher.GetChannelInfo()
checkError(err)
fmt.Printf("channelInfo: %+v\n", channelInfo)
if channelInfo["arch"] == true && slack.Archives == false {
fmt.Printf("Channel %s is archived. Set Archives option to true to fetch messages", slack.ChID)
}
p := &slack.MsgHistParams{}
numChannelMembers, err := slack.GetChannelMembers(myFetcher, p)
checkError(err)
fmt.Printf("Num Members: %d\n", numChannelMembers)
channelInfo["numMembers"] = numChannelMembers
msgs := make([]slack.RawMsg, 0)
msgs, _ = slack.GetMsgHistory(myFetcher, p)
fmt.Println(msgs)
}
func checkError(err error) {
if err != nil {
fmt.Println(err)
os.Exit(1)
}
}