示例#1
0
 async def execute(self, arg):
     if self.module.mode == utility.getModType("message"):
         await self.executeMessage(arg)
     elif self.module.mode == utility.getModType("schedule"):
         await self.executeSchedule(arg)
     elif self.module.mode == utility.getModType("join"):
         await self.executeJoin(arg)
示例#2
0
def getModules(type):
    if type == utility.getModType("0"):
        return config.messageMod.actions
    elif type == utility.getModType("1"):
        return config.scheduleMod.actions
    elif type == utility.getModType("2"):
        return config.joinMod.actions
    else:
        return config.joinMod.actions + config.scheduleMod.actions + config.messageMod.actions
示例#3
0
def checkMode(mode):
    if config.openModule[-1].mode == utility.getModType("message"):
        if mode == "message" or mode == "m" or mode == "0":
            return 0
        elif mode == "username" or mode == "u" or mode == "1":
            return 1
        elif mode == "variable" or mode == "v" or mode == "2":
            return 2
        elif mode == "command" or mode == "c" or mode == "3":
            return 3
示例#4
0
def checkMode(mode):
    if config.openModule[-1].mode == utility.getModType("message"):
        if mode == "message" or mode == "0" or mode == "m":
            return 0
        elif mode == "giverole" or mode == "1" or mode == "gr":
            return 1
        elif mode == "removerole" or mode == "2" or mode == "rr":
            return 2
        elif mode == "variable" or mode == "3" or mode == "v":
            return 3
示例#5
0
def PrintModules(list):
    embed = discord.Embed(title="Modules", color=0x00ff00)
    i = 1
    string = ""
    for x in list:
        string += "**" + str(i) + ":** " + x.getName(
        ) + " - (" + utility.getModType(x.getMode()) + ")\n"
        i += 1
    if (len(list) == 0):
        string = "There are no defined modules"
    embed.add_field(name="-------------------", value=string, inline=True)
    return embed
示例#6
0
 def print(self, level):
     string = ""
     string += "Module '**" + self.name + "**' of type '**" + utility.getModType(
         str(self.mode)) + "** "
     if self.active == 1:
         string += "(active)"
     string += "\n"
     for ts in range(level):
         string += "|\t\t"
     string += "**Triggers**\n"
     if len(self.triggers) == 0:
         for ts in range(level):
             string += "|\t\t"
         string += "\t\t"
         string += "There are no triggers (the module will always execute)\n"
     else:
         for x in self.triggers:
             for ts in range(level):
                 string += "|\t\t"
             string += "\t\t"
             string += x.print() + "\n"
     for ts in range(level):
         string += "|\t\t"
     string += "**Actions**\n"
     if len(self.actions) == 0:
         for ts in range(level):
             string += "|\t\t"
         string += "\t\t"
         string += "There are no actions (nothing will happen if it executes)\n"
     else:
         for x in self.actions:
             for ts in range(level):
                 string += "|\t\t"
             string += "\t\t"
             string += x.print() + "\n"
     for ts in range(level):
         string += "|\t\t"
     string += "**Stored variables**\n"
     if len(self.variables) == 0:
         for ts in range(level):
             string += "|\t\t"
         string += "\t\t"
         string += "There are no variables"
     else:
         for x in self.variables:
             for ts in range(level):
                 string += "|\t\t"
             string += "\t\t"
             if x != self.variables[-1]:
                 string += str(x) + "\n"
             else:
                 string += str(x)
     return string
示例#7
0
async def crMod(ctx, name, type):
    if len(config.openModule) != 0:
        type = config.openModule[-1].mode
    else:
        father = 0
    if utility.getModType(type) == "noType":
        response = utility.getEmbed(
            "**Error creating the module:** Invalid type")
        await ctx.send(embed=response)
        return
    for x in getModules(-1):
        if x.name == name:
            response = utility.getEmbed(
                "**Error creating the module:** There is already a module with that name"
            )
            await ctx.send(embed=response)
            return
    config.openModule.append(Module.Module(name, utility.getModType(type)))
    response = utility.getEmbed("Created module **' " + name +
                                "'** with type **" + utility.getModType(type) +
                                "**")
    await ctx.send(embed=response)
示例#8
0
def PrintActiveModules():
    embed = discord.Embed(title="Active Modules", color=0x00ff00)
    i = 1
    string = ""
    for x in getModules(-1):
        if x.active == 1:
            string += "**" + str(i) + ":** " + x.getName(
            ) + " - (" + utility.getModType(x.getMode()) + ")\n"
            i += 1
    if (string == ""):
        string = "There are no active modules"
    embed.add_field(name="-------------------", value=string, inline=True)
    return embed
示例#9
0
 def checkState(self, message):
     if self.module.mode == utility.getModType("message"):
         if(self.mode == 0):
             return self.checkMessageContent(message.content)
         elif(self.mode == 1):
             return self.checkUserName(message)
         elif(self.mode == 2):
             return self.checkVariable()
         elif(self.mode == 3):
             return self.checkCommand()
         else:
             return False
     return False
示例#10
0
def checkArgs(mode, args):
    if config.openModule[-1].mode == utility.getModType("message"):
        if checkMode(mode) == 0:
            if len(args) != 2:
                return False
        elif checkMode(mode) == 1:
            if len(args) != 1:
                return False
        elif checkMode(mode) == 2:
            if len(args) != 2:
                return False
        elif checkMode(mode) == 3:
            if len(args) < 1:
                return False
    return True
示例#11
0
def updateData(mode):
    if utility.getModType(mode) == utility.getModType("0"):
        with open("msgModuleDat.p", "wb") as f:
            pickle.dump(config.messageMod, f)
    elif utility.getModType(mode) == utility.getModType("1"):
        with open("schModuleDat.p", "wb") as f:
            pickle.dump(config.scheduleMod, f)
    elif utility.getModType(mode) == utility.getModType("2"):
        with open("joinModuleDat.p", "wb") as f:
            pickle.dump(config.joinMod, f)
示例#12
0
async def CloseModule(ctx):
    if len(config.openModule) == 0:
        await ctx.channel.send(
            embed=utility.getEmbed("**Error:** No module opened"))
        return
    aux = config.openModule.pop()
    if len(config.openModule) == 0:
        if utility.getModType(aux.mode) == utility.getModType("0"):
            for x in config.messageMod.actions:
                if aux.getName() == x.getName():
                    config.messageMod.actions.remove(x)
                    break
            config.messageMod.actions.append(aux)
        elif utility.getModType(aux.mode) == utility.getModType("1"):
            for x in config.scheduleMod.actions:
                if aux.getName() == x.getName():
                    config.scheduleMod.actions.remove(x)
                    break
            config.scheduleMod.actions.append(aux)
        elif utility.getModType(aux.mode) == utility.getModType("2"):
            for x in config.joinMod.actions:
                if aux.getName() == x.getName():
                    config.joinMod.actions.remove(x)
                    break
            config.joinMod.actions.append(aux)
        else:
            print("Invalid type wtf this should not happen O.o\n")
            return
        updateData(aux.mode)
    else:
        for x in filterActions(config.openModule[-1].actions):
            if aux.getName() == x.getName():
                config.openModule[-1].actions.remove(x)
                break
        config.openModule[-1].actions.append(aux)
    await ctx.channel.send(embed=utility.getEmbed("Module Closed"))
    return