コード例 #1
0
async def LoadBackup(ctx):
    if config.backup == 0:
        await ctx.channel.send(embed=utility.getEmbed(
            "There is no backup saved, use .SaveBackup [.sb] to save the current open Modules"
        ))
        return
    config.openModule = config.backup.copy()
    await ctx.channel.send(embed=utility.getEmbed("Backup loaded"))
コード例 #2
0
async def ShowOpenModule(ctx):
    if len(config.openModule) == 0:
        string = utility.getEmbed("No module is open")
    else:
        string = utility.getEmbed("The module **" +
                                  config.openModule[-1].getName() +
                                  "** is opened")
    await ctx.channel.send(embed=string)
コード例 #3
0
async def ModuleCheckState(ctx):
    if len(config.openModule) == 0:
        await ctx.channel.send(
            embed=utility.getEmbed("There is no open module"))
        return
    if config.openModule[-1].active == 1:
        await ctx.channel.send(embed=utility.getEmbed("Active"))
    else:
        await ctx.channel.send(embed=utility.getEmbed("Not Active"))
コード例 #4
0
async def toggleMainteinance(ctx):
    if config.mainteinance == 0:
        config.mainteinance = 1
        response = utility.getEmbed(
            "Mainteinance mode is now on, all modules disabled")
        await ctx.send(embed=response)
    else:
        config.mainteinance = 0
        response = utility.getEmbed(
            "Mainteinance mode is now of, normal configurations restored")
        await ctx.send(embed=response)
コード例 #5
0
async def setActiveModule(ctx, set):
    if len(config.openModule) == 0:
        await ctx.channel.send(
            embed=utility.getEmbed("There is no open module"))
        return
    if set == "enable":
        activity = 1
    elif set == "disable":
        activity = 0
    else:
        set == abs(config.openModule[-1].active - 1)
    config.openModule[-1].active = activity
    response = utility.getEmbed("The module **" + config.openModule[-1].name +
                                "** is now " + set + "d")
    await ctx.send(embed=response)
コード例 #6
0
async def die(ctx):
    with open("deathcounter.p", "rb") as f:
        num = pickle.load(f)
    num = int(num) + 1
    with open("deathcounter.p", "wb") as f:
        pickle.dump(num, f)
    await ctx.channel.send(embed=utility.getEmbed("I have died " + str(num) +
                                                  " times"))
    await config.client.logout()
コード例 #7
0
async def DeleteModule(ctx):
    if len(config.openModule) == 0:
        await ctx.channel.send(embed=utility.getEmbed("No module is open"))
        return
    aux = config.openModule.pop()
    if len(config.openModule) == 0:
        for x in getModules(aux.mode):
            if x.name == aux.name:
                getModules(aux.mode).remove(x)
                await ctx.channel.send(
                    embed=utility.getEmbed("Deleted the module **" + aux.name +
                                           "**"))
                updateData(aux.mode)
                return
    for x in config.openModule[-1].actions:
        if x.name == aux.name:
            config.openModule[-1].actions.remove(x)
    await ctx.channel.send(embed=utility.getEmbed("Deleted the module **" +
                                                  aux.name + "**"))
コード例 #8
0
async def crTrigger(ctx, *args):
    if len(config.openModule) == 0:
        await ctx.channel.send(embed=utility.getEmbed(
            "Error: No module is open, please open a module first with .OpenModule [.om]"
        ))
        return
    argl = list(args)
    if len(argl) < 2:
        await ctx.channel.send(
            embed=utility.getEmbed("Error: Invalid arguments"))
        return
    name = argl.pop(0)
    mode = argl.pop(0)
    if not checkArgs(mode, argl):
        await ctx.channel.send(
            embed=utility.getEmbed("Error: Invalid arguments"))
        return
    n = Trigger.Trigger(name, checkMode(mode), config.openModule[-1], argl)
    config.openModule[-1].addTrigger(n)
    await ctx.channel.send(embed=utility.getEmbed("Created Trigger"))
コード例 #9
0
async def OpenModule(ctx, name):
    if len(config.openModule) != 0:
        list = filterActions(config.openModule[-1].actions)
    else:
        list = getModules(3)
    for x in list:
        if not isinstance(x, Module.Module):
            continue
        if x.name == name:
            config.openModule.append(x)
            await ctx.channel.send(embed=utility.getEmbed("Module **" + name +
                                                          "** opened"))
            return
    if len(config.openModule) != 0:
        await ctx.channel.send(embed=utility.getEmbed(
            "**Error:** That module doesn't exist in module **" +
            config.openModule[-1].name + "**"))
    else:
        await ctx.channel.send(
            embed=utility.getEmbed("**Error:** That module doesn't exist"))
コード例 #10
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)
コード例 #11
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
コード例 #12
0
async def CancelEdit(ctx):
    config.openModule.clear()
    await ctx.channel.send(
        embed=utility.getEmbed("Closed modules without saving"))
コード例 #13
0
async def SaveBackup(ctx):
    config.backup = config.openModule.copy()
    await ctx.channel.send(embed=utility.getEmbed(
        "Backup saved, use .LoadBackup [.lb] to load it"))
コード例 #14
0
async def DisplayModule(ctx):
    if len(config.openModule) == 0:
        await ctx.channel.send(embed=utility.getEmbed(
            "There is no open module, use .OpenModule [.om] to open a module"))
        return
    await ctx.channel.send(config.openModule[-1].print(0))