matrix-org / matrix-appservice-discord

A bridge between Matrix and Discord.
Apache License 2.0
799 stars 151 forks source link

Allow longer display names #543

Open pacien opened 5 years ago

pacien commented 5 years ago

~~Some characters/emojis allowed in Matrix display names are not supported by Discord. Currently, those names are simply replaced with the users' MXID if they contain such unauthorised characters.~~

While those MXIDs are fine for real Matrix users, they quickly become hard to distinguish for ghosts created by other application services.

Long Matrix display names are replaced with the MXID when bridged to Discord (https://github.com/Half-Shot/matrix-appservice-discord/issues/543#issuecomment-523145360).

In my case, messages posted by some Telegram users are being relayed to Discord through Matrix. Discord users often end up seeing something like this:

[BOT] @telegram_123456789:homeserver.tld hello
[BOT] @telegram_123456780:homeserver.tld hi!
[BOT] @telegram_123456781:homeserver.tld hey there!

The profile pictures often do not help as they seem to be unstable.

One easy solution could be to replace those special characters in display names with some placeholder instead.

Half-Shot commented 5 years ago

Do we know which characters Discord is unable to display, so we can filter for those?

pacien commented 5 years ago

No idea, but the bridge already seems to know about those (or is able to detect the error) since it's already falling back to the MXID in such case.

Half-Shot commented 5 years ago

Indeed, is strange.

Half-Shot commented 5 years ago

@pacien Do you have a view of the Matrix room?

pacien commented 5 years ago

As suggested by @Half-Shot in PM, this seems to be related to the display name length instead of the presence of emojis.

This limit seems to be defined in two places:

https://github.com/Half-Shot/matrix-appservice-discord/blob/4fc149e79c30cfbeb4c3aa2dcb92622c871e0c5e/src/matrixeventprocessor.ts#L37

https://github.com/Half-Shot/matrix-appservice-discord/blob/4fc149e79c30cfbeb4c3aa2dcb92622c871e0c5e/src/matrixmessageprocessor.ts#L25

Affecting the embed author field:

https://github.com/Half-Shot/matrix-appservice-discord/blob/4fc149e79c30cfbeb4c3aa2dcb92622c871e0c5e/src/matrixeventprocessor.ts#L469-L485

And the reply format:

https://github.com/Half-Shot/matrix-appservice-discord/blob/4fc149e79c30cfbeb4c3aa2dcb92622c871e0c5e/src/matrixmessageprocessor.ts#L66-L76

For the former, this limit seems to be rather short as the author.name field accepts up to 256 characters according to Discord's API doc.

StepS- commented 4 years ago

This is also an issue whenever someone uses a 1-character nickname (which is often the case with certain secretive Telegram users). The nick is not correctly carried over to Discord and displays the full matrix userID.

Not sure if that's the same thing but thought I'd add to this issue here.

Edit: screw it, made a new one anyway: #612