mautrix / discord

A Matrix-Discord puppeting bridge
https://go.mau.fi/mautrix-discord
GNU Affero General Public License v3.0
261 stars 24 forks source link

Send discord emojis in text from matrix to discord #82

Open XHawk87 opened 1 year ago

XHawk87 commented 1 year ago

I have this bridge on my matrix server, and I have it set up to puppet my discord account. I was trying out direct messages with a friend to see how it works. It's great in most respects, but one key thing that's missing is the ability to use my own discord emojis in chat messages. I wanted to open up a discussion about if/how this can be implemented. I'm a software developer, and I'd be willing to pitch in to help make this happen.

XHawk87 commented 1 year ago

It seems to me like the correct way to handle this would be to detect <img data-mx-emoticon/> tags in org.matrix.custom.html messages, and have the discord puppet replace these with the matching discord emoji if found, or just send the image link if not. Any thoughts on using this approach?

XHawk87 commented 1 year ago

According to https://discord.com/developers/docs/reference#message-formatting

Type Structure Example
Custom Emoji <:NAME:ID> <:mmLol:216154654256398347>
Custom Emoji (Animated) <a:NAME:ID> <a:b1nzy:392938283556143104>

So we'll need to get the emoji ID somehow.

XHawk87 commented 1 year ago

For reference, this is how spoiler tags are currently handled: https://github.com/mautrix/go/blob/ac3d88b512f26cee04d90eb8b6c47ce5ebec750b/format/htmlparser.go#L232 https://github.com/mautrix/go/blob/ac3d88b512f26cee04d90eb8b6c47ce5ebec750b/format/htmlparser.go#L307 https://github.com/mautrix/go/blob/ac3d88b512f26cee04d90eb8b6c47ce5ebec750b/format/htmlparser.go#L60 https://github.com/mautrix/discord/blob/7655ff1a648e6312203623ff4bcc3ab85653cc18/formatter.go#L204

This seems like an appropriate place to set up conversion of matrix emoticons tags to discord tags

HonbraDev commented 1 year ago

It would also be possible to include Discord's custom emoticons by including it in the 'server' space, as defined in MSC 2545.

Spaenny commented 7 months ago

You could retrieve all emotes from a Discord guild using the Discord API (https://discord.com/developers/docs/resources/emoji), and then upload them to the respective space using the State Event: im.ponies.room_emotes. This feature is supported by certain clients such as Cinny and FluffyChat.

You could simply add an extra prefix to the emotes for identification on the Matrix side, for example, "discord_emotename"

Spacefreak18 commented 1 month ago

for what it's worth, if your client supports text reactions, and you know the name and id of the emote on discord, you can send the emote as a reaction from matrix with

/react :emotename:123456789

Spacefreak18 commented 1 month ago

It seems to me like the correct way to handle this would be to detect <img data-mx-emoticon/> tags in org.matrix.custom.html messages, and have the discord puppet replace these with the matching discord emoji if found, or just send the image link if not. Any thoughts on using this approach?

@XHawk87

do you atleast see the emotes on the matrix side if they've been added to a message on the discord side?

That's atleast my experience with nheko and schildi chat

XHawk87 commented 4 weeks ago

do you atleast see the emotes on the matrix side if they've been added to a message on the discord side?

Yes, that was my experience too. It's going the other way that was the problem.

Unfortunately, I am not in a position to contribute to this project at the moment. I haven't used this service in a while, it actually stopped working on my homeserver entirely at one point, and I didn't have time to spend troubleshooting it so I disabled it. It seems like a neat idea though, I might come back to it at some point in the future.

Spacefreak18 commented 3 weeks ago

do you atleast see the emotes on the matrix side if they've been added to a message on the discord side?

Yes, that was my experience too. It's going the other way that was the problem.

Unfortunately, I am not in a position to contribute to this project at the moment. I haven't used this service in a while, it actually stopped working on my homeserver entirely at one point, and I didn't have time to spend troubleshooting it so I disabled it. It seems like a neat idea though, I might come back to it at some point in the future.

interesting, because i just recently moved to this because mx-puppet stopped working.

things seem to be stable right now with the newest synapse

i may try to add this functionality myself