diff --git a/cmd/run/messages_text.go b/cmd/run/messages_text.go index f3244ad..cca61ed 100644 --- a/cmd/run/messages_text.go +++ b/cmd/run/messages_text.go @@ -83,14 +83,20 @@ func (mt *MessagesText) createMessage(m discord.Message) { } func (mt *MessagesText) createHeader(w io.Writer, m discord.Message, isReply bool) { + time := m.Timestamp.Format(time.Kitchen) + + if config.Current.Timestamps && config.Current.TimestampsBeforeAuthor { + fmt.Fprintf(w, "[::d]%7s[::-] ", time) + } + if isReply { fmt.Fprintf(mt, "[::d]%s", config.Current.Theme.MessagesText.ReplyIndicator) } - fmt.Fprintf(w, "[%s]%s[-] ", config.Current.Theme.MessagesText.AuthorColor, m.Author.Username) + fmt.Fprintf(w, "[%s]%s[-:-:-] ", config.Current.Theme.MessagesText.AuthorColor, m.Author.Username) - if config.Current.Timestamps { - fmt.Fprintf(w, "[::d]%s[::-] ", m.Timestamp.Format(time.Kitchen)) + if config.Current.Timestamps && !config.Current.TimestampsBeforeAuthor { + fmt.Fprintf(w, "[::d]%s[::-] ", time) } } diff --git a/config/config.go b/config/config.go index 1d2b744..b8d99a0 100644 --- a/config/config.go +++ b/config/config.go @@ -16,6 +16,8 @@ type Config struct { Mouse bool `yaml:"mouse"` // MessagesLimit is the number of messages to fetch when a text-based channel is selected. MessagesLimit uint `yaml:"messages_limit"` + // TimestampsBeforeAuthor indicates whether to draw the timestamp before or after the author. + TimestampsBeforeAuthor bool `yaml:"timestamps_before_author"` // Timestamps indicates whether to draw the timestamp in front of the message or not. Timestamps bool `yaml:"timestamps"` // Editor is the program to open when the `LaunchEditor` key is pressed. If the value of the field is "default", the `$EDITOR` environment variable is used instead. @@ -27,10 +29,11 @@ type Config struct { func defConfig() Config { return Config{ - Mouse: true, - Timestamps: false, - MessagesLimit: 50, - Editor: "default", + Mouse: true, + TimestampsBeforeAuthor: false, + Timestamps: false, + MessagesLimit: 50, + Editor: "default", Keys: defKeys(), Theme: defTheme(),