* Blocked Messages can now be shown as a placeholder
MODIFY
config/config.go
config/config.go
@@ -50,6 +50,7 @@ var (
ShortenLinks: false,
ShortenerPort: 63212,
DesktopNotifications: true,
+ ShowPlaceholderForBlockedMessages: false,
}
)
@@ -103,6 +104,12 @@ type Config struct {
// system when a notification needs to be sent.
DesktopNotifications bool
+ // ShowPlaceholderForBlockedMessages will cause blocked message to shown
+ // as a placeholder message, replacing user and message with generic text.
+ // The time of the message will still be correct in order to not mess up
+ // the timeline of messages.
+ ShowPlaceholderForBlockedMessages bool
+
// Accounts contains all saved accounts, allowing the user to dynamicly
// switch between the accounts.
Accounts []*Account

MODIFY
ui/chatview.go
ui/chatview.go
@@ -247,11 +247,17 @@ OUTER_LOOP:
//AddMessage add an additional message to the ChatView.
func (chatView *ChatView) AddMessage(message *discordgo.Message) {
+ var isBlocked bool
for _, relationship := range chatView.session.State.Relationships {
if relationship.User.ID == message.Author.ID &&
relationship.Type == discordgo.RelationTypeBlocked {
- return
+ isBlocked = true
+ break
+ }
}
+
+ if !config.GetConfig().ShowPlaceholderForBlockedMessages && isBlocked {
+ return
}
wasScrolledToTheEnd := chatView.internalTextView.IsScrolledToEnd()
@@ -270,10 +276,15 @@ func (chatView *ChatView) AddMessage(message *discordgo.Message) {
formattedMessage, contains := chatView.formattedMessages[message.ID]
if contains {
newText = formattedMessage
+ } else {
+ if isBlocked {
+ newText = messagePartsToColouredString(message.Timestamp, "Blocked user", "Blocked message")
+ chatView.formattedMessages[message.ID] = newText
} else {
newText = chatView.formatMessage(message)
chatView.formattedMessages[message.ID] = newText
}
+ }
if rerender {
chatView.Rerender()
@@ -303,12 +314,6 @@ func (chatView *ChatView) Rerender() {
}
func (chatView *ChatView) formatMessage(message *discordgo.Message) string {
- time, parseError := message.Timestamp.Parse()
- var timeCellText string
- if parseError == nil {
- timeCellText = times.TimeToString(&time)
- }
-
var messageText string
if message.Type == discordgo.MessageTypeDefault {
@@ -495,7 +500,17 @@ func (chatView *ChatView) formatMessage(message *discordgo.Message) string {
messageAuthor = "[#44e544]" + messageAuthor
}
- return fmt.Sprintf("[gray]%s %s [white]%s[\"\"][\"\"]", timeCellText, messageAuthor, messageText)
+ return messagePartsToColouredString(message.Timestamp, messageAuthor, messageText)
+}
+
+func messagePartsToColouredString(timestamp discordgo.Timestamp, author, message string) string {
+ time, parseError := timestamp.Parse()
+ var timeCellText string
+ if parseError == nil {
+ timeCellText = times.TimeToString(&time)
+ }
+
+ return fmt.Sprintf("[gray]%s %s [white]%s[\"\"][\"\"]", timeCellText, author, message)
}
func parseBoldAndUnderline(messageText string) string {

* Blocked Messages can now be shown as a placeholder