From 5db54c9934e176560c28317f9ab7b28bda6e6961 Mon Sep 17 00:00:00 2001 From: David Haukeness Date: Wed, 16 Oct 2019 13:17:51 -0600 Subject: [PATCH] updated to pull channel members --- main.go | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/main.go b/main.go index ead1e46..781c509 100644 --- a/main.go +++ b/main.go @@ -221,6 +221,30 @@ func populateList() { } } +func getCurrentChannelMembership() []string { + var rs []string + if channel.Name != "" { + t := k.NewTeam(channel.Name) + if testVar, err := t.MemberList(); err != nil { + printToView("Feed", fmt.Sprintf("Error getting member list - %+v", err)) + } else { + for _, m := range testVar.Result.Members.Owners { + rs = append(rs, fmt.Sprintf("%+v", m.Username)) + } + for _, m := range testVar.Result.Members.Admins { + rs = append(rs, fmt.Sprintf("%+v", m.Username)) + } + for _, m := range testVar.Result.Members.Writers { + rs = append(rs, fmt.Sprintf("%+v", m.Username)) + } + for _, m := range testVar.Result.Members.Readers { + rs = append(rs, fmt.Sprintf("%+v", m.Username)) + } + } + } + return rs +} + func filterStringSlice(ss []string, fv string) []string { var rs []string for _, s := range ss { @@ -307,6 +331,11 @@ func generateChannelTabCompletionSlice(inputWord string) []string { firstSlice = appendIfNotInSlice(firstSlice, cleanChannelName(s.Name)) } } + // next fetch all members of the current channel and add them to the slice + secondSlice := getCurrentChannelMembership() + for _, m := range secondSlice { + firstSlice = appendIfNotInSlice(firstSlice, m) + } // now return the resultSlice which contains all that are prefixed with inputWord resultSlice := filterStringSlice(firstSlice, inputWord) return resultSlice