Exemple #1
0
async def check_count(client, server, member):
    global reach
    count = server.member_count - 3
    channel = client.get_channel("405502332902703106")

    path_file = "SETTINGS/" + server.id + "/reach.txt"
    path_drop = "/Gear_Two/reach.txt"

    if not path.isfile(path_file):
        f = open(path_file, "w")
        f.write("0")
        f.close()
    try:

        use.drop_down(path_drop, path_file)

        with open(path_file) as f:
            content = f.readlines()
            content = [x.strip() for x in content]
            f.close()
        reach = int(content[0])

    except:
        print("upload reach")
        await update_reach(reach, path_file, path_drop)

    if count == 100 and reach == 0:
        reach = 1
        await update_reach(reach, path_file, path_drop)

        await one_hundered(client, server, channel, member)

    print("Success")
Exemple #2
0
async def send(client,channel):
    global first
    dbx = dropbox.Dropbox(CONECT.DROP_TOKEN)
    res = dbx.files_list_folder("/Pictures/main")
    file_list = []
    for file in res.entries:
        file_list.append(file.name)

    if len(file_list) > 0:
        send_name = random.choice(file_list)

        path_drop = '/Pictures/main/' + send_name
        path_file = "data/temp/" + send_name

        use.drop_down(path_drop, path_file)

        print("mid")
        if first == 1:
            first = 0
            await client.send_message(channel, "Hey, hey, hey\nSaucy Bot is online and will currently send a picture every day XD!!!")

        await client.send_file(channel, path_file)
        print("send")
        from_path = "/Pictures/main/" + send_name
        to_path = "/Pictures/output/" + send_name

        dbx.files_move_v2(from_path, to_path, allow_shared_folder=False, autorename=True)

        os.remove(path_file)
        increase_down_count(dbx)
    else:
        print ("Empty")
Exemple #3
0
async def get_picture_refuel(client, channel):
    path_drop = '/Pictures/info/images/refueled.png'
    path_file = "data/temp/refueled.png"
    use.drop_down(path_drop, path_file)
    print("mid")
    await client.send_file(channel, path_file)
    print("send")
    os.remove(path_file)
Exemple #4
0
def download_custom():
    path_file = "data/temp/custom.txt"
    path_drop = "/Gear_Two/custom.txt"

    try:
        use.drop_down(path_drop, path_file)
    except:
        if not path.isfile(path_file):
            f = open(path_file, "w")
            f.write("0\n")
            f.close()
Exemple #5
0
async def reset_info(dbx,client,channel):
    await client.send_message(channel, "Info reseted")

    path_file = "data/info_reset.txt"
    path_drop = "/Pictures/info/name_info_reset.txt"

    use.drop_down(path_drop, path_file)

    up = open(path_file, 'rb')
    dbx.files_upload(up.read(), "/Pictures/info/name_info.txt", mode=WriteMode('overwrite'))
    up.close()
    os.remove(path_file)
Exemple #6
0
async def give_juice(client, server, channel, message):
    global send_channel, delta_add

    tday = dt.utcnow().date()

    ti = str(dt.utcnow()).split(" ")[1].split(":")[0:2]
    cur_time = time_create(int(ti[0]) + 2, int(ti[1]))

    user = message.author

    path_file = "data/temp/give_info.txt"
    path_drop = "/Pictures/info/give_info.txt"

    try:
        use.drop_down(path_drop, path_file)
    except:
        print("No file found!")

    if not path.isfile("data/temp/give_info.txt"):
        f = open(path_file, "w")
        f.write("0")
        f.close()

    with open(path_file) as f:
        content = f.readlines()
        content = [x.strip() for x in content]
        f.close()
    if content[0] != "0":
        delta_add = datetime.timedelta(days=0)
        if check_for_new_day(content[0], tday, cur_time, 0):
            if check_player_can(content, user, tday, cur_time):
                await uploader.send(client, send_channel)
                #print ("Would send!!!!!!!")
                update_give_info(user, tday, path_file, path_drop)

            else:
                #Send "You can not request more than one picture within 3 days..."
                till = get_till(content[0], tday, cur_time, 3)
                await use.error((
                    "You can not request more than one picture within 3 days...\nYou have to wait %s."
                    % till), message.channel, client)

        else:
            #Send "You have to wait till the next day..."
            await use.error(
                "Juice was already given today. \nYou have to wait till the next day...",
                message.channel, client)

    else:
        await uploader.send(client, send_channel)
        update_give_info(user, tday, path_file, path_drop)
Exemple #7
0
async def get_upload_count(dbx,client,channel):


    path_drop = "/Pictures/info/name_info.txt"
    path_file = "data/info.txt"

    use.drop_down(path_drop, path_file)

    with open("data/info.txt") as f:
        content = f.readlines()
        content = [x.strip() for x in content]
        await client.send_message(channel, "%s pictures have been uploaded." % content[0])

    os.remove("data/info.txt")
Exemple #8
0
async def init_antispam_status(server):
    global status
    file_path = "SETTINGS/" + server.id + "/antispam_status.txt"
    drop_path = "/Gear_Two/antispam_status.txt"

    try:
        use.drop_down(drop_path, file_path)
        with open(file_path) as f:
            content = f.readlines()
            content = [x.strip() for x in content]
            f.close()

        status = int(content[0])
    except:
        print("No file uploaded! (antispam_status.txt)")
Exemple #9
0
def error_process(error):

    path_file = "data/temp/error.txt"
    path_drop = "/Pictures/info/error.txt"

    use.drop_down(path_drop, path_file)

    with open(path_file, "a") as myfile:
        new_id = "\n" + str(error)
        myfile.write(new_id)
        myfile.close()

    use.drop_up(path_drop, path_file)

    os.remove(path_file)
Exemple #10
0
def members_auth2(server):
    dbx = dropbox.Dropbox(CONECT.DROP_TOKEN)

    loc_path = "SETTINGS/" + server.id + "/permission_type2.txt"

    drop_path = "/Gear_Two/permission_type2.txt"
    try:
        use.drop_down(drop_path, loc_path)
    except:
        print("File not in Dropbox.")

    with open(loc_path) as f:
        content = f.readlines()
    content = [x.strip() for x in content]

    return content
Exemple #11
0
async def add_auth2(client, server, channel, member):
    file_path = "SETTINGS/" + server.id + "/permission_type2.txt"
    drop_path = "/Gear_Two/permission_type2.txt"
    try:
        use.drop_down(drop_path, file_path)
    except:
        print("File not in Dropbox.")
    if await use.dev_authorisation_type2(server, member) == False:
        with open(file_path, "a") as myfile:
            new_id = "\n" + str(member.id)
            myfile.write(new_id)
            myfile.close()

        use.drop_up(drop_path, file_path)
        await client.send_message(
            channel, "Authorisation granted to %s" % member.mention)
    else:
        await client.send_message(
            channel, "Member %s already has authorisation2" % member.mention)
Exemple #12
0
async def delete_auth2(client, server, channel, user):
    file_path = "SETTINGS/" + server.id + "/permission_type2.txt"
    drop_path = "/Gear_Two/permission_type2.txt"
    try:
        use.drop_down(drop_path, file_path)
    except:
        print("File not in Dropbox.")

    if await use.dev_authorisation_type2(server, user):
        f = open(file_path, "r")
        lines = f.readlines()
        f.close()

        f = open(file_path, "w")
        for line in lines:
            if line != str(user.id) + "\n":
                f.write(line)
        f.close()

        use.drop_up(drop_path, file_path)
        await client.send_message(
            channel, "Authorisation off %s deleted!" % user.mention)
    else:
        await client.send_message(channel, "You do not have auth2.")
Exemple #13
0
async def re_status(client, main_loop, server):
    global status

    path_file = "data/temp/status.txt"
    path_drop = "/Pictures/info/status.txt"


    use.drop_down(path_drop, path_file)

    with open(path_file) as f:
        content = f.readlines()
        content = [x.strip() for x in content]
        f.close()

    if content[0] != str(status):
        print ("Error")
        error_process("Status reset!")

    status = int(content[0])

    if status == 1:
        await check_for_channel_file(client, None, server)
        # Start the thread
        threading.Thread(name='sender_loop', target=sender_loop, args=(client, main_loop)).start()
Exemple #14
0
async def check_for_channel_file(client, channel, server):
    global send_channel
    path_channel = "data/temp/channel.txt"
    path_dbx = "/Pictures/info/channel.txt"

    try:
        use.drop_down(path_dbx,path_channel)

    except:
        print("No online file")


    if not path.isfile(path_channel):
        if channel != None:
            await client.send_message(channel, "No channel was previously set.")
    else:
        with open(path_channel) as f:
            content = f.readlines()
            content = [x.strip() for x in content]
            f.close()

        #print(int(content[0]))
        channel_f = server.get_channel(str(content[0]))
        send_channel = channel_f
Exemple #15
0
async def pull_authorisation_type2(client, server, channel):

    drop_path = "/Gear_Two/permission_type2.txt"
    file_path = "SETTINGS/" + server.id + "/permission_type2.txt"
    use.drop_down(drop_path, file_path)
    await client.send_message(channel, "Updating permissions type 2")