Update emoji
This commit is contained in:
parent
c62f9c0ddc
commit
8d0d0dd3a7
2 changed files with 4248 additions and 1997 deletions
6193
js/emoji.js
6193
js/emoji.js
File diff suppressed because it is too large
Load diff
52
tools/update_emoji.py
Executable file
52
tools/update_emoji.py
Executable file
|
@ -0,0 +1,52 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import requests
|
||||
import json
|
||||
import re
|
||||
import sys
|
||||
|
||||
in_data = requests.get("https://github.com/mattermost/mattermost-webapp/raw/master/utils/emoji.json").json()
|
||||
"""
|
||||
{
|
||||
"name": "GRINNING FACE",
|
||||
"unified": "1F600",
|
||||
"short_name": "grinning",
|
||||
"short_names": [
|
||||
"grinning"
|
||||
],
|
||||
"text": ":D",
|
||||
"texts": null,
|
||||
"category": "smileys-emotion"
|
||||
},
|
||||
"""
|
||||
|
||||
|
||||
def text_or_emoji(emoji_entry):
|
||||
if emoji_entry.get("text") and emoji_entry.get("short_name") != "blush":
|
||||
return emoji_entry["text"]
|
||||
elif emoji_entry.get("unified"):
|
||||
textual_unicode = emoji_entry["unified"]
|
||||
assert re.fullmatch("[0-9A-F]{4,5}(-[0-9A-F]{4,5})*", textual_unicode)
|
||||
return "".join(
|
||||
chr(int(c, base=16)) for c in textual_unicode.split("-")
|
||||
)
|
||||
else:
|
||||
return None
|
||||
|
||||
|
||||
out_data = {
|
||||
short_name: text_or_emoji(emoji_entry)
|
||||
for emoji_entry in in_data
|
||||
for short_name in emoji_entry["short_names"]
|
||||
}
|
||||
out_data = {k: v for k, v in out_data.items() if v is not None}
|
||||
|
||||
out = json.dumps(out_data, ensure_ascii=False)
|
||||
out = re.sub(", *", ",\n", out)
|
||||
|
||||
print(f"""// The rest of this file uses data provided by Mattermost.
|
||||
// In sofar as it is protectable by copyright, it is licensed under the Apache license:
|
||||
// https://github.com/mattermost/mattermost-webapp/blob/51185f6969bed6d061558de65f0722ffb6dc62b3/LICENSE.txt
|
||||
//
|
||||
// Generated with /tools/update_emoji.py
|
||||
const emoji = {out};""")
|
Loading…
Reference in a new issue