Parcourir la source

Add timestamps_format option to configuration file (#378)

Steven Irving il y a 2 ans
Parent
commit
057919e236
2 fichiers modifiés avec 5 ajouts et 2 suppressions
  1. 2 2
      cmd/messages_text.go
  2. 3 0
      internal/config/config.go

+ 2 - 2
cmd/messages_text.go

@@ -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 {

+ 3 - 0
internal/config/config.go

@@ -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",