Sequence of emoji codes

main
Bob Mottram 2020-02-21 21:08:24 +00:00
parent 4173ea679e
commit 29783f7bf4
1 changed files with 25 additions and 7 deletions

View File

@ -64,14 +64,32 @@ def replaceEmojiFromTags(content: str,tag: [],messageType: str) -> str:
if iconName:
if len(iconName)>1:
if iconName[0].isdigit():
if '.' in iconName and '-' not in iconName:
if '.' in iconName:
iconName=iconName.split('.')[0]
try:
content= \
content.replace(tagItem['name'], \
chr(int("0x"+iconName,16)))
except:
pass
# see https://unicode.org/emoji/charts/full-emoji-list.html
if '-' not in iconName:
# a single code
try:
content= \
content.replace(tagItem['name'], \
chr(int("0x"+iconName,16)))
except:
pass
else:
# sequence of codes
iconCodes=iconName.split('-')
iconCodeSequence=''
for icode in iconCodes:
try:
iconCodeSequence+=chr(int("0x"+iconName,16))
except:
iconCodeSequence=''
break
if iconCodeSequence:
content= \
content.replace(tagItem['name'], \
iconCodeSequence)
htmlClass='emoji'
if messageType=='post header':
htmlClass='emojiheader'