Class EmojiProcessor

java.lang.Object
tv.phantombot.scripts.handler.EmojiProcessor

public class EmojiProcessor extends Object
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 Details

    • EmojiProcessor

      public EmojiProcessor()
  • Method Details

    • extractEmoji

      public static List<String> extractEmoji(String input)
      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

      public static String covertEmoteToCodepoint(String emoji)
      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

      public static String[] extractAllEmojiToCodepoint(String input)
      Combines extractEmoji(String) and covertEmoteToCodepoint(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

      public static Map<String,Long> groupByCount(String[] emojis)