Supporting unicode <-> slackcode emoji conversions on message text#185
Open
berrange wants to merge 2 commits into
Open
Supporting unicode <-> slackcode emoji conversions on message text#185berrange wants to merge 2 commits into
berrange wants to merge 2 commits into
Conversation
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é <berrange@redhat.com>
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é <berrange@redhat.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.