Browse Source

Auto general teams

pull/1/head
Gregory Rudolph 5 years ago
parent
commit
314461f5e6
Signed by: rudi
GPG Key ID: EF64F3CBD1A1EBDD
  1. 21
      main.go

21
main.go

@ -51,9 +51,24 @@ func populateChat(g *gocui.Gui) {
lastMessage.ID = 0 lastMessage.ID = 0
chat := k.NewChat(channel) chat := k.NewChat(channel)
maxX, _ := g.Size() maxX, _ := g.Size()
if api, err := chat.Read(maxX / 2); err != nil { api, err := chat.Read(maxX / 2)
if err != nil {
for _, testChan := range channels {
if channel.Name == testChan.Name {
channel = testChan
channel.TopicName = "general"
}
}
chat = k.NewChat(channel)
_, err2 := chat.Read(2)
if err2 != nil {
printToView(g, "Feed", fmt.Sprintf("%+v", err)) printToView(g, "Feed", fmt.Sprintf("%+v", err))
return
} else { } else {
go populateChat(g)
return
}
}
var printMe []string var printMe []string
var actuallyPrintMe string var actuallyPrintMe string
lastMessage.ID = api.Result.Messages[0].Msg.ID lastMessage.ID = api.Result.Messages[0].Msg.ID
@ -75,7 +90,7 @@ func populateChat(g *gocui.Gui) {
} }
} }
printToView(g, "Chat", actuallyPrintMe) printToView(g, "Chat", actuallyPrintMe)
}
} }
func sendChat(message string) { func sendChat(message string) {
@ -120,12 +135,14 @@ func populateList(g *gocui.Gui) {
if testVar, err := k.ChatList(); err != nil { if testVar, err := k.ChatList(); err != nil {
log.Printf("%+v", err) log.Printf("%+v", err)
} else { } else {
clearView(g, "List") clearView(g, "List")
var recentPMs = "---[PMs]---\n" var recentPMs = "---[PMs]---\n"
var recentPMsCount = 0 var recentPMsCount = 0
var recentChannels = "---[Teams]---\n" var recentChannels = "---[Teams]---\n"
var recentChannelsCount = 0 var recentChannelsCount = 0
for _, s := range testVar.Result.Conversations { for _, s := range testVar.Result.Conversations {
channels = append(channels, s.Channel)
if s.Channel.MembersType == keybase.TEAM { if s.Channel.MembersType == keybase.TEAM {
recentChannelsCount++ recentChannelsCount++
if recentChannelsCount <= ((maxY - 2) / 3) { if recentChannelsCount <= ((maxY - 2) / 3) {

Loading…
Cancel
Save