dylex / slack-libpurple

Slack module for libpurple
GNU General Public License v2.0
280 stars 38 forks source link

Supporting unicode <-> slackcode emoji conversions on message text #185

Open berrange opened 1 year ago

berrange commented 1 year ago

When someone types a unicode emoji in a message, slack will convert that into a slackcode

eg someone types 🦕 and slack's message text contains :sauropod: instead of 🦕, even though unicode was perfectly capable of representing the emoji as-is. I'm assuming they do this to better support clients on platforms using outdated unicode standards which have not defined some emoji.

The downside is that this does not currently display nicely in libpurple client apps like pidgin.

The second minor issue is that slack-libpurple sends the raw unicode sequences, rather than slackcodes. IIUC, slack server converts the emoji when it sees them, but it is better if slack-libpurple sent the slackcodes directly.

So these patches add support for the unicode <-> slackcode emoji conversions on incoming and outgoing messages.

It is fairly simple based on a pair of lookup tables, populated from a json doc that is built into the binary using GResource. The actual JSON data comes from Weechat's slack plugin repo as-is.

This does not support user defined emoji, which would require downloading images from the slack server. That could potentially be added at a later date by extending this basic unicode emoji functionality.