From 284853dc4ab9f3fc06301ed2b6cca069b0032048 Mon Sep 17 00:00:00 2001 From: ayn2op Date: Wed, 30 Apr 2025 13:25:12 -0400 Subject: [PATCH] feat(config): move Timestamps & TimestampsFormat to its own table --- cmd/messages_text.go | 4 ++-- internal/config/config.go | 15 ++++++++++----- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/cmd/messages_text.go b/cmd/messages_text.go index de1a079..5a67837 100644 --- a/cmd/messages_text.go +++ b/cmd/messages_text.go @@ -128,8 +128,8 @@ func (mt *MessagesText) createMessage(m discord.Message) { } func (mt *MessagesText) createHeader(w io.Writer, m discord.Message, isReply bool) { - if mt.cfg.Timestamps { - time := m.Timestamp.Time().In(time.Local).Format(mt.cfg.TimestampsFormat) + if mt.cfg.Timestamps.Enabled { + time := m.Timestamp.Time().In(time.Local).Format(mt.cfg.Timestamps.Format) fmt.Fprintf(w, "[::d]%s[::-] ", time) } diff --git a/internal/config/config.go b/internal/config/config.go index 3c1a263..d4fdf00 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -14,6 +14,11 @@ import ( const fileName = "config.toml" type ( + Timestamps struct { + Enabled bool `toml:"enabled"` + Format string `toml:"format"` + } + Identify struct { Status discord.Status `toml:"status"` Browser string `toml:"browser"` @@ -40,9 +45,7 @@ type ( ShowAttachmentLinks bool `toml:"show_attachment_links"` MessagesLimit uint8 `toml:"messages_limit"` - Timestamps bool `toml:"timestamps"` - TimestampsFormat string `toml:"timestamps_format"` - + Timestamps Timestamps `toml:"timestamps"` Identify Identify `toml:"identify"` Notifications Notifications `toml:"notifications"` @@ -60,8 +63,10 @@ func defaultConfig() *Config { ShowAttachmentLinks: true, MessagesLimit: 50, - Timestamps: false, - TimestampsFormat: time.Kitchen, + Timestamps: Timestamps{ + Enabled: false, + Format: time.Kitchen, + }, Identify: Identify{ Status: discord.OnlineStatus,