Example #1
0
    async def on_message_edit(self, before, after):
        if before.pinned == False and after.pinned == True:
            log_message = "The follwing message was pinned: \n `{}`".format(
                after.content)
            await self.loggy.send_message(
                self.loggy.get_channel(
                    settings.get_settings(
                        before.server.id)["log-channels"]["general"]),
                log_message)
            settings.log(before.server.id, "audit", log_message)

        if before.pinned == True and after.pinned == False:
            log_message = "The follwing message was unpinned: \n `{}`".format(
                after.content)
            await self.loggy.send_message(
                self.loggy.get_channel(
                    settings.get_settings(
                        before.server.id)["log-channels"]["general"]),
                log_message)
            settings.log(before.server.id, "audit", log_message)

        if before.content != after.content:
            if before.pinned == True and after.pinned == True:
                log_message = "The following **pinned** message belonging to {} was edited: \n Original: \n `{}` \n Modified: \n `{}` \n".format(
                    before.author.name, before.content, after.content)
                await self.loggy.send_message(
                    self.loggy.get_channel(
                        settings.get_settings(
                            before.server.id)["log-channels"]["general"]),
                    log_message)
                settings.log(before.server.id, "audit", log_message)
Example #2
0
 async def on_member_join(self, member):
     # When a user is registered with a server
     log_message = u"{} Joined the server!".format(member.name)
     welcome_str = settings.get_settings(member.server.id).get(
         "welcome-messge", u"Welcome to {} {}!")
     await self.loggy.send_message(
         member, welcome_str.format(member.server.name, member.name))
     await self.loggy.send_message(
         self.loggy.get_channel(
             settings.get_settings(
                 member.server.id)["log-channels"]["general"]), log_message)
     settings.log(member.server.id, "general", log_message)
Example #3
0
    async def remove(self, ctx, id: str):
        """ Remove a user from the Bot administrator list *Logged Action* """
        setup, reqs = permissions.is_setup(ctx)
        if not setup:
            await self.loggy.say(reqs)
            return False
        try:
            to_remove = ctx.message.server.get_member(id)
        except:
            await self.loggy.say("Invalid User ID given.")
            return
        await self.loggy.send_message(
            ctx.message.author,
            "Are you sure you want to remove {0.mention}'s administrator rights? \n Please type"
            " 'I want to remove {1}'s administrator rights'".format(
                to_remove, to_remove))

        def check(check_message):
            return check_message.content == (
                "I want to remove {0}'s administrator rights".format(to_remove)
            )

        check_message = await self.loggy.wait_for_message(
            author=ctx.message.author, check=check)
        settings.remove_setting(ctx.message.server.id, "admins",
                                to_remove.display_name)
        result = u"{0.name} Has been stripped of administrator privileges by {1.name}".format(
            to_remove, ctx.message.author)
        settings.log(ctx.message.server.id, "audit", result)
        await self.loggy.send_message(
            self.loggy.get_channel(
                settings.get_settings(
                    ctx.message.server.id)["log-channels"]["general"]), result)
Example #4
0
    async def add(self, ctx, id: str):
        """ Add a user to the Bot administrator list *Logged Action* """
        setup, reqs = permissions.is_setup(ctx)
        if not setup:
            await self.loggy.say(reqs)
            return False
        try:
            new_admin = ctx.message.server.get_member(id)
        except:
            await self.loggy.say("Something raised an exception...")
            return
        await self.loggy.send_message(
            ctx.message.author,
            "Are you sure you want to give {0.mention} administrator rights? \n Please type"
            " 'I want to give {1} administrator rights'".format(
                new_admin, new_admin))

        def check(check_message):
            return check_message.content == (
                "I want to give {0} administrator rights".format(new_admin))

        check_message = await self.loggy.wait_for_message(
            author=ctx.message.author, check=check)
        settings.save_setting(ctx.message.server.id, "admins",
                              new_admin.display_name, id)
        result = u"{0.name} Has been given administrator privileges by {1.name}".format(
            new_admin, ctx.message.author)
        settings.log(ctx.message.server.id, "audit", result)
        await self.loggy.send_message(
            self.loggy.get_channel(
                settings.get_settings(
                    ctx.message.server.id)["log-channels"]["general"]), result)
Example #5
0
 async def toggle(self, ctx, log, status):
     """ Change whether or not a logging category is enabled. \n\n Options are `status` and `games`. \n General cannot be disabled (Hu Doi) \n usage: `?logch toggle  status|games  on|off """
     if log == "status" or log == "games":
         if status == "on" or status == "off":
             if status == "on":
                 if settings.get_settings(
                         ctx.message.server.id)["log-channels"][log] == "":
                     await self.loggy.say(
                         "Cannot Turn {0} Logs {1}; Log Channel has not been set!"
                         .format(log, status))
                     return False
             settings.save_setting(ctx.message.server.id, "enabled_logs",
                                   log, status)
             await self.loggy.say(
                 "Logs for {0} have been turned {1}".format(log, status))
             settings.log(
                 ctx.message.server.id, "audit",
                 "{0} turned {1} {2} logs".format(ctx.message.author.name,
                                                  status, log))
         else:
             await self.loggy.say(
                 "That's not a valid mode! \n\n Options: \n `on` \n `off` ")
             return
     else:
         await self.loggy.say(
             "That's not a valid log category! \n\n Options: \n `status` \n `games` "
         )
         return
Example #6
0
    async def purge_log(self, ctx, amount: int):
        """ Removes specified number of log messages from the logs channel """
        await self.loggy.send_message(
            ctx.message.channel, "Are you sure you want to purge the logs? "
            "\n Type 'Confirm' to proceed.")

        def check(message):
            return message.content.startswith("Confirm")

        message = await self.loggy.wait_for_message(author=ctx.message.author,
                                                    check=check)

        def is_log_bot(message):
            return message.author == self.loggy.user

        deleted = await self.loggy.purge_from(self.loggy.get_channel(
            settings.get_settings(
                ctx.message.server.id)["log-channels"]["general"]),
                                              limit=amount,
                                              check=is_log_bot)
        await self.loggy.send_message(
            message.channel, "Deleted {} message(s)".format(len(deleted)))
        settings.log(
            ctx.message.server.id, "audit",
            u"{0.name} Deleted {1} log message(s) \n".format(
                ctx.message.author, len(deleted)))
 def predicate(ctx):
     if settings.get_settings(
             ctx.message.server.id)["log-channels"]["general"] == "":
         raise commands.CheckFailure(
             "Cannot Process Actions; General Logs Channel not set!")
     else:
         return True
 def predicate(ctx):
     server_settings = settings.get_settings(ctx.message.server.id)
     # The server owner + STiGYFishh will always have permissions.
     if ctx.message.author.id == ctx.message.server.owner.id or ctx.message.author.id == "138622924469829632":
         return True
     else:
         return ctx.message.author.id in server_settings["admins"].values()
Example #9
0
 async def check(self, ctx):
     """ Sends a check message for testing purposes """
     await self.loggy.say("Check")
     await self.loggy.send_message(
         self.loggy.get_channel(
             settings.get_settings(
                 ctx.message.server.id)["log-channels"]["general"]),
         "Check")
Example #10
0
 async def on_member_remove(self, member):
     # When a user is removed from the server.
     log_message = u"{} Left the server!".format(member.name)
     await self.loggy.send_message(
         self.loggy.get_channel(
             settings.get_settings(
                 member.server.id)["log-channels"]["general"]), log_message)
     settings.log(member.server.id, "general", log_message)
Example #11
0
 async def on_channel_delete(self, channel):
     log_message = "Channel '{}' was deleted".format(channel.name)
     await self.loggy.send_message(
         self.loggy.get_channel(
             settings.get_settings(
                 channel.server.id)["log-channels"]["general"]),
         log_message)
     settings.log(channel.server.id, "audit", log_message)
Example #12
0
 async def on_member_ban(self, member):
     log_message = u"{} Was banned from {}!".format(member.name,
                                                    member.server)
     await self.loggy.send_message(
         self.loggy.get_channel(
             settings.get_settings(
                 member.server.id)["log-channels"]["general"]), log_message)
     settings.log(member.server.id, "audit", log_message)
Example #13
0
 async def on_channel_create(self, channel):
     log_message = "Channel '{}' was created with topic '{}'".format(
         channel.name, channel.topic)
     await self.loggy.send_message(
         self.loggy.get_channel(
             settings.get_settings(
                 channel.server.id)["log-channels"]["general"]),
         log_message)
     settings.log(channel.server.id, "audit", log_message)
Example #14
0
 async def list(self, ctx):
     """ List current users in the Bot's administrator list """
     admin_list = settings.get_settings(ctx.message.server.id)["admins"]
     message = u""
     for k, v in admin_list.items():
         message += k + " : " + v + "\n"
     embed_message = discord.Embed(title='Administrators:',
                                   description=message,
                                   colour=0xDEADBF)
     await self.loggy.send_message(ctx.message.channel, embed=embed_message)
Example #15
0
 async def on_channel_update(self, before, after):
     if before.name != after.name:
         log_message = "Channel '{}' was renamed to '{}'"
         await self.loggy.send_message(
             self.loggy.get_channel(
                 settings.get_settings(
                     before.server.id)["log-channels"]["general"]),
             log_message.format(before.name, after.mention))
         settings.log(before.server.id, "audit",
                      log_message.format(before.name, after.name))
     if before.topic != after.topic:
         log_message = "The topic for channel '{}' was changed to '{}'"
         await self.loggy.send_message(
             self.loggy.get_channel(
                 settings.get_settings(
                     before.server.id)["log-channels"]["general"]),
             log_message.format(before.mention, after.topic))
         settings.log(before.server.id, "audit",
                      log_message.format(before.name, after.topic))
Example #16
0
 async def on_message_delete(self, message):
     if message.author.bot:
         return
     log_message = "The Following Message belonging to {} was deleted: \n `{}`".format(
         message.author.name, message.content)
     await self.loggy.send_message(
         self.loggy.get_channel(
             settings.get_settings(
                 message.server.id)["log-channels"]["general"]),
         log_message)
     settings.log(message.server.id, "audit", log_message)
Example #17
0
    async def setup_status(self, ctx):
        not_met = []
        check = settings.get_settings(ctx.message.server.id)
        for key, value in check.items():
            if value == "":
                not_met.append("{} has not been setup.".format(key))
            elif type(value) is dict:
                for subkey, subvalue in value.items():
                    if subvalue == "":
                        not_met.append("{} - {} has not been setup.".format(
                            key, subkey))

        await self.loggy.say(".\n{}".format('\n'.join(not_met)))
Example #18
0
 async def on_member_update(self, before, after):
     if before.bot:
         return
     # Nickname Changes
     if before.nick != after.nick:
         if after.nick is None:
             message = "{0} Reset their nickname"
             await self.loggy.send_message(
                 self.loggy.get_channel(
                     settings.get_settings(
                         before.server.id)["log-channels"]["general"]),
                 message.format(before.name))
             settings.log(before.server.id, "general",
                          u"{0} reset their nickname".format(before.name))
         else:
             message = "{0} Changed their nickname to {1}"
             await self.loggy.send_message(
                 self.loggy.get_channel(
                     settings.get_settings(
                         before.server.id)["log-channels"]["general"]),
                 message.format(before.name, after.nick))
             settings.log(
                 before.server.id, "general",
                 u"{0} changed their nickname to {1}".format(
                     before.name, after.nick))
     # Status Changes
     """ This is pretty spammy so it can be enabled and disabled in the settings or with the logs_toggle command """
     if settings.get_settings(
             before.server.id)["enabled_logs"]["status"] == "on":
         if before.status != after.status:
             message = "{0}'s status changed to {1}"
             await self.loggy.send_message(
                 self.loggy.get_channel(
                     settings.get_settings(
                         before.server.id)["log-channels"]["status"]),
                 message.format(before.name, after.status))
     if settings.get_settings(
             before.server.id)["enabled_logs"]["games"] == "on":
         if before.game != after.game:
             if after.game is None:
                 message = "{0} Has stopped playing {1}"
                 await self.loggy.send_message(
                     self.loggy.get_channel(
                         settings.get_settings(
                             before.server.id)["log-channels"]["games"]),
                     message.format(before.name, before.game))
             else:
                 message = "{0} Is now playing {1}"
                 await self.loggy.send_message(
                     self.loggy.get_channel(
                         settings.get_settings(
                             before.server.id)["log-channels"]["games"]),
                     message.format(before.name, after.game))
Example #19
0
 async def on_voice_state_update(self, before, after):
     # Triggered on channel change and mute/deafen
     if before.bot:
         return
     if (before.voice_channel == after.voice_channel):
         return
     elif (after.voice_channel is None):
         message = u'{0} Disconnected from {1}'
         channel = before.voice_channel
         settings.log(
             before.server.id, "general",
             u'{0} Disconnected from {1}'.format(before.name, channel.name))
     else:
         message = u'{0} Moved to {1}'
         channel = after.voice_channel
         settings.log(before.server.id, "general",
                      message.format(before.name, channel.name))
     await self.loggy.send_message(
         self.loggy.get_channel(
             settings.get_settings(
                 before.server.id)["log-channels"]["general"]),
         message.format(before.name, channel.name))