1
0
Fork 0

send a slightly more appropriate display name

This commit is contained in:
Cadence Ember 2023-08-19 18:37:34 +12:00
parent 36adc30990
commit 213bf0a515

View file

@ -16,11 +16,19 @@ function eventToMessage(event) {
/** @type {(DiscordTypes.RESTPostAPIWebhookWithTokenJSONBody & {files?: {name: string, file: Buffer}[]})[]} */ /** @type {(DiscordTypes.RESTPostAPIWebhookWithTokenJSONBody & {files?: {name: string, file: Buffer}[]})[]} */
const messages = [] 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") { if (event.content.msgtype === "m.text") {
messages.push({ messages.push({
content: event.content.body, content: event.content.body,
username: event.sender.replace(/^@/, ""), username: displayName,
avatar_url: undefined, // TODO: provide the URL to the avatar from the homeserver's content repo avatar_url: avatarURL
}) })
} }