|
|
@@ -126,7 +126,11 @@ func (mt *MessagesText) createMsg(msg discord.Message) {
|
|
|
|
|
|
switch msg.Type {
|
|
|
case discord.DefaultMessage:
|
|
|
- mt.createDefaultMsg(msg)
|
|
|
+ if msg.Reference != nil && msg.Reference.Type == discord.MessageReferenceTypeForward {
|
|
|
+ mt.createForwardedMsg(msg)
|
|
|
+ } else {
|
|
|
+ mt.createDefaultMsg(msg)
|
|
|
+ }
|
|
|
case discord.InlinedReplyMessage:
|
|
|
mt.createReplyMsg(msg)
|
|
|
|
|
|
@@ -141,9 +145,12 @@ func (mt *MessagesText) createMsg(msg discord.Message) {
|
|
|
fmt.Fprintln(mt)
|
|
|
}
|
|
|
|
|
|
+func (mt *MessagesText) formatTimestamp(ts discord.Timestamp) string {
|
|
|
+ return ts.Time().In(time.Local).Format(mt.cfg.Timestamps.Format)
|
|
|
+}
|
|
|
+
|
|
|
func (mt *MessagesText) drawTimestamps(ts discord.Timestamp) {
|
|
|
- time := ts.Time().In(time.Local).Format(mt.cfg.Timestamps.Format)
|
|
|
- fmt.Fprintf(mt, "[::d]%s[::D] ", time)
|
|
|
+ fmt.Fprintf(mt, "[::d]%s[::D] ", mt.formatTimestamp(ts))
|
|
|
}
|
|
|
|
|
|
func (mt *MessagesText) drawAuthor(msg discord.Message) {
|
|
|
@@ -158,6 +165,12 @@ func (mt *MessagesText) drawContent(msg discord.Message) {
|
|
|
markdown.DefaultRenderer.Render(mt, c, ast)
|
|
|
}
|
|
|
|
|
|
+func (mt *MessagesText) drawSnapshotContent(msg discord.MessageSnapshotMessage) {
|
|
|
+ c := []byte(tview.Escape(msg.Content))
|
|
|
+ // discordmd doesn't support MessageSnapshotMessage, so we just use write it as is. todo?
|
|
|
+ mt.Write(c)
|
|
|
+}
|
|
|
+
|
|
|
func (mt *MessagesText) createDefaultMsg(msg discord.Message) {
|
|
|
if mt.cfg.Timestamps.Enabled {
|
|
|
mt.drawTimestamps(msg.Timestamp)
|
|
|
@@ -206,6 +219,14 @@ func (mt *MessagesText) authorName(user discord.User, gID discord.GuildID) strin
|
|
|
return name
|
|
|
}
|
|
|
|
|
|
+func (mt *MessagesText) createForwardedMsg(msg discord.Message) {
|
|
|
+ mt.drawTimestamps(msg.Timestamp)
|
|
|
+ mt.drawAuthor(msg)
|
|
|
+ fmt.Fprintf(mt, "[::d]%s [::-]", mt.cfg.Theme.MessagesText.ForwardedIndicator)
|
|
|
+ mt.drawSnapshotContent(msg.MessageSnapshots[0].Message)
|
|
|
+ fmt.Fprintf(mt, " [::d](%s)[-:-:-] ", mt.formatTimestamp(msg.MessageSnapshots[0].Message.Timestamp))
|
|
|
+}
|
|
|
+
|
|
|
func (mt *MessagesText) authorColor(user discord.User, gID discord.GuildID) string {
|
|
|
color := mt.cfg.Theme.MessagesText.AuthorColor
|
|
|
if app.cfg.Theme.MessagesText.ShowUsernameColors && gID.IsValid() {
|