async def enlarge(self, ctx, emoji): try: if emoji[0] == '<': name = emoji.split(':')[1] emoji_name = emoji.split(':')[2][:-1] anim = emoji.split(':')[0] if anim == '<a': url = f'https://cdn.discordapp.com/emojis/{emoji_name}.gif' else: url = f'https://cdn.discordapp.com/emojis/{emoji_name}.png' try: await ctx.send(url) except Exception as e: print(e) async with self.session.get(url) as resp: if resp.status != 200: await ctx.send(embed=create_embed('Error: Emote not found.')) return img = await resp.read() kwargs = {'parent_width': 1024, 'parent_height': 1024} convert = False task = functools.partial(bigEmote.generate, img, convert, **kwargs) task = self.bot.loop.run_in_executor(None, task) try: img = await asyncio.wait_for(task, timeout=15) except asyncio.TimeoutError: await ctx.send(embed=create_embed("Error: Timed Out. Try again in a few seconds")) return await ctx.send(file=discord.File(img, filename=name + '.png')) except Exception as e: await ctx.send(embed=create_embed(f"Error, couldn't send emote.\n{e}"))
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())
async def _emoji(self, ctx, *, emoji: str): '''Use emojis without nitro!''' emoji = emoji.split(":") emoji_check = self.check_emojis(ctx.bot.emojis, emoji) if emoji_check[0]: emo = emoji_check[1] else: emoji = [e.lower() for e in emoji] if emoji[0] == "<" or emoji[0] == "": emo = discord.utils.find(lambda e: emoji[1] in e.name.lower(), ctx.bot.emojis) else: emo = discord.utils.find(lambda e: emoji[0] in e.name.lower(), ctx.bot.emojis) if emo == None: em = discord.Embed(title="Отправка смайликов", description="Не удалось найти смайлик.") em.color = await ctx.get_dominant_color(ctx.author.avatar_url) await ctx.send(embed=em) return async with ctx.session.get(emo.url) as resp: image = await resp.read() with io.BytesIO(image) as file: await ctx.message.delete() await ctx.send(file=discord.File(file, 'emoji.png'))
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())
def set_emojitable(): file = 'EmojiSentiment.csv' emojilist = [] emojisent = [] with open(file) as inFile: for emoji in inFile.readlines(): emoji = emoji.split(',') emojilist.append(emoji[1]) emojisent.append(emoji[7]) emoji_table = dict(zip(emojilist, emojisent)) return emoji_table
async def _emoji(self, ctx, *, emoji: str): '''Use emojis without nitro!''' emoji = emoji.split(":") emoji_check = self.check_emojis(ctx.bot.emojis, emoji) if emoji_check[0]: emo = emoji_check[1] else: emoji = [e.lower() for e in emoji] if emoji[0] == "<" or emoji[0] == "": emo = discord.utils.find(lambda e: emoji[1] in e.name.lower(), ctx.bot.emojis) else: emo = discord.utils.find(lambda e: emoji[0] in e.name.lower(), ctx.bot.emojis) if emo == None: em = discord.Embed(title="Send Emoji", description="Could not find emoji.") em.color = await ctx.get_dominant_color(ctx.author.avatar_url) await ctx.send(embed=em) return await ctx.send(str(emo))
ax2.set_xlabel('Month') ax2.set_ylabel('No. of posts') ax2.set_xticks(nposts_year_month.index) ax2.set_ylim(0,50) plt.show() # In[26]: # Create variables for no. of words (omitting Chinese characters), hashtags, and emojis in captions data['nwords'] = [len(caption.split()) for caption in data['caption_en']] data['nhashtags'] = [len(hashtag.split()) for hashtag in data['hashtags']] data['nemojis'] = [len(emoji.split()) for emoji in data['emojis']] # In[27]: # Find % of posts with captions nposts = data.shape[0] nposts_caption = sum(data['iscaption']) print(round(nposts_caption*100/nposts,2), '% of posts contain captions.') # In[28]: