示例#1
0
def is_hushed(log_event, guild_id, channel_id, user_id):

    #loading storage
    guilds = storage.load()
    current_log_data = guilds[guild_id][channel_id]["data"]

    if log_event in current_log_data:
        if user_id in current_log_data[log_event]["ignored_users"]:
            return True
    else:
        if user_id in current_log_data["ignored_users"]:
            return True
        else:
            return False
示例#2
0
    def remove_event(self, event):
        if len(event.args) >= 1:

            #Loading the storage
            guilds = storage.load()

            #Setting some variables
            guild_id = str(event.guild.id)
            channel_id = str(event.msg.channel_id)
            not_log_event = []
            not_logging = []
            removed_log_event = []

            #Checking permissions
            if not is_allowed(guild=event.msg.guild, user=event.msg.author):
                return event.msg.reply(response.command.invalid_permissions)

            #Make sure the channel is a log channel
            if channel_id not in guilds[guild_id]:
                return event.msg.reply(response.command.not_log_event)

            #Make sure the log event is valid
            for log_event in event.args:
                log_event = log_event.upper()
                if log_event in user_events:
                    if log_event not in guilds[guild_id][channel_id]["events"]:
                        not_logging.append(log_event)
                    else:
                        guilds[guild_id][channel_id]["events"].remove(
                            log_event)
                        removed_log_event.append(log_event)
                else:
                    not_log_event.append(log_event)
            storage.write(guilds)
            if len(removed_log_event):
                event.msg.reply(
                    response.command.removed_log_events.format(
                        "`, `".join(removed_log_event)))
            if len(not_logging):
                event.msg.reply(
                    response.command.not_logging.format(
                        "`, `".join(not_logging)))
            if len(not_log_event):
                event.msg.reply(
                    response.command.not_log_events.format(
                        "`, `".join(not_log_event)))

        else:
            return event.msg.reply(response.not_enough_arguments)
示例#3
0
    def add_log(self, event):

        #Load the storage
        guilds = storage.load()

        #Setting some variables
        guild_id = str(event.msg.guild.id)
        channel_id = str(event.msg.channel_id)

        #Checking permissions
        if not is_allowed(guild=event.msg.guild, user=event.msg.author):
            return event.msg.reply(response.command.invalid_permissions)

        #Add the guild if they are not in the database then reload the database
        if guild_id not in guilds:
            storage.add_guild(guild_id)
        guilds = storage.load()

        #Erroring if the channel is already a log
        if channel_id in guilds[guild_id]:
            return event.msg.reply(response.command.already_log)
        else:
            storage.add_log(guild_id, channel_id)
            return event.msg.reply(response.command.log_added)
示例#4
0
    def member_join_static(self, event):
        log_event = "USER_JOIN"
        guilds = load()
        guild_id = str(event.member.guild_id)
        user = event.member
        send_message = self.bot.client.api.client.channels_messages_create
        
        
        if guild_id not in guilds:
            return
        
        
        if len(guilds[guild_id]) == 0:
            return
        
        
        for log in guilds[guild_id]:
            if log_event in log["events"]:
                if log_event in log["data"]:
                    return
                    #TODO: Custom data handling as per custom processing
                    #create_custom_message(log)
            else:
                #TODO: Default event handling
                if log["type"] == "rich":
                    response = create_log_embed(log_event, event)
                    
                    send_message(int(log),
                                 content=response[0],
                                 embed=response[1])
                else:
                    send_message(int(log),
                                 response_to_class(log["type"], log_event))



    #TODO: Member Leave
    #TODO: Member Updated
    #TODO: Role Created
    #TODO: Role Updated
    #TODO: Role Deleted
    #TODO: Member Presence Update
    #TODO: Voice State Updated
    #TODO: Voice Server Updated
    #TODO: Webhooks Updated
    #TODO: Non-Bot Embeds
示例#5
0
    def log_type(self, event):

        #Assigning some variables
        guilds = storage.load()
        guild_id = str(event.guild.id)
        channel_id = str(event.msg.channel_id)
        log_types = {
            "simple": "compact",
            "plain": "compact",
            "compact": "compact",
            "fanceh": "fanceh",
            "fancy-ish": "fanceh",
            "fancy": "rich",
            "rich": "rich"
        }

        #Permission checking
        if not is_allowed(guild=event.msg.guild, user=event.msg.author):
            event.msg.reply(response.command.invalid_permissions)

        #Checking the guild for data
        if guild_id not in guilds:
            return event.msg.reply(response.command.no_guild_data)

        #Checking if the channel is a log
        if channel_id not in guilds[guild_id]:
            return event.msg.reply(response.command.not_log)

        #Make sure they supplied an argument
        if len(event.args):
            if event.args[0] in log_types:

                #Check if the log is already that style
                if log_types[
                        event.args[0]] == guilds[guild_id][channel_id]["type"]:
                    return event.msg.reply(response.command.already_log_type)

                guilds[guild_id][channel_id]["type"] = log_types[event.args[0]]
                storage.write(guilds)
                event.msg.reply(
                    response.command.changed_log_type.format(
                        log_types[event.args[0]]))
        else:
            event.msg.reply(response.command.not_enough_arguments)
示例#6
0
    def log_list(self, event):

        #loading storage
        guilds = storage.load()

        #Assigning some variables
        guild_id = str(event.guild.id)

        #Checking to make sure the guild exists in the database
        if guild_id not in guilds:
            return event.msg.reply(response.command.no_guild_data)

        #Checking permissions
        if not is_allowed(guild=event.msg.guild, user=event.msg.author):
            return event.msg.reply(response.command.invalid_permissions)

        #Creating and sending the message
        logs = "<#" + ">, <#".join(guilds[guild_id].keys()) + ">"
        event.msg.reply(response.command.log_list.format(logs))
示例#7
0
def is_allowed(guild, user, perm_type="default", role="logger"):

    #Loading storage & config
    guilds = storage.load()
    config = load_config()

    #Assigning some variables
    guild_id = str(guild.id)
    user_id = user.id

    if perm_type == "default":
        if user_id == guild.owner.id:
            return True
        elif guild.get_permissions(user).to_dict()["manage_channels"]:
            return True
        return False
    elif perm_type == "global":
        if user_id in config["user"]["admin_ids"]:
            return True
        return False
示例#8
0
    def list_events(self, event):

        #Loading the storage
        guilds = storage.load()

        #Assigning some variables
        guild_id = str(event.guild.id)
        channel_id = str(event.msg.channel_id)

        #Checking permissions
        if not is_allowed(guild=event.msg.guild, user=event.msg.author):
            return event.msg.reply(response.command.invalid_permissions)

        #Ensuring the channel is a logging channel
        if channel_id not in guilds[guild_id]:
            return event.msg.reply(response.command.no_event_list)

        #Sending the channel list to chat.
        events = ", ".join(guilds[guild_id][channel_id]["events"])
        return event.msg.reply(response.command.event_list.format(events))
示例#9
0
    def remove_log(self, event, channel_id=None):

        #Load the storage
        guilds = storage.load()

        #Setting some variables
        guild_id = str(event.guild.id)
        channel_id = str(event.msg.channel_id)

        #Checking permissions
        if not is_allowed(guild=event.msg.guild, user=event.msg.author):
            return event.msg.reply(response.command.invalid_permissions)

        #Make sure the guild is in the database
        if guild_id not in guilds:
            return event.msg.reply(response.command.no_guild_data)

        if channel_id not in guilds[guild_id]:
            return event.msg.reply(response.command.not_log_remove)
        else:
            storage.remove_log(guild_id, channel_id)
            return event.msg.reply(response.command.log_removed)
示例#10
0
def create_log_embed(event_type, event, custom=False, data={}):
    guilds = load()
    embed = MessageEmbed()

    if not custom:
        log_message = response_to_class("rich", event_type)
        content = log_message[0]
        if log_message[0] != None:
            content = log_message[0].format(e=event)

        embed.title = log_message[1]
        if log_message != None:
            embed.title = log_message[1].format(e=event)

        embed.description = log_message[2]
        if log_message[2] != None:
            embed.description = log_message[2].format(e=event)

        embed.footer.text = log_message[3]
        if log_message[3] != None:
            embed.footer.text = log_message[3].format(e=event)

        embed.url = log_message[4]
        if log_message[4] != None:
            embed.url = log_message[4].format(e=event)
        embed.color = log_message[5]
    """else:   #IGNORE FOR NOW
        if "content" in data:
            content = data["content"]
        
        if "title" in data:
            title = data["title"]
        
        if "desciption" in data:
            desciption = data["response"]"""

    return [content, embed]