async def showalltempo(ctx):
    global ctxGlobal
    ctxGlobal = ctx
    f = open(file_name, "r")
    bruteText = f.read()
    f.close()

    if len(bruteText) > 0:
        temp = bruteText.split("\n")
        r = []
        for i in range(0, len(temp)):
            r.append(cmdParse(temp[i]))

    embed = discord.Embed(title="temporizadores ", color=discord.Color.blue())

    if len(bruteText) > 0:
        for i in range(0, len(r)):
            embed.add_field(name="nombre: " + r[i]["name"],
                            value=r[i]["temp"],
                            inline=False)
    else:
        embed.add_field(
            name="No hay temporizadores disponibles ",
            value=
            "puedes aƱadir temporizadores con el comando: $tempo nombre_temporizador>intervalo1:intervalo2...>sonido.mp3 (los sonidos todavia no estan disponibles)"
        )

    await ctxGlobal.send(embed=embed)
async def rmtempo(ctx, name):
    global ctxGlobal
    ctxGlobal = ctx
    global temporizers
    global temporizators
    global file_name
    f = open(file_name, "r")
    txt = f.read()
    f.close()
    tot = ""
    print(txt)

    txt = txt.split("\n")
    for i in range(0, len(txt)):
        r = cmdParse(txt[i])
        if r["name"] != name:
            if (i == len(txt) - 1):
                tot = tot + txt[i]
            else:
                tot = tot + txt[i] + "\n"
        else:
            if i == len(txt) - 1:
                tot = tot[0:len(tot) - 1]
    f = open(file_name, "w")
    f.write(tot)
    f.close()

    temporizators = loadTimerbots(file_name)
    timerBotAdder()
async def tempo(ctx, cmd):
    global ctxGlobal
    ctxGlobal = ctx
    global temporizers
    f = open(file_name, "a")
    print(temporizers)
    if len(temporizers) > 0:
        f.write("\n" + cmd)
    else:
        f.write(cmd)
    f.close()
    r = cmdParse(cmd)  # "name", "temp", "sound"
    print(cmd)

    temporizers.append({
        "name": r["name"],
        "timerbot": timerbot(),
        "sound": r["sound"]
    })
    acumulator = 0

    for j in range(0, len(r["temp"])):
        acumulator = acumulator + r["temp"][j]
        temporizers[len(temporizers) - 1]["timerbot"].add_timeout(
            acumulator, timOut, {
                "final": FINAL1,
                "step": STEP1,
                "iter": len(temporizers) - 1
            }, "tempo" + str(len(temporizers) - 1))
async def showtempo(ctx, name):
    global ctxGlobal
    ctxGlobal = ctx
    f = open(file_name, "r")
    bruteText = f.read()
    f.close()

    temp = bruteText.split("\n")
    r = []
    for i in range(0, len(temp)):
        r.append(cmdParse(temp[i]))

    for i in range(0, len(r)):
        if r[i]["name"] == name:
            embed = discord.Embed(title="temporizador " + name,
                                  color=discord.Color.blue())
            embed.add_field(name="tiempos", value=r[i]["temp"])
        else:
            continue
    await ctxGlobal.send(embed=embed)
def timerBotAdder():
    global temporizators
    global temporizers
    if (len(temporizators) > 0):
        for i in range(0, len(temporizators)):
            acumulator = 0
            r = cmdParse(temporizators[i])
            temporizers.append({
                "name": r["name"],
                "timerbot": timerbot(),
                "sound": r["sound"]
            })
            for j in range(0, len(r["temp"])):
                acumulator = acumulator + r["temp"][j]
                # ojo!, timOut es una funcion generica todavia no declarada
                temporizers[i]["timerbot"].add_timeout(acumulator, timOut, {
                    "final": FINAL1,
                    "step": STEP1,
                    "iter": i
                }, "tempo" + str(i))
    else:
        temporizers = []