浏览代码

Ignore message content from color and region tags

rigormorrtiss 4 年之前
父节点
当前提交
a544c05bfe
共有 1 个文件被更改,包括 9 次插入4 次删除
  1. 9 4
      util/discord.go

+ 9 - 4
util/discord.go

@@ -17,9 +17,7 @@ func WriteMessage(v *tview.TextView, s *state.State, m discord.Message) {
 	// $ AUTHOR_USERNAME (BOT)*space*
 	writeAuthor(&b, s, m.Author)
 	// $ MESSAGE_CONTENT
-	if m.Content != "" {
-		b.WriteString(m.Content)
-	}
+	writeContent(&b, m.Content)
 
 	// $ *space*(edited)
 	if m.EditedTimestamp.IsValid() {
@@ -71,7 +69,14 @@ func writeReferencedMessage(b *strings.Builder, rm *discord.Message) {
 		// Reset foreground
 		b.WriteString("[-::] ")
 
-		b.WriteString(rm.Content)
+		writeContent(b, rm.Content)
 		b.WriteString("[-:-:-]\n")
 	}
 }
+
+func writeContent(b *strings.Builder, c string) {
+	if c != "" {
+		c = tview.Escape(c)
+		b.WriteString(c)
+	}
+}