From 213bf0a5159e8dd023ab80966d6d73e6b1fa4113 Mon Sep 17 00:00:00 2001 From: Cadence Ember Date: Sat, 19 Aug 2023 18:37:34 +1200 Subject: [PATCH] send a slightly more appropriate display name --- m2d/converters/event-to-message.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/m2d/converters/event-to-message.js b/m2d/converters/event-to-message.js index 817ffff..74a45ce 100644 --- a/m2d/converters/event-to-message.js +++ b/m2d/converters/event-to-message.js @@ -16,11 +16,19 @@ function eventToMessage(event) { /** @type {(DiscordTypes.RESTPostAPIWebhookWithTokenJSONBody & {files?: {name: string, file: Buffer}[]})[]} */ const messages = [] + let displayName = event.sender + let avatarURL = undefined + const match = event.sender.match(/^@(.*?):/) + if (match) { + displayName = match[1] + // TODO: get the media repo domain and the avatar url from the matrix member event + } + if (event.content.msgtype === "m.text") { messages.push({ content: event.content.body, - username: event.sender.replace(/^@/, ""), - avatar_url: undefined, // TODO: provide the URL to the avatar from the homeserver's content repo + username: displayName, + avatar_url: avatarURL }) }