notification now contains the senders name
@@ -526,7 +526,6 @@ func NewWindow(app *tview.Application, discord *discordgo.Session) (*Window, err
} else {
mentionsYou := false
if message.Author.ID != window.session.State.User.ID {
-
for _, user := range message.Mentions {
if user.ID == window.session.State.User.ID {
mentionsYou = true
@@ -544,20 +543,35 @@ func NewWindow(app *tview.Application, discord *discordgo.Session) (*Window, err
}
if mentionsYou {
- notificationLocation := channel.Name
+ var notificationLocation string
+
+ if channel.Type == discordgo.ChannelTypeDM {
+ notificationLocation = message.Author.Username
+ } else if channel.Type == discordgo.ChannelTypeGroupDM {
+ notificationLocation = channel.Name
if notificationLocation == "" {
- notificationLocation = channel.Recipients[0].Username
+ for index, recipient := range channel.Recipients {
+ if index == 0 {
+ notificationLocation = recipient.Username
+ } else {
+ notificationLocation = fmt.Sprintf("%s, %s", notificationLocation, recipient.Username)
}
- beeep.Notify("Cordless - "+notificationLocation, message.ContentWithMentionsReplaced(), "assets/information.png")
}
}
+
+ notificationLocation = message.Author.Username + "-" + notificationLocation
+ } else if channel.Type == discordgo.ChannelTypeGuildText {
+ notificationLocation = message.Author.Username + "-" + channel.Name
}
- window.app.QueueUpdateDraw(func() {
+ beeep.Notify("Cordless - "+notificationLocation, message.ContentWithMentionsReplaced(), "assets/information.png")
+ }
+ }
+ window.app.QueueUpdateDraw(func() {
window.channelRootNode.Walk(func(node, parent *tview.TreeNode) bool {
data, ok := node.GetReference().(string)
- if ok && data == message.ChannelID {
+ if ok && data == message.ChannelID && window.selectedChannel.ID != data {
if mentionsYou {
channel, stateError := window.session.State.Channel(message.ChannelID)
if stateError == nil {
@@ -574,6 +588,7 @@ func NewWindow(app *tview.Application, discord *discordgo.Session) (*Window, err
}
}
}
+ }
}()
go func() {
