From 29783f7bf40a975c5f426fb5074a4a730ef68af5 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Fri, 21 Feb 2020 21:08:24 +0000 Subject: [PATCH] Sequence of emoji codes --- content.py | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/content.py b/content.py index 5f2d2ca3..0b515c66 100644 --- a/content.py +++ b/content.py @@ -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'