Package tv.phantombot.scripts.handler
Class EmojiProcessor
java.lang.Object
tv.phantombot.scripts.handler.EmojiProcessor
This is a helper class to parse emojis.
Rhino does not support the y-flag for RegExp which is needed to run Twitter's twemoji-parser. It runs, but it causes
an infinitive loop because the lastIndex variable is not behaving as expected and therefore the abort condition
will never happen.
This implementation relies on emoji-java. It just uses the
emoji parser and the emoji database (as of version 5.1.1 it's Emoji Version 13.1).
The output are codepoints that are compatible with the common emoji libraries such es Twemoji.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic String
covertEmoteToCodepoint
(String emoji) Converts a unicode (multi-byte) emoji to its codepoint representation (e.g.static String[]
extractAllEmojiToCodepoint
(String input) CombinesextractEmoji(String)
andcovertEmoteToCodepoint(String)
in a single method to retrieve an array of codepointsextractEmoji
(String input) Extracts all known emojis from the given stringgroupByCount
(String[] emojis)
-
Constructor Details
-
EmojiProcessor
public EmojiProcessor()
-
-
Method Details
-
extractEmoji
Extracts all known emojis from the given string- Parameters:
input
- the input string to parse emojis from- Returns:
- a list of single emoji characters (they are still multibyte characters)
-
covertEmoteToCodepoint
Converts a unicode (multi-byte) emoji to its codepoint representation (e.g. 1f590-1f3fb)- Parameters:
emoji
- a single emoji to convert- Returns:
- the code point representation that works with emoji libraries
-
extractAllEmojiToCodepoint
CombinesextractEmoji(String)
andcovertEmoteToCodepoint(String)
in a single method to retrieve an array of codepoints- Parameters:
input
- the input string to parse emojis from- Returns:
- an array of strings in a code point representation format that works with emoji libraries (e.g. 1f590-1f3fb)
-
groupByCount
-