mirror of
https://github.com/Rudi9719/kbtui.git
synced 2026-03-22 11:07:22 +00:00
Happy populate
This commit is contained in:
11
main.go
11
main.go
@ -36,20 +36,25 @@ func main() {
|
||||
}
|
||||
}
|
||||
func populateChat(g *gocui.Gui) {
|
||||
xMax, _ := g.Size()
|
||||
chat := k.NewChat(channel)
|
||||
if api, err := chat.Read(xMax/5); err != nil {
|
||||
if api, err := chat.Read(15); err != nil {
|
||||
log.Fatal(err)
|
||||
} else {
|
||||
var printMe []string
|
||||
for _, message := range api.Result.Messages {
|
||||
if message.Msg.Content.Type == "text" {
|
||||
msgSender := message.Msg.Sender.Username
|
||||
msgBody := message.Msg.Content.Text.Body
|
||||
printToView(g, "Chat", fmt.Sprintf("%s: %s", msgSender, msgBody))
|
||||
newMessage := fmt.Sprintf("%s: %s", msgSender, msgBody)
|
||||
printMe = append(printMe, newMessage)
|
||||
}
|
||||
}
|
||||
for i := len(printMe) - 1; i >= 0; i-- {
|
||||
printToView(g, "Chat", printMe[i])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func sendChat(message string) {
|
||||
chat := k.NewChat(channel)
|
||||
chat.Send(message)
|
||||
|
||||
Reference in New Issue
Block a user