mirror of
https://github.com/Rudi9719/kbtui.git
synced 2026-03-22 13:17:23 +00:00
Progress on wall
This commit is contained in:
23
cmdWall.go
23
cmdWall.go
@ -4,6 +4,8 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
"samhofi.us/x/keybase"
|
"samhofi.us/x/keybase"
|
||||||
)
|
)
|
||||||
@ -27,7 +29,12 @@ func cmdPopulateWall(cmd []string) {
|
|||||||
var requestedUsers string
|
var requestedUsers string
|
||||||
var printMe []string
|
var printMe []string
|
||||||
var actuallyPrintMe string
|
var actuallyPrintMe string
|
||||||
|
start := time.Now()
|
||||||
if len(cmd) > 1 {
|
if len(cmd) > 1 {
|
||||||
|
if cmd[1] == "!all" {
|
||||||
|
go cmdAllWall()
|
||||||
|
return
|
||||||
|
}
|
||||||
for _, username := range cmd[1:] {
|
for _, username := range cmd[1:] {
|
||||||
requestedUsers += fmt.Sprintf("%s ", username)
|
requestedUsers += fmt.Sprintf("%s ", username)
|
||||||
var newChan keybase.Channel
|
var newChan keybase.Channel
|
||||||
@ -43,7 +50,8 @@ func cmdPopulateWall(cmd []string) {
|
|||||||
requestedUsers += cleanChannelName(channel.Name)
|
requestedUsers += cleanChannelName(channel.Name)
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
printToView("Feed", fmt.Sprintf("Error, can't run wall in teams", channel.MembersType))
|
printToView("Feed", fmt.Sprintf("Error, can't run wall in teams"))
|
||||||
|
go cmdAllWall()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if len(users) < 1 {
|
if len(users) < 1 {
|
||||||
@ -54,9 +62,10 @@ func cmdPopulateWall(cmd []string) {
|
|||||||
chat := k.NewChat(chann)
|
chat := k.NewChat(chann)
|
||||||
api, err := chat.Read()
|
api, err := chat.Read()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
if len(users) < 6 {
|
||||||
printToView("Feed", fmt.Sprintf("There was an error for user %s: %+v", cleanChannelName(chann.Name), err))
|
printToView("Feed", fmt.Sprintf("There was an error for user %s: %+v", cleanChannelName(chann.Name), err))
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
for _, message := range api.Result.Messages {
|
for _, message := range api.Result.Messages {
|
||||||
if message.Msg.Content.Type == "text" {
|
if message.Msg.Content.Type == "text" {
|
||||||
var apiCast keybase.ChatAPI
|
var apiCast keybase.ChatAPI
|
||||||
@ -65,6 +74,7 @@ func cmdPopulateWall(cmd []string) {
|
|||||||
printMe = append(printMe, newMessage)
|
printMe = append(printMe, newMessage)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
for i := len(printMe) - 1; i >= 0; i-- {
|
for i := len(printMe) - 1; i >= 0; i-- {
|
||||||
@ -73,5 +83,14 @@ func cmdPopulateWall(cmd []string) {
|
|||||||
actuallyPrintMe += "\n"
|
actuallyPrintMe += "\n"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
printToView("Chat", fmt.Sprintf("\nWall:\n%s\n", actuallyPrintMe))
|
printToView("Chat", fmt.Sprintf("\nWall:\n%s\n", actuallyPrintMe))
|
||||||
|
time.Sleep(1 * time.Millisecond)
|
||||||
|
printToView("Chat", fmt.Sprintf("Your wall query took %s", time.Since(start)))
|
||||||
|
}
|
||||||
|
func cmdAllWall() {
|
||||||
|
bytes, _ := k.Exec("list-following")
|
||||||
|
bigString := string(bytes)
|
||||||
|
following := strings.Split(bigString, "\n")
|
||||||
|
go cmdPopulateWall(following)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user