Add timestamps_format option to configuration file (#378)

This commit is contained in:
Steven Irving 2024-04-01 04:20:25 -06:00 • committed by GitHub
parent 3632f70e54
commit 057919e236
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 5 additions and 2 deletions

View file

@ -97,10 +97,10 @@ func (mt *MessagesText) createMessage(m discord.Message) {
}
func (mt *MessagesText) createHeader(w io.Writer, m discord.Message, isReply bool) {
time := m.Timestamp.Time().In(time.Local).Format(time.Kitchen)
time := m.Timestamp.Time().In(time.Local).Format(cfg.TimestampsFormat)
if cfg.Timestamps && cfg.TimestampsBeforeAuthor {
fmt.Fprintf(w, "[::d]%7s[::-] ", time)
fmt.Fprintf(w, "[::d]%s[::-] ", time)
}
if isReply {

View file

@ -3,6 +3,7 @@ package config
import (
"os"
"path/filepath"
"time"
"github.com/BurntSushi/toml"
"github.com/ayn2op/discordo/internal/constants"
@ -13,6 +14,7 @@ type Config struct {
Timestamps bool `toml:"timestamps"`
TimestampsBeforeAuthor bool `toml:"timestamps_before_author"`
TimestampsFormat string `toml:"timestamps_format"`
MessagesLimit uint8 `toml:"messages_limit"`
@ -28,6 +30,7 @@ func DefaultConfig() Config {
Timestamps: false,
TimestampsBeforeAuthor: false,
TimestampsFormat: time.Kitchen,
MessagesLimit: 50,
Editor: "default",