mirror of https://gitlab.com/bashrc2/epicyon
Lookup emoji codes from their names for the common emoji list
parent
77cd289a5e
commit
a7cb0ead44
|
@ -1677,6 +1677,11 @@ def set_custom_background(base_dir: str, background: str,
|
||||||
def html_common_emoji(base_dir: str, no_of_emoji: int) -> str:
|
def html_common_emoji(base_dir: str, no_of_emoji: int) -> str:
|
||||||
"""Shows common emoji
|
"""Shows common emoji
|
||||||
"""
|
"""
|
||||||
|
emojis_filename = base_dir + '/emoji/emoji.json'
|
||||||
|
if not os.path.isfile(emojis_filename):
|
||||||
|
emojis_filename = base_dir + '/emoji/default_emoji.json'
|
||||||
|
emojis_json = None
|
||||||
|
|
||||||
common_emoji_filename = base_dir + '/accounts/common_emoji.txt'
|
common_emoji_filename = base_dir + '/accounts/common_emoji.txt'
|
||||||
if not os.path.isfile(common_emoji_filename):
|
if not os.path.isfile(common_emoji_filename):
|
||||||
return ''
|
return ''
|
||||||
|
@ -1695,6 +1700,18 @@ def html_common_emoji(base_dir: str, no_of_emoji: int) -> str:
|
||||||
while ctr < no_of_emoji and line_ctr < len(common_emoji):
|
while ctr < no_of_emoji and line_ctr < len(common_emoji):
|
||||||
emoji_name = common_emoji[line_ctr].split(' ')[1].replace('\n', '')
|
emoji_name = common_emoji[line_ctr].split(' ')[1].replace('\n', '')
|
||||||
emoji_filename = base_dir + '/emoji/' + emoji_name + '.png'
|
emoji_filename = base_dir + '/emoji/' + emoji_name + '.png'
|
||||||
|
if not os.path.isfile(emoji_filename):
|
||||||
|
# load the emojis index
|
||||||
|
if not emojis_json:
|
||||||
|
emojis_json = load_json(emojis_filename)
|
||||||
|
# lookup the name within the index to get the hex code
|
||||||
|
if emojis_json:
|
||||||
|
for emoji_tag, emoji_code in emojis_json.items():
|
||||||
|
if emoji_tag == emoji_name:
|
||||||
|
emoji_name = emoji_code
|
||||||
|
# get the filename based on the hex code
|
||||||
|
emoji_filename = \
|
||||||
|
base_dir + '/emoji/' + emoji_name + '.png'
|
||||||
if os.path.isfile(emoji_filename):
|
if os.path.isfile(emoji_filename):
|
||||||
# NOTE: deliberately no alt text, so that without graphics only
|
# NOTE: deliberately no alt text, so that without graphics only
|
||||||
# the emoji name shows
|
# the emoji name shows
|
||||||
|
|
Loading…
Reference in New Issue