Browse Source

upstream merge

pull/34/head
David Haukeness 5 years ago
parent
commit
299f5103a5
No known key found for this signature in database
GPG Key ID: A7F1091956853EF9
  1. 2
      .travis.yml
  2. 13
      README.md
  3. 3
      cmdClean.go
  4. 21
      cmdDownload.go
  5. 29
      cmdEdit.go
  6. 2
      cmdHelp.go
  7. 12
      cmdReact.go
  8. 66
      cmdSet.go
  9. 30
      kbtui.tml
  10. 29
      mage.go
  11. 59
      main.go
  12. 99
      tabComplete.go

2
.travis.yml

@ -7,8 +7,6 @@ go:
install: true install: true
script: script:
- go get -u samhofi.us/x/keybase
- go get -u github.com/awesome-gocui/gocui
- go get -u github.com/magefile/mage/mage - go get -u github.com/magefile/mage/mage
- go run build.go buildBeta - go run build.go buildBeta
- go vet ./... - go vet ./...

13
README.md

@ -31,16 +31,9 @@ go get -u github.com/rudi9719/kbtui
``` ```
Or you can do the following: Or you can do the following:
``` ```
go get ./... go get github.com/magefile/mage/mage
go run build.go
go run build.go {build, buildBeta... etc} go run build.go {build, buildBeta... etc}
./kbtui ./kbtui
``` ```
Mage is a requirement for building `kbtui` as it will automatically handle/manage imports as well as mage is used to generate the
You may see an error with `go get ./...` about PATHs, that may be safely ignored. file for emoji completion.
If you see an error about a missing dependancy during a build, you'll want to resolve that.
Occasionally when [@dxb](https://keybase.io/dxb) updates his API it will be necessary to run
`go get -u ./...` or `go get -u samhofi.us/x/keybase`

3
cmdClean.go

@ -15,6 +15,7 @@ func init() {
func cmdClean(cmd []string) { func cmdClean(cmd []string) {
clearView("Chat") clearView("Chat")
clearView("List")
go populateChat() go populateChat()
go populateList()
} }

21
cmdDownload.go

@ -24,16 +24,29 @@ func cmdDownloadFile(cmd []string) {
printToView("Feed", fmt.Sprintf("%s%s $messageId $fileName - Download a file to user's downloadpath", cmdPrefix, cmd[0])) printToView("Feed", fmt.Sprintf("%s%s $messageId $fileName - Download a file to user's downloadpath", cmdPrefix, cmd[0]))
return return
} }
messageID, _ := strconv.Atoi(cmd[1]) messageID, err := strconv.Atoi(cmd[1])
if err != nil {
printToView("Feed", "There was an error converting your messageID to an int")
return
}
chat := k.NewChat(channel)
api, err := chat.ReadMessage(messageID)
if err != nil {
printToView("Feed", fmt.Sprintf("There was an error pulling message %d", messageID))
return
}
if api.Result.Messages[0].Msg.Content.Type != "attachment" {
printToView("Feed", "No attachment detected")
return
}
var fileName string var fileName string
if len(cmd) == 3 { if len(cmd) == 3 {
fileName = cmd[2] fileName = cmd[2]
} else { } else {
fileName = "" fileName = api.Result.Messages[0].Msg.Content.Attachment.Object.Filename
} }
chat := k.NewChat(channel) _, err = chat.Download(messageID, fmt.Sprintf("%s/%s", downloadPath, fileName))
_, err := chat.Download(messageID, fmt.Sprintf("%s/%s", downloadPath, fileName))
if err != nil { if err != nil {
printToView("Feed", fmt.Sprintf("There was an error downloading %s from %s", fileName, channel.Name)) printToView("Feed", fmt.Sprintf("There was an error downloading %s from %s", fileName, channel.Name))
} else { } else {

29
cmdEdit.go

@ -11,7 +11,7 @@ import (
func init() { func init() {
command := Command{ command := Command{
Cmd: []string{"edit", "e"}, Cmd: []string{"edit", "e"},
Description: "$messageId - Edit a message (messageID is optional)", Description: "$messageID - Edit a message (messageID is optional)",
Help: "", Help: "",
Exec: cmdEdit, Exec: cmdEdit,
} }
@ -20,16 +20,22 @@ func init() {
} }
func cmdEdit(cmd []string) { func cmdEdit(cmd []string) {
var messageId int var messageID int
chat := k.NewChat(channel) chat := k.NewChat(channel)
if len(cmd) == 2 || len(cmd) == 1 { if len(cmd) == 2 || len(cmd) == 1 {
if len(cmd) == 2 { if len(cmd) == 2 {
messageId, _ = strconv.Atoi(cmd[1]) messageID, _ = strconv.Atoi(cmd[1])
} else if lastMessage.ID != 0 {
if lastMessage.Type != "text" {
printToView("Feed", "Last message isn't editable (is it an edit?)")
return
}
messageID = lastMessage.ID
} else { } else {
messageId = lastMessage.ID printToView("Feed", "No message to edit")
return
} }
origMessage, _ := chat.ReadMessage(messageID)
origMessage, _ := chat.ReadMessage(messageId)
if origMessage.Result.Messages[0].Msg.Content.Type != "text" { if origMessage.Result.Messages[0].Msg.Content.Type != "text" {
printToView("Feed", fmt.Sprintf("%+v", origMessage)) printToView("Feed", fmt.Sprintf("%+v", origMessage))
return return
@ -41,19 +47,20 @@ func cmdEdit(cmd []string) {
editString := origMessage.Result.Messages[0].Msg.Content.Text.Body editString := origMessage.Result.Messages[0].Msg.Content.Text.Body
clearView("Edit") clearView("Edit")
popupView("Edit") popupView("Edit")
printToView("Edit", fmt.Sprintf("/e %d %s", messageId, editString)) printToView("Edit", fmt.Sprintf("/e %d %s", messageID, editString))
setViewTitle("Edit", fmt.Sprintf(" Editing message %d ", messageId)) setViewTitle("Edit", fmt.Sprintf(" Editing message %d ", messageID))
moveCursorToEnd("Edit")
return return
} }
if len(cmd) < 3 { if len(cmd) < 3 {
printToView("Feed", "Not enough options for Edit") printToView("Feed", "Not enough options for Edit")
return return
} }
messageId, _ = strconv.Atoi(cmd[1]) messageID, _ = strconv.Atoi(cmd[1])
newMessage := strings.Join(cmd[2:], " ") newMessage := strings.Join(cmd[2:], " ")
_, err := chat.Edit(messageId, newMessage) _, err := chat.Edit(messageID, newMessage)
if err != nil { if err != nil {
printToView("Feed", fmt.Sprintf("Error editing message %d, %+v", messageId, err)) printToView("Feed", fmt.Sprintf("Error editing message %d, %+v", messageID, err))
} }
} }

2
cmdHelp.go

@ -28,7 +28,7 @@ func cmdHelp(cmd []string) {
helpText = fmt.Sprintf("%s%s%s\t\t%s\n", helpText, cmdPrefix, c, commands[c].Description) helpText = fmt.Sprintf("%s%s%s\t\t%s\n", helpText, cmdPrefix, c, commands[c].Description)
} }
if len(typeCommands) > 0 { if len(typeCommands) > 0 {
for c, _ := range typeCommands { for c := range typeCommands {
tCommands = append(tCommands, typeCommands[c].Name) tCommands = append(tCommands, typeCommands[c].Name)
} }
sort.Strings(tCommands) sort.Strings(tCommands)

12
cmdReact.go

@ -10,7 +10,7 @@ import (
func init() { func init() {
command := Command{ command := Command{
Cmd: []string{"react", "r", "+"}, Cmd: []string{"react", "r", "+"},
Description: "$messageId $reaction - React to a message (messageID is optional)", Description: "$messageID $reaction - React to a message (messageID is optional)",
Help: "", Help: "",
Exec: cmdReact, Exec: cmdReact,
} }
@ -20,7 +20,7 @@ func init() {
func cmdReact(cmd []string) { func cmdReact(cmd []string) {
if len(cmd) > 2 { if len(cmd) > 2 {
reactToMessageId(cmd[1], strings.Join(cmd[2:], " ")) reactToMessageID(cmd[1], strings.Join(cmd[2:], " "))
} else if len(cmd) == 2 { } else if len(cmd) == 2 {
reactToMessage(cmd[1]) reactToMessage(cmd[1])
} }
@ -30,13 +30,13 @@ func cmdReact(cmd []string) {
func reactToMessage(reaction string) { func reactToMessage(reaction string) {
doReact(lastMessage.ID, reaction) doReact(lastMessage.ID, reaction)
} }
func reactToMessageId(messageId string, reaction string) { func reactToMessageID(messageID string, reaction string) {
ID, _ := strconv.Atoi(messageId) ID, _ := strconv.Atoi(messageID)
doReact(ID, reaction) doReact(ID, reaction)
} }
func doReact(messageId int, reaction string) { func doReact(messageID int, reaction string) {
chat := k.NewChat(channel) chat := k.NewChat(channel)
_, err := chat.React(messageId, reaction) _, err := chat.React(messageID, reaction)
if err != nil { if err != nil {
printToView("Feed", "There was an error reacting to the message.") printToView("Feed", "There was an error reacting to the message.")
} }

66
cmdSet.go

@ -5,6 +5,8 @@ package main
import ( import (
"fmt" "fmt"
"strings" "strings"
"github.com/pelletier/go-toml"
) )
func init() { func init() {
@ -17,30 +19,33 @@ func init() {
RegisterCommand(command) RegisterCommand(command)
} }
func printSetting(cmd []string) {
switch cmd[1] {
case "load":
loadFromToml()
case "downloadPath":
printToView("Feed", fmt.Sprintf("Setting for %s -> %s", cmd[1], downloadPath))
case "outputFormat":
printToView("Feed", fmt.Sprintf("Setting for %s -> %s", cmd[1], outputFormat))
case "dateFormat":
printToView("Feed", fmt.Sprintf("Setting for %s -> %s", cmd[1], dateFormat))
case "timeFormat":
printToView("Feed", fmt.Sprintf("Setting for %s -> %s", cmd[1], timeFormat))
case "cmdPrefix":
printToView("Feed", fmt.Sprintf("Setting for %s -> %s", cmd[1], cmdPrefix))
default:
printToView("Feed", fmt.Sprintf("Unknown config value %s", cmd[1]))
}
return
}
func cmdSet(cmd []string) { func cmdSet(cmd []string) {
if len(cmd) < 2 { if len(cmd) < 2 {
printToView("Feed", "No config value specified") printToView("Feed", "No config value specified")
return return
} }
if len(cmd) < 3 { if len(cmd) < 3 {
switch cmd[1] { printSetting(cmd)
case "load":
printToView("Feed", "Load values from file?")
case "downloadPath":
printToView("Feed", fmt.Sprintf("Setting for %s -> %s", cmd[1], downloadPath))
case "outputFormat":
printToView("Feed", fmt.Sprintf("Setting for %s -> %s", cmd[1], outputFormat))
case "dateFormat":
printToView("Feed", fmt.Sprintf("Setting for %s -> %s", cmd[1], dateFormat))
case "timeFormat":
printToView("Feed", fmt.Sprintf("Setting for %s -> %s", cmd[1], timeFormat))
case "cmdPrefix":
printToView("Feed", fmt.Sprintf("Setting for %s -> %s", cmd[1], cmdPrefix))
default:
printToView("Feed", fmt.Sprintf("Unknown config value %s", cmd[1]))
}
return return
} }
switch cmd[1] { switch cmd[1] {
@ -62,3 +67,30 @@ func cmdSet(cmd []string) {
} }
} }
func loadFromToml() {
printToView("Feed", fmt.Sprintf("Loading config from toml"))
config, err := toml.LoadFile("kbtui.tml")
if err != nil {
printToView("Feed", fmt.Sprintf("Could not read config file: %+v", err))
return
}
if config.Has("Basics.colorless") {
colorless = config.Get("Basics.colorless").(bool)
}
if config.Has("Basics.downloadPath") {
downloadPath = config.Get("Basics.downloadPath").(string)
}
if config.Has("Basics.cmdPrefix") {
cmdPrefix = config.Get("Basics.cmdPrefix").(string)
}
if config.Has("Formatting.outputFormat") {
outputFormat = config.Get("Formatting.outputFormat").(string)
}
if config.Has("Formatting.dateFormat") {
dateFormat = config.Get("Formatting.dateFormat").(string)
}
if config.Has("Formatting.timeFormat") {
timeFormat = config.Get("Formatting.timeFormat").(string)
}
RunCommand("clean")
}

30
kbtui.tml

@ -0,0 +1,30 @@
[Basics]
downloadPath = "/tmp/"
colorless = false
# The prefix before evaluating a command
cmdPrefix = "/"
[Formatting]
# BASH-like PS1 variable equivalent
outputFormat = "┌──[$USER@$DEVICE] [$ID] [$DATE - $TIME]\n└╼ $MSG"
# 02 = Day, Jan = Month, 06 = Year
dateFormat = "02Jan06"
# 15 = hours, 04 = minutes, 05 = seconds
timeFormat = "15:04"
[Colors]
channelsColor = 8
channelsHeaderColor = 6
noColor = -1
mentionColor = 3
messageHeaderColor = 8
messageIdColor = 7
messageTimeColor = 6
messageSenderDefaultColor = 8
messageSenderDeviceColor = 8
messageBodyColor = -1
messageAttachmentColor = 2
messageLinkColor = 4

29
mage.go

@ -4,10 +4,29 @@ package main
import ( import (
"fmt" "fmt"
"github.com/magefile/mage/sh"
"os" "os"
"github.com/magefile/mage/mg"
"github.com/magefile/mage/sh"
) )
func getRemotePackages() error {
var packages = []string{
"samhofi.us/x/keybase",
"github.com/awesome-gocui/gocui",
"github.com/magefile/mage/mage",
"github.com/magefile/mage/mg",
"github.com/magefile/mage/sh",
"github.com/pelletier/go-toml",
}
for _, p := range packages {
if err := sh.Run("go", "get", "-u", p); err != nil {
return err
}
}
return nil
}
// proper error reporting and exit code // proper error reporting and exit code
func exit(err error) { func exit(err error) {
if err != nil { if err != nil {
@ -18,6 +37,7 @@ func exit(err error) {
// Build kbtui with just the basic commands. // Build kbtui with just the basic commands.
func Build() { func Build() {
mg.Deps(getRemotePackages)
if err := sh.Run("go", "build"); err != nil { if err := sh.Run("go", "build"); err != nil {
defer func() { defer func() {
exit(err) exit(err)
@ -29,6 +49,7 @@ func Build() {
// The ShowReactions TypeCommand will print a message in the feed window when // The ShowReactions TypeCommand will print a message in the feed window when
// a reaction is received in the current conversation. // a reaction is received in the current conversation.
func BuildShowReactions() { func BuildShowReactions() {
mg.Deps(getRemotePackages)
if err := sh.Run("go", "build", "-tags", "showreactionscmd"); err != nil { if err := sh.Run("go", "build", "-tags", "showreactionscmd"); err != nil {
defer func() { defer func() {
exit(err) exit(err)
@ -41,6 +62,7 @@ func BuildShowReactions() {
// received in the current conversation. This gets pretty annoying, and // received in the current conversation. This gets pretty annoying, and
// is not recommended. // is not recommended.
func BuildAutoReact() { func BuildAutoReact() {
mg.Deps(getRemotePackages)
if err := sh.Run("go", "build", "-tags", "autoreactcmd"); err != nil { if err := sh.Run("go", "build", "-tags", "autoreactcmd"); err != nil {
defer func() { defer func() {
exit(err) exit(err)
@ -50,6 +72,7 @@ func BuildAutoReact() {
// Build kbtui with all commands and TypeCommands disabled. // Build kbtui with all commands and TypeCommands disabled.
func BuildAllCommands() { func BuildAllCommands() {
mg.Deps(getRemotePackages)
if err := sh.Run("go", "build", "-tags", "allcommands"); err != nil { if err := sh.Run("go", "build", "-tags", "allcommands"); err != nil {
defer func() { defer func() {
exit(err) exit(err)
@ -59,6 +82,7 @@ func BuildAllCommands() {
// Build kbtui with all Commands and TypeCommands enabled. // Build kbtui with all Commands and TypeCommands enabled.
func BuildAllCommandsT() { func BuildAllCommandsT() {
mg.Deps(getRemotePackages)
if err := sh.Run("go", "build", "-tags", "type_commands,allcommands"); err != nil { if err := sh.Run("go", "build", "-tags", "type_commands,allcommands"); err != nil {
defer func() { defer func() {
exit(err) exit(err)
@ -68,7 +92,8 @@ func BuildAllCommandsT() {
// Build kbtui with beta functionality // Build kbtui with beta functionality
func BuildBeta() { func BuildBeta() {
if err := sh.Run("go", "build", "-tags", "allcommands,showreactionscmd,tabcompletion"); err != nil { mg.Deps(getRemotePackages)
if err := sh.Run("go", "build", "-tags", "allcommands,showreactionscmd,emojiList,tabcompletion"); err != nil {
defer func() { defer func() {
exit(err) exit(err)
}() }()

59
main.go

@ -112,9 +112,8 @@ func initKeybindings() error {
if input != "" { if input != "" {
clearView("Input") clearView("Input")
return nil return nil
} else {
return gocui.ErrQuit
} }
return gocui.ErrQuit
}); err != nil { }); err != nil {
return err return err
} }
@ -166,9 +165,8 @@ func setViewTitle(viewName string, title string) {
updatingView, err := g.View(viewName) updatingView, err := g.View(viewName)
if err != nil { if err != nil {
return err return err
} else {
updatingView.Title = title
} }
updatingView.Title = title
return nil return nil
}) })
} }
@ -178,9 +176,9 @@ func getViewTitle(viewName string) string {
// in case there is active tab completion, filter that to just the view title and not the completion options. // in case there is active tab completion, filter that to just the view title and not the completion options.
printToView("Feed", fmt.Sprintf("Error getting view title: %s", err)) printToView("Feed", fmt.Sprintf("Error getting view title: %s", err))
return "" return ""
} else {
return strings.Split(view.Title, "||")[0]
} }
return strings.Split(view.Title, "||")[0]
} }
func popupView(viewName string) { func popupView(viewName string) {
_, err := g.SetCurrentView(viewName) _, err := g.SetCurrentView(viewName)
@ -195,10 +193,27 @@ func popupView(viewName string) {
updatingView, err := g.View(viewName) updatingView, err := g.View(viewName)
if err != nil { if err != nil {
return err return err
} else {
viewX, viewY := updatingView.Size()
updatingView.MoveCursor(viewX, viewY, true)
} }
updatingView.MoveCursor(0, 0, true)
return nil
})
}
func moveCursorToEnd(viewName string) {
g.Update(func(g *gocui.Gui) error {
inputView, err := g.View(viewName)
if err != nil {
return err
}
inputString, _ := getInputString(viewName)
stringLen := len(inputString)
maxX, _ := inputView.Size()
x := stringLen % maxX
y := stringLen / maxX
inputView.SetCursor(0, 0)
inputView.SetOrigin(0, 0)
inputView.MoveCursor(x, y, true)
return nil return nil
}) })
@ -208,11 +223,11 @@ func clearView(viewName string) {
inputView, err := g.View(viewName) inputView, err := g.View(viewName)
if err != nil { if err != nil {
return err return err
} else {
inputView.Clear()
inputView.SetCursor(0, 0)
inputView.SetOrigin(0, 0)
} }
inputView.Clear()
inputView.SetCursor(0, 0)
inputView.SetOrigin(0, 0)
return nil return nil
}) })
@ -222,11 +237,11 @@ func writeToView(viewName string, message string) {
updatingView, err := g.View(viewName) updatingView, err := g.View(viewName)
if err != nil { if err != nil {
return err return err
} else {
for _, c := range message {
updatingView.EditWrite(c)
}
} }
for _, c := range message {
updatingView.EditWrite(c)
}
return nil return nil
}) })
} }
@ -276,11 +291,11 @@ func populateChat() {
if err2 != nil { if err2 != nil {
printToView("Feed", fmt.Sprintf("%+v", err)) printToView("Feed", fmt.Sprintf("%+v", err))
return return
} else {
go populateChat()
go generateChannelTabCompletionSlice()
return
} }
go populateChat()
go generateChannelTabCompletionSlice()
return
} }
var printMe []string var printMe []string
var actuallyPrintMe string var actuallyPrintMe string
@ -366,7 +381,7 @@ func formatOutput(api keybase.ChatAPI) string {
msg = colorRegex(msg, `(https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*))`, messageLinkColor, messageBodyColor) msg = colorRegex(msg, `(https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*))`, messageLinkColor, messageBodyColor)
msg = colorText(colorReplaceMentionMe(msg, messageBodyColor), messageBodyColor, c) msg = colorText(colorReplaceMentionMe(msg, messageBodyColor), messageBodyColor, c)
if msgType == "attachment" { if msgType == "attachment" {
msg = fmt.Sprintf("%s", colorText("[Attachment]", messageAttachmentColor, c)) msg = fmt.Sprintf("%s\n%s", api.Msg.Content.Attachment.Object.Title, colorText(fmt.Sprintf("[Attachment: %s]", api.Msg.Content.Attachment.Object.Filename), messageAttachmentColor, c))
} }
user := colorUsername(api.Msg.Sender.Username, c) user := colorUsername(api.Msg.Sender.Username, c)
device := colorText(api.Msg.Sender.DeviceName, messageSenderDeviceColor, c) device := colorText(api.Msg.Sender.DeviceName, messageSenderDeviceColor, c)

99
tabComplete.go

@ -20,46 +20,46 @@ func handleTab(viewName string) error {
inputString, err := getInputString(viewName) inputString, err := getInputString(viewName)
if err != nil { if err != nil {
return err return err
}
// if you successfully get an input string, grab the last word from the string
ss := regexp.MustCompile(`[ #]`).Split(inputString, -1)
s := ss[len(ss)-1]
// create a variable in which to store the result
var resultSlice []string
// if the word starts with a : its an emoji lookup
if strings.HasPrefix(s, ":") {
resultSlice = getEmojiTabCompletionSlice(s)
} else if strings.HasPrefix(s, "/") {
generateCommandTabCompletionSlice()
s = strings.Replace(s, "/", "", 1)
resultSlice = getCommandTabCompletionSlice(s)
} else { } else {
// if you successfully get an input string, grab the last word from the string if strings.HasPrefix(s, "@") {
ss := regexp.MustCompile(`[ #]`).Split(inputString, -1) // now in case the word (s) is a mention @something, lets remove it to normalize
s := ss[len(ss)-1] s = strings.Replace(s, "@", "", 1)
// create a variable in which to store the result
var resultSlice []string
// if the word starts with a : its an emoji lookup
if strings.HasPrefix(s, ":") {
resultSlice = getEmojiTabCompletionSlice(s)
} else if strings.HasPrefix(s, "/") {
generateCommandTabCompletionSlice()
s = strings.Replace(s, "/", "", 1)
resultSlice = getCommandTabCompletionSlice(s)
} else {
if strings.HasPrefix(s, "@") {
// now in case the word (s) is a mention @something, lets remove it to normalize
s = strings.Replace(s, "@", "", 1)
}
// now call get the list of all possible cantidates that have that as a prefix
resultSlice = getChannelTabCompletionSlice(s)
} }
rLen := len(resultSlice) // now call get the list of all possible cantidates that have that as a prefix
lcp := longestCommonPrefix(resultSlice) resultSlice = getChannelTabCompletionSlice(s)
if lcp != "" { }
originalViewTitle := getViewTitle("Input") rLen := len(resultSlice)
newViewTitle := "" lcp := longestCommonPrefix(resultSlice)
if rLen >= 1 && originalViewTitle != "" { if lcp != "" {
if rLen == 1 { originalViewTitle := getViewTitle("Input")
newViewTitle = originalViewTitle newViewTitle := ""
} else if rLen <= 5 { if rLen >= 1 && originalViewTitle != "" {
newViewTitle = fmt.Sprintf("%s|| %s", originalViewTitle, strings.Join(resultSlice, " ")) if rLen == 1 {
} else if rLen > 5 { newViewTitle = originalViewTitle
newViewTitle = fmt.Sprintf("%s|| %s +%d more", originalViewTitle, strings.Join(resultSlice[:6], " "), rLen-5) } else if rLen <= 5 {
} newViewTitle = fmt.Sprintf("%s|| %s", originalViewTitle, strings.Join(resultSlice, " "))
setViewTitle(viewName, newViewTitle) } else if rLen > 5 {
remainder := stringRemainder(s, lcp) newViewTitle = fmt.Sprintf("%s|| %s +%d more", originalViewTitle, strings.Join(resultSlice[:6], " "), rLen-5)
writeToView(viewName, remainder)
} }
setViewTitle(viewName, newViewTitle)
remainder := stringRemainder(s, lcp)
writeToView(viewName, remainder)
} }
} }
return nil return nil
} }
@ -124,22 +124,23 @@ func getCurrentChannelMembership() []string {
var rs []string var rs []string
if channel.Name != "" { if channel.Name != "" {
t := k.NewTeam(channel.Name) t := k.NewTeam(channel.Name)
if testVar, err := t.MemberList(); err != nil { testVar, err := t.MemberList()
if err != nil {
return rs // then this isn't a team, its a PM or there was an error in the API call return rs // then this isn't a team, its a PM or there was an error in the API call
} 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))
}
} }
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 return rs
} }

Loading…
Cancel
Save