Пример #1
0
 async def copy(self, ctx, *, emoji: str):
     '''Copy an emoji from another server to your own'''
     if len(ctx.message.guild.emojis) == 50:
         await ctx.message.delete()
         await ctx.send('Лимит смайликов в вашем сервере исчерпан!')
         return
     emo_check = self.check_emojis(ctx.bot.emojis, emoji.split(":"))
     if emo_check[0]:
         emo = emo_check[1]
     else:
         emo = discord.utils.find(
             lambda e: emoji.replace(":", "") in e.name, ctx.bot.emojis)
     em = discord.Embed()
     em.color = await ctx.get_dominant_color(ctx.author.avatar_url)
     if emo == None:
         em.title = 'Добавление смайлика'
         em.description = 'Невозможно найти смайлик.'
         await ctx.send(embed=em)
         return
     em.title = f'Добавлен смайлик: {emo.name}'
     em.set_image(url='attachment://emoji.png')
     async with ctx.session.get(emo.url) as resp:
         image = await resp.read()
     with io.BytesIO(image) as file:
         await ctx.send(embed=em,
                        file=discord.File(copy.deepcopy(file), 'emoji.png'))
         await ctx.guild.create_custom_emoji(name=emo.name,
                                             image=file.read())
Пример #2
0
 async def copy(self, ctx, *, emoji: str):
     '''Copy an emoji from another server to your own'''
     if len(ctx.message.guild.emojis) == 50:
         await ctx.message.delete()
         await ctx.send('Your Server has already hit the 50 Emoji Limit!')
         return
     emo_check = self.check_emojis(ctx.bot.emojis, emoji.split(":"))
     if emo_check[0]:
         emo = emo_check[1]
     else:
         emo = discord.utils.find(
             lambda e: emoji.replace(":", "") in e.name, ctx.bot.emojis)
     em = discord.Embed()
     em.color = await ctx.get_dominant_color(ctx.author.avatar_url)
     if emo == None:
         em.title = 'Add Emoji'
         em.description = 'Could not find emoji.'
         await ctx.send(embed=em)
         return
     em.title = f'Added Emoji: {emo.name}'
     em.set_image(url='attachment://emoji.png')
     async with ctx.session.get(emo.url) as resp:
         image = await resp.read()
     with io.BytesIO(image) as file:
         await ctx.send(embed=em,
                        file=discord.File(copy.deepcopy(file), 'emoji.png'))
         await ctx.guild.create_custom_emoji(name=emo.name,
                                             image=file.read())
Пример #3
0
def handle_emoji_tone(emoji):
    for t in tones:
        if t in emoji:
            tone = t
            return emoji.replace(tone, '')
    return emoji
Пример #4
0
def decode(payload):
    return payload.split(':', maxsplit=1)


# encode an outgoing message
def encode(action, message):
    return '%s:%s' % (action, message)


# create the chat client
with Client(port=50000) as chat:

    # call the function we defined whenever a new message arrives
    chat.on_message_received(handle_message)

    # let everyone know you're here
    chat.send_message(encode(HELLO, my_name))

    finished = False
    while not finished:
        message = window.ask("Enter a message: ")
        # type 'bye' to leave the chat and exit the program
        if message.lower() == 'bye':
            finished = True
        else:
            message = emoji.replace(message)
            chat.send_message(encode(SAY, message))

    # let everyone know you're leaving
    chat.send_message(BYE)