Example #1
0
def on_message_edit(before: discord.Message, after: discord.Message):
    """Chamado sempre que uma mensagem é editada."""
    if before.channel.is_private:
        return
    if before.author.id == bot.user.id:
        return
    if before.content == after.content:
        return
    before_decoded = decode_emoji(before.clean_content)
    after_decoded = decode_emoji(after.clean_content)

    log.info("@{0} edited a message in #{3} ({4}):\n\t'{1}'\n\t'{2}'".format(before.author.name, before_decoded,
                                                                                 after_decoded, before.channel,
                                                                                 before.server))
Example #2
0
def on_command(command, ctx):
    """Chamado toda vez que um comando é utilizado. Usado para armazenar logs dos comandos em um arquivo."""
    if ctx.message.channel.is_private:
        destination = 'PM'
    else:
        destination = '#{0.channel.name} ({0.server.name})'.format(ctx.message)
    message_decoded = decode_emoji(ctx.message.content)
    log.info('Command by {0} in {1}: {2}'.format(ctx.message.author.display_name, destination, message_decoded))
Example #3
0
 async def on_command(self, ctx: Context):
     """Called when a command is used. Used to log commands on a file."""
     if isinstance(ctx.message.channel, abc.PrivateChannel):
         destination = 'PM'
     else:
         destination = '#{0.channel.name} ({0.guild.name})'.format(
             ctx.message)
     message_decoded = decode_emoji(ctx.message.content)
     log.info('Command by {0} in {1}: {2}'.format(
         ctx.message.author.display_name, destination, message_decoded))
Example #4
0
def on_message_delete(message: discord.Message):
    """Chamado sempre que uma mensagem for deletada."""
    if message.channel.name == ask_channel_name:
        return

    message_decoded = decode_emoji(message.clean_content)
    attachment = ""
    if message.attachments:
        attachment = "\n\tAttached file: "+message.attachments[0]['filename']
    log.info("A message by @{0} was deleted in #{2} ({3}):\n\t'{1}'{4}".format(message.author.display_name,
                                                                               message_decoded, message.channel.name,
                                                                               message.server.name, attachment))
Example #5
0
    async def on_message_edit(self, before: discord.Message,
                              after: discord.Message):
        """Called every time a message is edited."""
        # Ignore bot messages
        if before.author.id == self.user.id:
            return

        # Ignore private messages
        if isinstance(before.channel, abc.PrivateChannel):
            return

        # Ignore if content didn't change (usually fired when attaching files)
        if before.content == after.content:
            return

        before_decoded = decode_emoji(before.clean_content)
        after_decoded = decode_emoji(after.clean_content)

        log.info(
            "@{0} edited a message in #{3} ({4}):\n\t'{1}'\n\t'{2}'".format(
                before.author.name, before_decoded, after_decoded,
                before.channel, before.guild))
Example #6
0
    async def on_message_delete(self, message: discord.Message):
        """Called every time a message is deleted."""
        if message.channel.name == config.ask_channel_name:
            return

        message_decoded = decode_emoji(message.clean_content)
        attachment = ""
        if message.attachments:
            attachment = "\n\tAttached file: " + message.attachments[0][
                'filename']
        log.info(
            "A message by @{0} was deleted in #{2} ({3}):\n\t'{1}'{4}".format(
                message.author.display_name, message_decoded,
                message.channel.name, message.guild.name, attachment))