Exemplo n.º 1
0
    def update_standard_emoji(self,
                              emoji_name: str,
                              skin_variation: str = None):
        emoji_data = emoji_data_python.find_by_shortname(emoji_name)
        if not emoji_data:
            self.logger.warning("emoji %s not found", emoji_name)
            return
        elif len(emoji_data) > 1:
            self.logger.warning("multiple emoji found for %s: %s", emoji_name,
                                emoji_data)
        emoji_data = emoji_data[0]

        if skin_variation and SKIN_TONES[
                skin_variation] in emoji_data.skin_variations:
            emoji_data = emoji_data.skin_variations[SKIN_TONES[skin_variation]]

        emoji_name = self.full_emoji_name(emoji_name, skin_variation)

        if not emoji_data.has_img_apple:
            self.logger.warning("No Apple emoji found for %s", emoji_name)

        url = (
            "https://raw.githubusercontent.com/iamcal/emoji-data/master/img-apple-64/"
            + emoji_data.image)
        self.update_emoji(url, emoji_name)
def get_emoji_from_data(token: str):
    if len(token) < 4:
        return None
    emojis = [emoji.char for emoji in emoji_data_python.find_by_name(token)]
    if emojis:
        return random.choice(emojis)
    # TODO: maybe make find by shortname a separate modifier
    emojis = [
        emoji.char for emoji in emoji_data_python.find_by_shortname(token)
    ]
    if emojis:
        return random.choice(emojis)
    return None
Exemplo n.º 3
0
 def test_find_by_shortname_unique(self):
     self.assertEqual(25, len(find_by_shortname('heart')))
     self.assertEqual(14, len(find_by_shortname('moon')))
Exemplo n.º 4
0
 def test_find_by_shortname(self):
     self.assertEqual(1, len(find_by_shortname('wave')))
     self.assertEqual('WAVING HAND SIGN', find_by_shortname('wave')[0].name)