Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

berrange
Copy link

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.

Slack messages can contain emoji codes of the form ":code-name:".

When displayed these can expand to either standard unicode emoji
characters, or arbitrary user defined emoji.

This adds support for a new pair of APIs that can convert
between standard unicode emoji characters and slack emoji codes.

The conversion process is driven by a mapping table loaded from
a JSON document that is built into the plugin binary as a glib
resource. The JSON file comes from weechat's slack plugin:

  https://github.com/wee-slack/wee-slack/blob/master/weemoji.json

wee-slack is under an MIT license, but this is JSON file is fully
auto-generated from information reported by Slack itself.

Signed-off-by: Daniel P. Berrangé <[email protected]>
Slack messages can contain emoji codes of the form ":code-name:".

When displayed these can expand to either standard unicode emoji
characters, or arbitrary user defined emoji. Rendering the latter
requires talking to the server to fetch the associated images,
but standard unicode emojis can be easily rendered by GTK, so we
can simply replace them with appropriate unicode characters upon
receiving a slack message.

When sending messages back to slack, while we can send raw unicode
emoji characters, best practice is to convert them to emoji codes.

Signed-off-by: Daniel P. Berrangé <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant