Remove timestamps_before_author field (timestamps are before author by default)

This commit is contained in:
ayn2op 2024-09-27 21:04:50 +05:30
parent a6e6388322
commit cc5fe0620d
2 changed files with 10 additions and 17 deletions

View file

@ -126,9 +126,8 @@ 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(cfg.TimestampsFormat)
if cfg.Timestamps && cfg.TimestampsBeforeAuthor {
if cfg.Timestamps {
time := m.Timestamp.Time().In(time.Local).Format(cfg.TimestampsFormat)
fmt.Fprintf(w, "[::d]%s[::-] ", time)
}
@ -137,10 +136,6 @@ func (mt *MessagesText) createHeader(w io.Writer, m discord.Message, isReply boo
}
fmt.Fprintf(w, "[%s]%s[-:-:-] ", cfg.Theme.MessagesText.AuthorColor, m.Author.Username)
if cfg.Timestamps && !cfg.TimestampsBeforeAuthor {
fmt.Fprintf(w, "[::d]%s[::-] ", time)
}
}
func (mt *MessagesText) createBody(w io.Writer, m discord.Message, isReply bool) {
@ -160,7 +155,7 @@ 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)
if cfg.ShowAttachmentLinks {
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)
@ -288,10 +283,10 @@ func (mt *MessagesText) _select(name string) {
}
func (mt *MessagesText) onHighlighted(added, removed, remaining []string) {
if (len(added) > 0) {
if len(added) > 0 {
mID, err := strconv.ParseInt(added[0], 10, 64)
if err != nil {
slog.Error("Failed to parse region id as int to use as message id.","err",err)
slog.Error("Failed to parse region id as int to use as message id.", "err", err)
return
}
mt.selectedMessageID = discord.MessageID(mID)

View file

@ -16,9 +16,8 @@ type Config struct {
MessagesLimit uint8 `toml:"messages_limit"`
Editor string `toml:"editor"`
Timestamps bool `toml:"timestamps"`
TimestampsBeforeAuthor bool `toml:"timestamps_before_author"`
TimestampsFormat string `toml:"timestamps_format"`
Timestamps bool `toml:"timestamps"`
TimestampsFormat string `toml:"timestamps_format"`
ShowAttachmentLinks bool `toml:"show_attachment_links"`
@ -33,10 +32,9 @@ func defaultConfig() *Config {
MessagesLimit: 50,
Editor: "default",
Timestamps: false,
TimestampsBeforeAuthor: false,
TimestampsFormat: time.Kitchen,
Timestamps: false,
TimestampsFormat: time.Kitchen,
ShowAttachmentLinks: true,
Keys: defaultKeys(),