From a6e638832224db469953488d4f6740381a856a08 Mon Sep 17 00:00:00 2001 From: Retropaint <70713407+Retropaint@users.noreply.github.com> Date: Wed, 25 Sep 2024 20:32:04 +0800 Subject: [PATCH] Color-coded attachements & link toggling (#438) Co-authored-by: Ayyan <119342035+ayn2op@users.noreply.github.com> --- cmd/messages_text.go | 6 +++++- internal/config/config.go | 4 ++++ internal/config/theme.go | 18 ++++++++++-------- 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/cmd/messages_text.go b/cmd/messages_text.go index 6436208..b9d0cef 100644 --- a/cmd/messages_text.go +++ b/cmd/messages_text.go @@ -160,7 +160,11 @@ func (mt *MessagesText) createBody(w io.Writer, m discord.Message, isReply bool) func (mt *MessagesText) createFooter(w io.Writer, m discord.Message) { for _, a := range m.Attachments { fmt.Fprintln(w) - fmt.Fprintf(w, "[%s]: %s", a.Filename, a.URL) + if cfg.ShowAttachmentLinks { + fmt.Fprintf(w, "[%s][%s]:\n%s[-]", cfg.Theme.MessagesText.AttachmentColor, a.Filename, a.URL) + } else { + fmt.Fprintf(w, "[%s][%s][-]", cfg.Theme.MessagesText.AttachmentColor, a.Filename) + } } } diff --git a/internal/config/config.go b/internal/config/config.go index 70132d3..7bf92c4 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -20,6 +20,8 @@ type Config struct { TimestampsBeforeAuthor bool `toml:"timestamps_before_author"` TimestampsFormat string `toml:"timestamps_format"` + ShowAttachmentLinks bool `toml:"show_attachment_links"` + Keys Keys `toml:"keys"` Theme Theme `toml:"theme"` } @@ -34,6 +36,8 @@ func defaultConfig() *Config { Timestamps: false, TimestampsBeforeAuthor: false, TimestampsFormat: time.Kitchen, + + ShowAttachmentLinks: true, Keys: defaultKeys(), Theme: defaultTheme(), diff --git a/internal/config/theme.go b/internal/config/theme.go index 51418e6..f665fe7 100644 --- a/internal/config/theme.go +++ b/internal/config/theme.go @@ -26,10 +26,11 @@ type ( MessagesTextTheme struct { ReplyIndicator string `toml:"reply_indicator"` - AuthorColor string `toml:"author_color"` - ContentColor string `toml:"content_color"` - EmojiColor string `toml:"emoji_color"` - LinkColor string `toml:"link_color"` + AuthorColor string `toml:"author_color"` + ContentColor string `toml:"content_color"` + EmojiColor string `toml:"emoji_color"` + LinkColor string `toml:"link_color"` + AttachmentColor string `toml:"attachment_color"` } ) @@ -52,10 +53,11 @@ func defaultTheme() Theme { MessagesText: MessagesTextTheme{ ReplyIndicator: string(tview.BoxDrawingsLightArcDownAndRight) + " ", - AuthorColor: "aqua", - ContentColor: tview.Styles.PrimaryTextColor.String(), - EmojiColor: "green", - LinkColor: "blue", + AuthorColor: "aqua", + ContentColor: tview.Styles.PrimaryTextColor.String(), + EmojiColor: "green", + LinkColor: "blue", + AttachmentColor: "yellow", }, } }