Пример #1
0
    async def on_reaction_add(self, reaction, user):
        logger.trace("reaction: {}", reaction)
        ctx = await self.bot.get_context(reaction.message)
        regex = r"\w+(?:\-\d+){3,4}$"

        # TODO: use discord.py native emoji classes for comparison
        if any(x in str(reaction) for x in Quotes.reactions):
            logger.info("sending image from reaction: {}", str(reaction))
            await self.image(ctx, query=reaction.message.content)
        elif any(x in str(reaction) for x in Quotes.react_next
                 ) and reaction.message.author == self.bot.user:
            footer = reaction.message.embeds[0].footer.text
            if footer:
                match = re.search(regex, footer)
                logger.trace(f"footer: {footer}")
                await self.id(ctx, move_id(match.group(), 1))
        elif any(x in str(reaction) for x in Quotes.react_previous
                 ) and reaction.message.author == self.bot.user:
            footer = reaction.message.embeds[0].footer.text
            if footer:
                match = re.search(regex, footer)
                logger.trace(f"footer: {footer}")
                await self.id(ctx, move_id(match.group(), -1))

        await logger.complete()
Пример #2
0
    async def on_command_error(self, ctx, exception):
        args = " ".join(exception.args)

        if isinstance(
                exception,
            (commands.errors.BadArgument,
             commands.errors.MissingRequiredArgument),
        ):
            await ctx.channel.send(
                f"\N{CROSS MARK} Bad argument: {args}",
                delete_after=10,
            )
            logger.info(f"Bad arguments: {args}")
            await logger.complete()

        elif isinstance(
                exception,
                commands.errors.CommandNotFound,
        ):
            await ctx.channel.send(
                f"\N{CROSS MARK} Command not found: {ctx.invoked_with}",
                delete_after=10,
            )
            logger.info(f"Command not found: {ctx.invoked_with}")
            await logger.complete()
        else:
            with configure_scope() as scope:
                scope.set_extra("username", str(ctx.author))
                scope.set_extra("invoked_with", ctx.invoked_with)
                scope.set_extra("args", ctx.args)
                scope.set_extra("kwargs", ctx.kwargs)
                capture_exception(exception)
                raise exception
Пример #3
0
    def thumbnail(self, time, dest, text):
        text_clip = VideoFile._generate_text(text)
        text_clip.duration = self.video_clip.duration
        video = CompositeVideoClip([self.video_clip, text_clip])
        video.duration = self.video_clip.duration

        try:
            video.save_frame(dest, t=(time + 1.0))
            logger.info("writing out thumbnail: {}", dest)
        except ValueError:
            logger.opt(
                exception=True).debug("Exception logged with debug level:")
Пример #4
0
def mkv_task(index: str, folder: str, task_name):
    for file in get_mkvs(folder):
        task_job = task_name.delay(index, file.path)
        logger.info("submitting {} task: {}", task_name, task_job)
Пример #5
0
def list_files(c, folder):
    for file in get_mkvs(folder):
        logger.info("found file: {}", file)
Пример #6
0
def finish_indexing(count):
    logger.info("finished indexing {} episodes".format(count))
Пример #7
0
 async def on_ready(self):
     logger.info("{} has connected to Discord!", self.user)
Пример #8
0
 async def on_command(self, ctx):
     logger.info(
         'Triggered command "{}" via guild "{}" user "{}" channel "{}"'.
         format(str(ctx.command), str(ctx.guild), str(ctx.author),
                str(ctx.channel)))
     await logger.complete()
Пример #9
0
 async def on_ready(self):
     logger.info("{} cog {} is ready", str(self.bot.user),
                 str(self.qualified_name))
     await logger.complete()
Пример #10
0
 async def on_guild_post(self):
     logger.info("Server count posted successfully")