emoji suggestion
Created by: lijiarui
I found src/misc is trying to strip emoji, HTML and any misc things in a text message.
I have 2 suggestions:
-
I feel a bit confused about all emoji rules and this file rules, so I suggest to add some comment here, then if any other one gets some new emoji rules, we can add it here.
-
I suggest to add two functions:
-
message.stripEmoji(): void
: to strip emoji from the text message, then we can get a pure one. -
message.emoji(): []
: return a list containing all emojis meaning in the text.
I found the following code in src/misc seems trying to get emoji meaning but it cannot always succeed, also if there is some emotion, like gif in wechat, it doesn't work too.
public static digestEmoji(html?: string): string {
if (!html) {
return ''
}
return html
.replace(/<img class="(\w*?emoji) (\w*?emoji[^"]+?)" text="(.*?)_web" src=[^>]+>/g,
'$3',
) // <img class="emoji emoji1f4a4" text="[流汗]_web" src="/zh_CN/htmledition/v2/images/spacer.gif" />
.replace(/<span class="(\w*?emoji) (\w*?emoji[^"]+?)"><\/span>/g,
'[$2]',
) // '<span class="emoji emoji1f334"></span>'
}
Well, thinks more, even it should be a seperate npm module....