Пример #1
0
def test_findall_list(tweet):
    assert len(demoji.findall_list(tweet, True)) \
        == len(demoji.findall_list(tweet, False))
    assert demoji.findall_list(tweet, True)
    assert demoji.findall_list(tweet, False)
    assert 'santa claus' in demoji.findall_list(tweet, True)[0].lower()
    assert '🔥' == demoji.findall_list(tweet, False)[1]
Пример #2
0
def test_findall_list(tweet):
    assert len(demoji.findall_list(tweet, True)) == len(
        demoji.findall_list(tweet, False))
    assert demoji.findall_list(tweet, True)
    assert demoji.findall_list(tweet, False)
    assert "santa claus" in demoji.findall_list(tweet, True)[0].lower()
    assert "🔥" == demoji.findall_list(tweet, False)[1]
Пример #3
0
    async def add_reaction(self, ctx, cn_id: int, msg_id: int, emoji):
        try:
            channel = self.bot.get_channel(cn_id)
            msg = await channel.fetch_message(msg_id)
            emoji = demoji.findall_list(emoji, desc=False) + list(
                re.findall(customEmojiPattern, emoji, flags=re.DOTALL))
            for reaction in emoji:
                await msg.add_reaction(reaction.strip('<> '))

        except Exception as e:
            await ctx.send(
                f'Could not add reaction. Error: {type(e).__name__}, {e}')
        else:
            await ctx.message.add_reaction('✅')
Пример #4
0
def extract_emoticons(text: str,
                      emoji_for_response_0: list,
                      emoji_for_response_1: list,
                      emoji_for_response_2: list
                      ):
    emoji = demoji.findall_list(text[0], desc=False)
    pattern = re.compile(r'[:;Xx]-?[\)\(dD](?=[\s\.]*)')
    text_emoji = pattern.findall(text[0].lower())
    result = [*emoji, *text_emoji]
    if len(result) > 0:
        if text[1] == 0:
            emoji_for_response_0.extend(result)
        elif text[1] == 1:
            emoji_for_response_1.extend(result)
        else:
            emoji_for_response_2.extend(result)
        return ' '.join(set(result)), len(result)
    else:
        return '', 0
def emoji(text):
    ls = set(demoji.findall_list(text))
    ls = list(ls)
    return ls
Пример #6
0
 async def poll(self, ctx, *, arg):
     emoji = demoji.findall_list(arg, desc=False) + list(
         re.findall(customEmojiPattern, arg, flags=re.DOTALL))
     msg = await ctx.send(f"**Poll time! <@{ctx.author.id}> asks:**\n{arg}")
     for reaction in emoji:
         await msg.add_reaction(reaction.strip('<> '))
Пример #7
0
def contains_emoji(s: str) -> bool:
    try:
        demoji.set_emoji_pattern()
    except IOError:
        demoji.download_codes()
    return bool(demoji.findall_list(s, desc=False))
Пример #8
0
def find_emojis_in_str(s: str) -> List[str]:
    return cast(List[str], demoji.findall_list(s, desc=False))