refactor(util): merge linebreak with .WriteString()

This commit is contained in:
rigormorrtiss 2021-08-07 18:34:04 +04:00
parent 3df9adabb3
commit 0bee19a27c

View file

@ -12,15 +12,17 @@ import (
func WriteMessage(v *tview.TextView, s *state.State, m discord.Message) {
var b strings.Builder
// > AUTHOR_USERNAME MESSAGE_CONTENT
// $ ╭ AUTHOR_USERNAME MESSAGE_CONTENT*linebreak*
writeReferencedMessage(&b, m.ReferencedMessage)
// AUTHOR_USERNAME MESSAGE_CONTENT
// $ AUTHOR_USERNAME (BOT)*space*
writeAuthor(&b, s, m.Author)
// $ MESSAGE_CONTENT
if m.Content != "" {
b.WriteString(m.Content)
}
// $ *space*(edited)
if m.EditedTimestamp.IsValid() {
b.WriteString(" [::d](edited)[-:-:-]")
}
@ -30,6 +32,7 @@ func WriteMessage(v *tview.TextView, s *state.State, m discord.Message) {
b.WriteString("\n<EMBED(S)>")
}
// $ *linebreak*ATTACHMENT_URL
writeAttachments(&b, m.Attachments)
fmt.Fprintln(v, b.String())
@ -66,7 +69,6 @@ func writeReferencedMessage(b *strings.Builder, rm *discord.Message) {
b.WriteString("[-:-:] ")
b.WriteString(rm.Content)
b.WriteString("\n")
b.WriteString("[-:-:-]")
b.WriteString("\n[-:-:-]")
}
}