diff --git a/m2d/converters/event-to-message.js b/m2d/converters/event-to-message.js index fcf0bf8..ff31607 100644 --- a/m2d/converters/event-to-message.js +++ b/m2d/converters/event-to-message.js @@ -324,11 +324,12 @@ async function eventToMessage(event, guild, di) { replyLine += `https://discord.com/channels/${guild.id}/${row.channel_id}/${row.message_id} ` } const sender = repliedToEvent.sender - const senderName = sender.match(/@([^:]*)/)?.[1] || sender const authorID = select("sim", "user_id", {mxid: repliedToEvent.sender}).pluck().get() if (authorID) { replyLine += `<@${authorID}>` } else { + let senderName = select("member_cache", "displayname", {mxid: repliedToEvent.sender}).pluck().get() + if (!senderName) senderName = sender.match(/@([^:]*)/)?.[1] || sender replyLine += `Ⓜ️**${senderName}**` } // If the event has been edited, the homeserver will include the relation in `unsigned`. diff --git a/m2d/converters/event-to-message.test.js b/m2d/converters/event-to-message.test.js index 87a4b12..41d63b2 100644 --- a/m2d/converters/event-to-message.test.js +++ b/m2d/converters/event-to-message.test.js @@ -1151,7 +1151,7 @@ test("event2message: rich reply to a matrix user's long message with formatting" messagesToEdit: [], messagesToSend: [{ username: "cadence [they]", - content: "> <:L1:1144820033948762203><:L2:1144820084079087647>https://discord.com/channels/112760669178241024/687028734322147344/1144865310588014633 Ⓜ️**cadence**:" + content: "> <:L1:1144820033948762203><:L2:1144820084079087647>https://discord.com/channels/112760669178241024/687028734322147344/1144865310588014633 Ⓜ️**cadence [they]**:" + "\n> i should have a little happy test list bold em..." + "\n**no you can't!!!**", avatar_url: "https://matrix.cadence.moe/_matrix/media/r0/download/cadence.moe/azCAhThKTojXSZJRoWwZmhvU" @@ -1312,7 +1312,7 @@ test("event2message: with layered rich replies, the preview should only be the r messagesToEdit: [], messagesToSend: [{ username: "cadence [they]", - content: "> <:L1:1144820033948762203><:L2:1144820084079087647>https://discord.com/channels/112760669178241024/687028734322147344/1144865310588014633 Ⓜ️**cadence**:" + content: "> <:L1:1144820033948762203><:L2:1144820084079087647>https://discord.com/channels/112760669178241024/687028734322147344/1144865310588014633 Ⓜ️**cadence [they]**:" + "\n> two" + "\nthree", avatar_url: "https://matrix.cadence.moe/_matrix/media/r0/download/cadence.moe/azCAhThKTojXSZJRoWwZmhvU"