Browse Source

go fmt

pull/1/head
Sam 5 years ago
parent
commit
4f7655dfd6
  1. 57
      main.go

57
main.go

@ -12,21 +12,20 @@ import (
) )
// Configurable section // Configurable section
var downloadPath = "/tmp/" var downloadPath = "/tmp/"
var outputFormat = "┌──[$USER@$DEVICE] [$ID] [$DATE - $TIME]\n└╼ $MSG" var outputFormat = "┌──[$USER@$DEVICE] [$ID] [$DATE - $TIME]\n└╼ $MSG"
// 02 = Day, Jan = Month, 06 = Year // 02 = Day, Jan = Month, 06 = Year
var dateFormat = "02Jan06" var dateFormat = "02Jan06"
// 15 = hours, 04 = minutes, 05 = seconds // 15 = hours, 04 = minutes, 05 = seconds
var timeFormat = "15:04" var timeFormat = "15:04"
// End configurable section // End configurable section
var k = keybase.NewKeybase() var k = keybase.NewKeybase()
var channel keybase.Channel var channel keybase.Channel
var channels [] keybase.Channel var channels []keybase.Channel
var stream = false var stream = false
var lastMessage keybase.ChatAPI var lastMessage keybase.ChatAPI
@ -75,27 +74,27 @@ func populateChat(g *gocui.Gui) {
return 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
for _, message := range api.Result.Messages { for _, message := range api.Result.Messages {
if message.Msg.Content.Type == "text" { if message.Msg.Content.Type == "text" {
if lastMessage.ID < 1 { if lastMessage.ID < 1 {
lastMessage.ID = message.Msg.ID lastMessage.ID = message.Msg.ID
}
var apiCast keybase.ChatAPI
apiCast.Msg = &message.Msg
newMessage := formatOutput(apiCast)
printMe = append(printMe, newMessage)
} }
var apiCast keybase.ChatAPI
apiCast.Msg = &message.Msg
newMessage := formatOutput(apiCast)
printMe = append(printMe, newMessage)
} }
for i := len(printMe) - 1; i >= 0; i-- { }
actuallyPrintMe += printMe[i] for i := len(printMe) - 1; i >= 0; i-- {
if i > 0 { actuallyPrintMe += printMe[i]
actuallyPrintMe += "\n" if i > 0 {
} actuallyPrintMe += "\n"
} }
printToView(g, "Chat", actuallyPrintMe) }
printToView(g, "Chat", actuallyPrintMe)
} }
@ -103,7 +102,7 @@ func sendChat(message string, g *gocui.Gui) {
chat := k.NewChat(channel) chat := k.NewChat(channel)
_, err := chat.Send(message) _, err := chat.Send(message)
if err != nil { if err != nil {
printToView(g,"Feed",fmt.Sprintf("There was an error %+v", err)) printToView(g, "Feed", fmt.Sprintf("There was an error %+v", err))
} }
} }
func formatOutput(api keybase.ChatAPI) string { func formatOutput(api keybase.ChatAPI) string {
@ -318,14 +317,14 @@ func handleMessage(api keybase.ChatAPI, g *gocui.Gui) {
} }
} }
if api.Msg.Channel.MembersType == channel.MembersType && cleanChannelName(api.Msg.Channel.Name) == channel.Name { if api.Msg.Channel.MembersType == channel.MembersType && cleanChannelName(api.Msg.Channel.Name) == channel.Name {
if channel.MembersType == keybase.TEAM && channel.TopicName != api.Msg.Channel.TopicName { if channel.MembersType == keybase.TEAM && channel.TopicName != api.Msg.Channel.TopicName {
// Do nothing, wrong channel // Do nothing, wrong channel
} else { } else {
printToView(g, "Chat", formatOutput(api)) printToView(g, "Chat", formatOutput(api))
chat := k.NewChat(channel) chat := k.NewChat(channel)
lastMessage.ID = api.Msg.ID lastMessage.ID = api.Msg.ID
chat.Read(api.Msg.ID) chat.Read(api.Msg.ID)
} }
} }
@ -421,7 +420,7 @@ func handleInput(g *gocui.Gui) error {
if len(command) == 3 { if len(command) == 3 {
reactToMessageId(command[1], command[2]) reactToMessageId(command[1], command[2])
} else { } else {
printToView(g,"Feed","/r $messageId $desiredReaction") printToView(g, "Feed", "/r $messageId $desiredReaction")
} }
default: default:
if inputString[:1] == "+" { if inputString[:1] == "+" {

Loading…
Cancel
Save