matterbridge icon indicating copy to clipboard operation
matterbridge copied to clipboard

Support (Discord) reply context in IRC

Open PointMeAtTheDawn opened this issue 10 months ago • 1 comments

Is your feature request related to a problem? Please describe. Discord replies have no context in IRC (even that they ARE a reply), leading to confusion.

Describe the solution you'd like Discord replies -> IRC should include some level of context: that it's a reply at all, reply to a particular user, reply to a message at a particular timestamp, or the beginning of the parent message.

Additional context Quick and dirty pseudocode if there's interest in merging a tested PR: In https://github.com/42wim/matterbridge/blob/master/bridge/discord/handlers.go#L85 In

    // Add our parent id if it exists, and if it's not referring to a message in another channel
    if ref := m.MessageReference; ref != nil && ref.ChannelID == m.ChannelID {
        rmsg.ParentID = ref.MessageID
    }

(MessageReference is just an id, ReferencedMessage has the actual content)

I would do something along the lines of this (but better typed :p)

DESIRED_SNIPPET_LENGTH := 25
DISCORD_PARENT_CONTENT := "discord_parent_content"
    // Add our parent id if it exists, and if it's not referring to a message in another channel.
        // Also, include a snippet of the parent to let bridges include it when the id is unusable.
    if ref := m.MessageReference; ref != nil && ref.ChannelID == m.ChannelID {
        rmsg.ParentID = ref.MessageID
                // Proper null safety here for best practice

                rmsg.Extra[DISCORD_PARENT_CONTENT] = ref.ReferencedMessage.content[:DESIRED_SNIPPET_LENGTH-1]
    }

Then in IRC https://github.com/42wim/matterbridge/blob/master/bridge/irc/irc.go#L140

if msg.Extra[DISCORD_PARENT_CONTENT] != "" (or w.e) {
    msg.Text = msg.Extra[DISCORD_PARENT_CONTENT].prettyFormatOrWhatever() + msg.Text
}

PointMeAtTheDawn avatar Apr 18 '24 22:04 PointMeAtTheDawn

Yes please, would be perfect if they looked just like telegram!

thechantaro avatar May 29 '24 16:05 thechantaro