Пример #1
0
    async def on_command_error(self, ctx, error):
        lang = Utils.get_lang(None, ctx.message)

        if isinstance(error, commands.CommandNotFound):
            return

        elif isinstance(error, commands.MissingPermissions):
            embed = Utils.error_embed(
                locales[lang]['errors']['missing_perms'])
            message = await ctx.send(embed=embed)
            await asyncio.sleep(5)
            await message.delete()

        elif isinstance(error, commands.BotMissingPermissions):
            embed = Utils.error_embed(
                locales[lang]['errors']['missing_bot_perms'])
            message = await ctx.send(embed=embed)
            await asyncio.sleep(5)
            await message.delete()

        elif isinstance(error, commands.CommandOnCooldown):
            embed = Utils.error_embed(
                locales[lang]['errors']['cooldown'].format(
                    error.retry_after))
            message = await ctx.send(embed=embed)
            await asyncio.sleep(5)
            await message.delete()
Пример #2
0
    async def train(self, ctx):
        lang = Utils.get_lang(None, ctx.message)
        await ctx.send(embed=Utils.done_embed(locales[lang]['etc']['on_train']))
        f = open(
            filepath + '/../samples/{0}.txt'.format(ctx.message.guild.id), 'w')
        ff = open(
            filepath + '/../samples/{0}_img.txt'.format(ctx.message.guild.id), 'w')

        for channel in ctx.guild.text_channels:
            try:
                messages = await channel.history(limit=500).flatten()
                for message in messages:
                    if message.author.bot:
                        pass
                    else:
                        is_bad_word = False
                        for badword in config['bad_start_words']:
                            if message.content.startswith(badword):
                                is_bad_word = True
                                break
                        if is_bad_word == False:
                            f.write(discord.utils.escape_markdown(
                                message.clean_content.lower().strip()) + '\\')

                        for file in message.attachments:
                            if file.url[-3::] == 'png' or file.url[-3::] == 'jpg' or file.url[-3::] == 'jpeg':
                                ff.write(file.url + '\n')
            except:
                pass

        await ctx.send(embed=Utils.done_embed(locales[lang]['gen']['successful_index']))
Пример #3
0
    async def train(self, ctx):
        lang = Utils.get_lang(None, ctx.message)
        await ctx.send(embed=Utils.done_embed(locales[lang]['etc']['on_train'])
                       )
        f = open(filepath + '/../samples/{0}.txt'.format(ctx.message.guild.id),
                 'w')
        ff = open(
            filepath + '/../samples/{0}_img.txt'.format(ctx.message.guild.id),
            'w')

        for channel in ctx.guild.text_channels:
            try:
                messages = await channel.history(limit=7500).flatten()
                for message in messages:
                    if message.author.bot:
                        pass
                    else:
                        f.write(message.content.lower().strip() + '\\')

                        for file in message.attachments:
                            if file.url[-3::] == 'png' or file.url[
                                    -3::] == 'jpg' or file.url[-3::] == 'jpeg':
                                ff.write(file.url + '\n')
            except:
                pass

        await ctx.send(
            embed=Utils.done_embed(locales[lang]['gen']['successful_index']))
Пример #4
0
    async def b(self, ctx):
        loop = asyncio.get_running_loop()
        lang = Utils.get_lang(None, ctx.message)

        lines = randint(2, 10)
        face = randint(1, 23)
        result = ''

        for _ in range(lines - 1):
            result += (await loop.run_in_executor(
                None, partial(get_generated_line, self.bot, ctx.message, 1,
                              10))).upper() + "\n@\n"

            result += (await loop.run_in_executor(
                None, partial(get_generated_line, self.bot, ctx.message, 1,
                              10))).upper()

        file = discord.File(filepath +
                            '/../data/burgut_faces/{0}.jpg'.format(face),
                            filename='{0}.jpg'.format(face))
        embed = discord.Embed(color=0xff546b,
                              title=locales[lang]['gen']['burgut_title'],
                              description=result)

        embed.set_image(url='attachment://{0}.jpg'.format(face))
        await ctx.send(file=file, embed=embed)
Пример #5
0
    async def d(self, ctx):
        lang = Utils.get_lang(None, ctx.message)

        try:
            lines = randint(2, 20)

            result = '```'
            for _ in range(lines):
                result += '> ' + \
                    get_generated_line(
                        ctx.message, 1, 10).capitalize() + "\n"
            result += '```'

            embed = discord.Embed(color=0xfcf36a,
                                  title=locales[lang]['gen']['dialogue_title'],
                                  description=result)
            await ctx.send(embed=embed)

        except Exception:
            await ctx.send(embed=Utils.error_embed(locales[lang]['errors']
                                                   ['too_late_gen']))
Пример #6
0
    async def b(self, ctx):
        lang = Utils.get_lang(None, ctx.message)

        try:
            lines = randint(2, 10)
            face = randint(1, 23)
            result = ''

            for _ in range(lines - 1):
                result += get_generated_line(ctx.message, 1,
                                             10).upper() + "\n@\n"
            result += get_generated_line(ctx.message, 1, 10).upper()

            file = discord.File(filepath +
                                '/../data/burgut_faces/{0}.jpg'.format(face),
                                filename='{0}.jpg'.format(face))
            embed = discord.Embed(color=0xff546b,
                                  title=locales[lang]['gen']['burgut_title'],
                                  description=result)
            embed.set_image(url='attachment://{0}.jpg'.format(face))
            await ctx.send(file=file, embed=embed)
        except Exception:
            await ctx.send(embed=Utils.error_embed(locales[lang]['errors']
                                                   ['too_late_gen']))
Пример #7
0
    async def d(self, ctx):
        lang = Utils.get_lang(None, ctx.message)
        loop = asyncio.get_running_loop()

        # try:
        lines = randint(2, 20)

        result = '```'
        for _ in range(lines):
            result += ('> ' + await loop.run_in_executor(
                None,
                partial(get_generated_line, self.bot, ctx.message, 1, 10, 5,
                        150, False))).capitalize() + "\n"
        result += '```'

        embed = discord.Embed(color=0xfcf36a,
                              title=locales[lang]['gen']['dialogue_title'],
                              description=result)
        await ctx.send(embed=embed)
Пример #8
0
 async def help(self, ctx):
     lang = Utils.get_lang(None, ctx.message)
     embed = discord.Embed(color=0x6cdbe0,
                           title=locales[lang]['help']['help_title'],
                           description=locales[lang]['help']['help_text'])
     await ctx.send(embed=embed)
Пример #9
0
    async def wipe(self, ctx):
        lang = Utils.get_lang(None, ctx.message)

        os.remove(filepath + f"/../samples/{ctx.guild.id}.txt")
        os.remove(filepath + f"/../samples/{ctx.guild.id}_img.txt")
        await ctx.send(embed=Utils.done_embed(locales[lang]['etc']['on_wipe']))