carpedm20 / emoji

emoji terminal output for Python
Other
1.87k stars 273 forks source link

Add alias for smiling face with heart eyes #268

Closed snus-kin closed 1 year ago

snus-kin commented 1 year ago

This alias is used in the YouTube frontend and the linked emoji site in the repo

cvzi commented 1 year ago

It looks like the cheat sheet website has been updated.

There seem to be a few more changes/additions, but there are also some obvious errors for example, if you type in the search "shaking", the result is

🤥

with the strange shortcode :⊛_shaking_face:

snus-kin commented 1 year ago

Ah yes, very easy to type that circled asterix operator!

I suppose some of these are slightly absurd but I created this PR since I found that one in use in the wild and wanted to use this library on it :)

cvzi commented 1 year ago

I was just wondering whether/how we should add all of the new ones. We have a script to update the emoji, but I removed the "emoji cheet sheet" as a source, because the website wasn't updated in a long time.

Since you mentioned Youtube, I found this document is used on youtube.com and seems to contain all youtube emojis: https://www.gstatic.com/youtube/img/emojis/emojis-png-7.json That might be a more reliable source than using the "emoji cheet sheet"

snus-kin commented 1 year ago

It would be cool if there was a way to make these things user-extensible, I guess. Not sure what is extant for that sort of thing as of right now. Even just providing an extra little dict of {":shortcut:": "<emoji>"} in a setup call might be nice

cvzi commented 1 year ago

I think that's a good idea. It's actually possible at the moment, but not documented or specified. A dedicated setup function would be nice.

At the moment you can change the EMOJI_DATA dict, as long as you do it before the first call of emojize() .

For example adding that one alias:

import emoji

emoji.EMOJI_DATA['😍']['alias'].insert(0, ':smiling_face_with_heart_eyes:')

print(emoji.emojize("test :smiling_face_with_heart_eyes:", language="alias"))
print(emoji.demojize("test 😍", language="alias"))

Note: demojize() only uses the first entry of the alias-list, so there is a difference between using .insert(0, ':shortcode:') and .append(':shortcode:').

cvzi commented 1 year ago

I'll add the cheat sheet back into the script to automatically update from the cheat sheet. There are only few "strange" ones with the asterix operator, I can filter them by hand.

So @TahirJalilov you can merge this pull request, and then I will create another pull request with the rest of the missing short-codes from the cheat sheet.