feat: implement message timestamps (#113)
This commit is contained in:
parent
a10732bc25
commit
867f87f2bc
2 changed files with 20 additions and 0 deletions
|
|
@ -10,6 +10,7 @@ type GeneralConfig struct {
|
|||
FetchMessagesLimit int `json:"fetchMessagesLimit"`
|
||||
Mouse bool `json:"mouse"`
|
||||
Notifications bool `json:"notifications"`
|
||||
Timestamps bool `json:"timestamps"`
|
||||
}
|
||||
|
||||
type KeybindingsConfig struct {
|
||||
|
|
@ -37,6 +38,7 @@ func New() *Config {
|
|||
FetchMessagesLimit: 50,
|
||||
Mouse: true,
|
||||
Notifications: true,
|
||||
Timestamps: false,
|
||||
},
|
||||
Keybindings: KeybindingsConfig{
|
||||
FocusGuildsList: []string{"Alt+Rune[g]"},
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package ui
|
|||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/ayntgl/discordgo"
|
||||
"github.com/ayntgl/discordo/util"
|
||||
|
|
@ -21,18 +22,35 @@ func buildMessage(app *App, m *discordgo.Message) []byte {
|
|||
b.WriteString("\"]")
|
||||
// Build the message associated with crosspost, channel follow add, pin, or a reply.
|
||||
buildReferencedMessage(&b, m.ReferencedMessage, app.Session.State.User.ID)
|
||||
|
||||
if app.Config.General.Timestamps {
|
||||
t, err := m.Timestamp.Parse()
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
b.WriteString("[::d]")
|
||||
b.WriteString(t.Format(time.Stamp))
|
||||
b.WriteString("[::-]")
|
||||
b.WriteByte(' ')
|
||||
}
|
||||
|
||||
// Build the author of this message.
|
||||
buildAuthor(&b, m.Author, app.Session.State.User.ID)
|
||||
|
||||
// Build the contents of the message.
|
||||
buildContent(&b, m, app.Session.State.User.ID)
|
||||
|
||||
if m.EditedTimestamp != "" {
|
||||
b.WriteString(" [::d](edited)[::-]")
|
||||
}
|
||||
|
||||
// Build the embeds associated with the message.
|
||||
buildEmbeds(&b, m.Embeds)
|
||||
|
||||
// Build the message attachments (attached files to the message).
|
||||
buildAttachments(&b, m.Attachments)
|
||||
|
||||
// Tags with no region ID ([""]) do not start new regions. They can
|
||||
// therefore be used to mark the end of a region.
|
||||
b.WriteString("[\"\"]")
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue