send a slightly more appropriate display name
This commit is contained in:
parent
36adc30990
commit
213bf0a515
1 changed files with 10 additions and 2 deletions
|
@ -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
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue