コード例 #1
0
async def create_archive(input_directory):
    return_name = None
    if os.path.exists(input_directory):
        base_dir_name = os.path.basename(input_directory)
        compressed_file_name = f"{base_dir_name}.tar.gz"
        # #BlameTelegram
        suffix_extention_length = 1 + 3 + 1 + 2
        if len(base_dir_name) > (64 - suffix_extention_length):
            compressed_file_name = base_dir_name[0 : (64 - suffix_extention_length)]
            compressed_file_name += ".tar.gz"
        # fix for https://t.me/c/1434259219/13344
        file_genertor_command = [
            "tar",
            "-cvf",
            compressed_file_name,
            f"{input_directory}",
        ]
        process = await asyncio.create_subprocess_exec(
            *file_genertor_command,
            # stdout must a pipe to be accessible as process.stdout
            stdout=asyncio.subprocess.PIPE,
            stderr=asyncio.subprocess.PIPE,
        )
        # Wait for the subprocess to finish
        stdout, stderr = await process.communicate()
        LOGGER.error(stderr.decode().strip())
        if os.path.exists(compressed_file_name):
            try:
                shutil.rmtree(input_directory)
            except:
                pass
            return_name = compressed_file_name
    return return_name
コード例 #2
0
async def download_tg(client, message):
    user_id = message.from_user.id
    LOGGER.info(user_id)
    mess_age = await message.reply_text("...", quote=True)
    if not os.path.isdir(DOWNLOAD_LOCATION):
        os.makedirs(DOWNLOAD_LOCATION)
    if message.reply_to_message is not None:
        start_t = datetime.now()
        download_location = str(Path("./").resolve()) + "/"
        c_time = time.time()
        prog = Progress(user_id, client, mess_age)
        try:
            the_real_download_location = await client.download_media(
                message=message.reply_to_message,
                file_name=download_location,
                progress=prog.progress_for_pyrogram,
                progress_args=("trying to download", c_time),
            )
        except Exception as g_e:
            await mess_age.edit(str(g_e))
            LOGGER.error(g_e)
            return
        end_t = datetime.now()
        ms = (end_t - start_t).seconds
        LOGGER.info(the_real_download_location)
        await asyncio.sleep(5)
        if the_real_download_location:
            await mess_age.edit_text(
                f"Downloaded to <code>{the_real_download_location}</code> in <u>{ms}</u> seconds"
            )
        else:
            await mess_age.edit_text(
                "😔 Download Cancelled or some error happened")
            return
    return the_real_download_location, mess_age
コード例 #3
0
async def down_load_media_f(client, message):
    user_id = message.from_user.id
    LOGGER.info(user_id)
    mess_age = await message.reply_text("...", quote=True)
    if not os.path.isdir(DOWNLOAD_LOCATION):
        os.makedirs(DOWNLOAD_LOCATION)
    if message.reply_to_message is not None:
        start_t = datetime.now()
        download_location = "/app/"
        c_time = time.time()
        try:
            the_real_download_location = await client.download_media(
                message=message.reply_to_message,
                file_name=download_location,
                progress=progress_for_pyrogram,
                progress_args=("trying to download", mess_age, c_time),
            )
        except Exception as g_e:
            await mess_age.edit(str(g_e))
            LOGGER.error(g_e)
            return
        end_t = datetime.now()
        ms = (end_t - start_t).seconds
        LOGGER.info(the_real_download_location)
        await asyncio.sleep(10)
        await mess_age.edit_text(
            f"Downloaded to <code>{the_real_download_location}</code> in <u>{ms}</u> seconds"
        )
        the_real_download_location_g = os.path.basename(
            the_real_download_location)
        LOGGER.info(the_real_download_location_g)
        if len(message.command) > 1:
            if message.command[1].lower() == "unzip":
                file_upload = await unzip_me(the_real_download_location_g)
                if file_upload is not None:
                    g_response = await upload_to_gdrive(
                        file_upload, mess_age, message, user_id)
                    LOGGER.info(g_response)

            elif message.command[1].lower() == "unrar":
                file_uploade = await unrar_me(the_real_download_location_g)
                if file_uploade is not None:
                    gk_response = await upload_to_gdrive(
                        file_uploade, mess_age, message, user_id)
                    LOGGER.info(gk_response)

            elif message.command[1].lower() == "untar":
                file_uploadg = await untar_me(the_real_download_location_g)
                if file_uploadg is not None:
                    gau_response = await upload_to_gdrive(
                        file_uploadg, mess_age, message, user_id)
                    LOGGER.info(gau_response)
        else:
            gaut_response = await upload_to_gdrive(
                the_real_download_location_g, mess_age, message, user_id)
            LOGGER.info(gaut_response)
    else:
        await mess_age.edit_text(
            "Reply to a Telegram Media, to upload to the Cloud Drive.")
コード例 #4
0
async def rename_tg_file(client, message):
    usr_id = message.from_user.id
    if not message.reply_to_message:
        await message.reply("<b>Reply with Telegram Media</b> None", quote=True)
        return
    if len(message.command) > 1:
        new_name = (
            str(Path().resolve()) + "/" +
            message.text.split(" ", maxsplit=1)[1].strip()
        )
        file, mess_age = await download_tg(client, message)
        try:
            if file:
                os.rename(file, new_name)
            else:
                return
        except Exception as g_g:
            LOGGER.error(g_g)
            await message.reply_text("g_g")
        response = {}
        final_response = await upload_to_tg(
            mess_age, new_name, usr_id, response, client
        )
        LOGGER.info(final_response)
        if not final_response:
            return
        try:
            message_to_send = ""
            for key_f_res_se in final_response:
                local_file_name = key_f_res_se
                message_id = final_response[key_f_res_se]
                channel_id = str(message.chat.id)[4:]
                private_link = f"https://t.me/c/{channel_id}/{message_id}"
                message_to_send += "➪ <a href='"
                message_to_send += private_link
                message_to_send += "'>"
                message_to_send += local_file_name
                message_to_send += "</a>"
                message_to_send += "\n"
            if message_to_send != "":
                mention_req_user = (
                    f"<a href='tg://user?id={usr_id}'>🐈 Hey Bru!! Your Requested Files 👇</a>\n\n"
                )
                message_to_send = mention_req_user + message_to_send
                message_to_send = message_to_send + "\n\n" + "<b> #UPLOADS\n\n💫 Powered By : @TGFilmZone</b>"
            else:
                message_to_send = "<i>FAILED</i> to upload files. 😞😞"
            await message.reply_text(
                text=message_to_send, quote=True, disable_web_page_preview=True
            )
        except Exception as pe:
            LOGGER.info(pe)

    else:
        await message.reply_text(
            "<b> Oops 😬</b>\n\nProvide Name with extension\n\n➩<b>Example</b>: <code> /rename Avengers Endgame.mkv</code>", quote=True
        )
コード例 #5
0
async def rename_tg_file(client, message):
    usr_id = message.from_user.id
    if not message.reply_to_message:
        await message.reply("😔 No downloading source provided 🙄", quote=True)
        return
    if len(message.command) > 1:
        new_name = (
            str(Path().resolve()) + "/" +
            message.text.split(" ", maxsplit=1)[1].strip()
        )
        file, mess_age = await download_tg(client, message)
        try:
            if file:
                os.rename(file, new_name)
            else:
                return
        except Exception as g_g:
            LOGGER.error(g_g)
            await message.reply_text("g_g")
        response = {}
        final_response = await upload_to_tg(
            mess_age, new_name, usr_id, response, client
        )
        LOGGER.info(final_response)
        if not final_response:
            return
        try:
            message_to_send = ""
            for key_f_res_se in final_response:
                local_file_name = key_f_res_se
                message_id = final_response[key_f_res_se]
                channel_id = str(message.chat.id)[4:]
                private_link = f"https://t.me/c/{channel_id}/{message_id}"
                message_to_send += "👉 <a href='"
                message_to_send += private_link
                message_to_send += "'>"
                message_to_send += local_file_name
                message_to_send += "</a>"
                message_to_send += "\n"
            if message_to_send != "":
                mention_req_user = (
                    f"<a href='tg://user?id={usr_id}'>Your Requested Files</a>\n\n"
                )
                message_to_send = mention_req_user + message_to_send
                message_to_send = message_to_send + "\n\n" + "#uploads"
            else:
                message_to_send = "<i>FAILED</i> to upload files. 😞😞"
            await message.reply_text(
                text=message_to_send, quote=True, disable_web_page_preview=True
            )
        except Exception as pe:
            LOGGER.info(pe)

    else:
        await message.reply_text(
            "😔 Provide new name of the file with extension 😐", quote=True
        )
コード例 #6
0
async def rename_tg_file(client, message):
    usr_id = message.from_user.id
    if not message.reply_to_message:
        await message.reply("😔 Tidak ada sumber download yang diberikan 🙄",
                            quote=True)
        return
    if len(message.command) > 1:
        new_name = (str(Path().resolve()) + "/" +
                    message.text.split(" ", maxsplit=1)[1].strip())
        file, mess_age = await download_tg(client, message)
        try:
            if file:
                os.rename(file, new_name)
            else:
                return
        except Exception as g_g:
            LOGGER.error(g_g)
            await message.reply_text("g_g")
        response = {}
        final_response = await upload_to_tg(mess_age, new_name, usr_id,
                                            response, client)
        LOGGER.info(final_response)
        if not final_response:
            return
        try:
            message_to_send = ""
            for key_f_res_se in final_response:
                local_file_name = key_f_res_se
                message_id = final_response[key_f_res_se]
                channel_id = str(message.chat.id)[4:]
                private_link = f"https://t.me/c/{channel_id}/{message_id}"
                message_to_send += "👉 <a href='"
                message_to_send += private_link
                message_to_send += "'>"
                message_to_send += local_file_name
                message_to_send += "</a>"
                message_to_send += "\n"
            if message_to_send != "":
                mention_req_user = (
                    f"<a href='tg://user?id={usr_id}'>Permintaan File Kamu</a>\n\n"
                )
                message_to_send = mention_req_user + message_to_send
                message_to_send = message_to_send + "\n\n" + "#uploads"
            else:
                message_to_send = "<i>Gagal</i> mengupload files. 😞😞"
            await message.reply_text(text=message_to_send,
                                     quote=True,
                                     disable_web_page_preview=True)
        except Exception as pe:
            LOGGER.info(pe)

    else:
        await message.reply_text(
            "😔 Berikan nama file baru beserta extensinya 😐", quote=True)
コード例 #7
0
async def down_load_media_f(client, message):
    user_command = message.command[0]
    user_id = message.from_user.id
    LOGGER.info(user_id)
    mess_age = await message.reply_text(
        "Is it really a Telegram Media 🤔!\nJust to make sure 🤷‍♂️ \nIf yes, then wait a few minutes",
        quote=True)
    if not os.path.isdir(DOWNLOAD_LOCATION):
        os.makedirs(DOWNLOAD_LOCATION)
    if message.reply_to_message is not None:
        start_t = datetime.now()
        download_location = str(Path().resolve()) + "/"
        c_time = time.time()
        prog = Progress(user_id, client, mess_age)
        try:
            the_real_download_location = await client.download_media(
                message=message.reply_to_message,
                file_name=download_location,
                progress=prog.progress_for_pyrogram,
                progress_args=("trying to download", c_time),
            )
        except Exception as g_e:
            await mess_age.edit(str(g_e))
            LOGGER.error(g_e)
            return
        end_t = datetime.now()
        ms = (end_t - start_t).seconds
        LOGGER.info(the_real_download_location)
        await asyncio.sleep(10)
        if the_real_download_location:
            await mess_age.edit_text(
                f"Downloaded to <code>{the_real_download_location}</code> in <u>{ms}</u> seconds"
            )
        else:
            await mess_age.edit_text(
                "😔 Download Cancelled or some error happened")
            return
        the_real_download_location_g = the_real_download_location
        if user_command == TELEGRAM_LEECH_UNZIP_COMMAND.lower():
            try:
                check_ifi_file = get_base_name(the_real_download_location)
                file_up = await unzip_me(the_real_download_location)
                if os.path.exists(check_ifi_file):
                    the_real_download_location_g = file_up
            except Exception as ge:
                LOGGER.info(ge)
                LOGGER.info(
                    f"Unable to extract {os.path.basename(the_real_download_location)}, Uploading the same file"
                )
        await upload_to_gdrive(the_real_download_location_g, mess_age, message,
                               user_id)
    else:
        await mess_age.edit_text(
            "Reply to a Telegram Media, to upload to the Cloud Drive.")
コード例 #8
0
async def rename_tg_file(client, message):
    usr_id = message.from_user.id
    if not message.reply_to_message:
        await message.reply("𝐆𝐢𝐛, 𝐚 𝐯𝐚𝐥𝐢𝐝 𝐥𝐢𝐧𝐤 𝐯𝐞𝐫𝐨 (◔‿◔)", quote=True)
        return
    if len(message.command) > 1:
        new_name = (str(Path().resolve()) + "/" +
                    message.text.split(" ", maxsplit=1)[1].strip())
        file, mess_age = await download_tg(client, message)
        try:
            if file:
                os.rename(file, new_name)
            else:
                return
        except Exception as g_g:
            LOGGER.error(g_g)
            await message.reply_text("g_g")
        response = {}
        final_response = await upload_to_tg(mess_age, new_name, usr_id,
                                            response, client)
        LOGGER.info(final_response)
        if not final_response:
            return
        try:
            message_to_send = ""
            for key_f_res_se in final_response:
                local_file_name = key_f_res_se
                message_id = final_response[key_f_res_se]
                channel_id = str(message.chat.id)[4:]
                private_link = f"https://t.me/c/{channel_id}/{message_id}"
                message_to_send += "🥏 <a href='"
                message_to_send += private_link
                message_to_send += "'>"
                message_to_send += local_file_name
                message_to_send += "</a>"
                message_to_send += "\n"
            if message_to_send != "":
                mention_req_user = (
                    f"<a href='tg://user?id={usr_id}'>𝐒𝐨𝐮𝐫𝐜𝐞 𝐂𝐨𝐝𝐞 😑</a>\n\n")
                message_to_send = mention_req_user + message_to_send
                message_to_send = message_to_send + "\n\n" + "#BOT1uploads"
            else:
                message_to_send = "<i>FAILED</i> to upload files. 😞😞"
            await message.reply_text(text=message_to_send,
                                     quote=True,
                                     disable_web_page_preview=True)
        except Exception as pe:
            LOGGER.info(pe)

    else:
        await message.reply_text(
            "𝐏𝐫𝐨𝐯𝐢𝐝𝐞 𝐧𝐞𝐰 𝐧𝐚𝐦𝐞 𝐨𝐟 𝐭𝐡𝐞 𝐟𝐢𝐥𝐞 𝐰𝐢𝐭𝐡 𝐞𝐱𝐭𝐞𝐧𝐬𝐢𝐨𝐧 👨‍🔧", quote=True)
コード例 #9
0
async def down_load_media_f(client, message):
    user_command = message.command[0]
    user_id = message.from_user.id
    LOGGER.info(user_id)
    mess_age = await message.reply_text("...", quote=True)
    if not os.path.isdir(DOWNLOAD_LOCATION):
        os.makedirs(DOWNLOAD_LOCATION)
    if message.reply_to_message is not None:
        start_t = datetime.now()
        download_location = str(Path().resolve()) + "/"
        c_time = time.time()
        try:
            the_real_download_location = await client.download_media(
                message=message.reply_to_message,
                file_name=download_location,
                progress=progress_for_pyrogram,
                progress_args=("trying to download", mess_age, c_time),
            )
        except Exception as g_e:
            await mess_age.edit(str(g_e))
            LOGGER.error(g_e)
            return
        end_t = datetime.now()
        ms = (end_t - start_t).seconds
        LOGGER.info(the_real_download_location)
        await asyncio.sleep(10)
        await mess_age.edit_text(
            f"Downloaded to <code>{the_real_download_location}</code> in <u>{ms}</u> seconds"
        )
        the_real_download_location_g = the_real_download_location
        if user_command == TELEGRAM_LEECH_UNZIP_COMMAND:
            file_up = await unzip_me(the_real_download_location)
            the_real_download_location_g = file_up
        gaut_response = await upload_to_gdrive(
            the_real_download_location_g, mess_age, message, user_id
        )
        LOGGER.info(gaut_response)
    else:
        await mess_age.edit_text(
            "Reply to a Telegram Media, to upload to the Cloud Drive."
        )
コード例 #10
0
ファイル: download.py プロジェクト: cihanvol/Leech-Pro
async def download_tg(client, message):
    user_id = message.from_user.id
    LOGGER.info(user_id)
    mess_age = await message.reply_text("**DownloadinG...**", quote=True)
    if not os.path.isdir(DOWNLOAD_LOCATION):
        os.makedirs(DOWNLOAD_LOCATION)
    rep_mess = message.reply_to_message
    if rep_mess is not None:
        file = [rep_mess.document, rep_mess.video, rep_mess.audio]
        file_name = [fi for fi in file if fi is not None][0].file_name
        start_t = datetime.now()
        download_location = str(Path("./").resolve()) + "/"
        c_time = time.time()
        prog = Progress(user_id, client, mess_age)
        try:
            the_real_download_location = await client.download_media(
                message=message.reply_to_message,
                file_name=download_location,
                progress=prog.progress_for_pyrogram,
                progress_args=(f"**• Downloading :** `{file_name}`", c_time)
            )
        except Exception as g_e:
            await mess_age.edit(str(g_e))
            LOGGER.error(g_e)
            return
        end_t = datetime.now()
        ms = (end_t - start_t).seconds
        LOGGER.info(the_real_download_location)
        await asyncio.sleep(2)
        if the_real_download_location:
            await mess_age.edit_text(
                f"Downloaded to <code>{the_real_download_location}</code> in <u>{ms}</u> seconds"
            )
        else:
            await mess_age.edit_text("😔 Download Cancelled or some error happened")
            return None, mess_age
    return the_real_download_location, mess_age
コード例 #11
0
async def split_large_files(input_file):
    working_directory = os.path.dirname(os.path.abspath(input_file))
    new_working_directory = os.path.join(working_directory, str(time.time()))
    # create download directory, if not exist
    if not os.path.isdir(new_working_directory):
        os.makedirs(new_working_directory)
    # if input_file.upper().endswith(("MKV", "MP4", "WEBM", "MP3", "M4A", "FLAC", "WAV")):
    """The below logic is DERPed, so removing temporarily
    """
    if input_file.upper().endswith(
        ("MKV", "MP4", "WEBM", "AVI", "MOV", "MPEG", "WMV", "M4V", "3GP")):
        # handle video / audio files here
        metadata = extractMetadata(createParser(input_file))
        total_duration = 0
        if metadata.has("duration"):
            total_duration = metadata.get("duration").seconds
        # proprietary logic to get the seconds to trim (at)
        LOGGER.info(total_duration)
        total_file_size = os.path.getsize(input_file)
        LOGGER.info(total_file_size)
        minimum_duration = (total_duration /
                            total_file_size) * (MAX_TG_SPLIT_FILE_SIZE)
        # casting to int cuz float Time Stamp can cause errors
        minimum_duration = int(minimum_duration)

        LOGGER.info(minimum_duration)
        # END: proprietary
        start_time = 0
        end_time = minimum_duration
        base_name = os.path.basename(input_file)
        input_extension = base_name.split(".")[-1]
        LOGGER.info(input_extension)

        i = 0
        flag = False

        while end_time <= total_duration:
            LOGGER.info(i)
            # file name generate
            parted_file_name = "{}_PART_{}.{}".format(str(base_name),
                                                      str(i).zfill(5),
                                                      str(input_extension))

            output_file = os.path.join(new_working_directory, parted_file_name)
            LOGGER.info(output_file)
            LOGGER.info(await cult_small_video(input_file, output_file,
                                               str(start_time), str(end_time)))
            LOGGER.info(
                f"Start time {start_time}, End time {end_time}, Itr {i}")

            # adding offset of 3 seconds to ensure smooth playback
            start_time = end_time - 3
            end_time = end_time + minimum_duration
            i = i + 1

            if (end_time > total_duration) and not flag:
                end_time = total_duration
                flag = True
            elif flag:
                break

    elif SP_LIT_ALGO_RITH_M.lower() == "hjs":
        # handle normal files here
        o_d_t = os.path.join(new_working_directory,
                             os.path.basename(input_file))
        o_d_t = o_d_t + "."
        file_genertor_command = [
            "split",
            "--numeric-suffixes=1",
            "--suffix-length=5",
            f"--bytes={MAX_TG_SPLIT_FILE_SIZE}",
            input_file,
            o_d_t,
        ]
        await run_comman_d(file_genertor_command)

    elif SP_LIT_ALGO_RITH_M.lower() == "rar":
        o_d_t = os.path.join(
            new_working_directory,
            os.path.basename(input_file),
        )
        LOGGER.info(o_d_t)
        file_genertor_command = [
            "rar",
            "a",
            f"-v{MAX_TG_SPLIT_FILE_SIZE}b",
            "-m0",
            o_d_t,
            input_file,
        ]
        await run_comman_d(file_genertor_command)
    try:
        os.remove(input_file)
    except Exception as r:
        LOGGER.error(r)
    return new_working_directory
コード例 #12
0
async def call_apropriate_function(
    aria_instance,
    incoming_link,
    c_file_name,
    sent_message_to_update_tg_p,
    is_zip,
    cstom_file_name,
    is_cloud,
    is_unzip,
    user_message,
    client,
):
    if incoming_link.lower().startswith("magnet:"):
        sagtus, err_message = add_magnet(aria_instance, incoming_link,
                                         c_file_name)
    elif incoming_link.lower().endswith(".torrent"):
        sagtus, err_message = add_torrent(aria_instance, incoming_link)
    else:
        sagtus, err_message = add_url(aria_instance, incoming_link,
                                      c_file_name)
    if not sagtus:
        return sagtus, err_message
    LOGGER.info(err_message)
    # https://stackoverflow.com/a/58213653/4723940
    await check_progress_for_dl(aria_instance, err_message,
                                sent_message_to_update_tg_p, None)
    if incoming_link.startswith("magnet:"):
        #
        err_message = await check_metadata(aria_instance, err_message)
        #
        await asyncio.sleep(1)
        if err_message is not None:
            await check_progress_for_dl(aria_instance, err_message,
                                        sent_message_to_update_tg_p, None)
        else:
            return False, "can't get metadata \n\n#MetaDataError"
    await asyncio.sleep(1)
    file = aria_instance.get_download(err_message)
    to_upload_file = file.name
    com_g = file.is_complete
    #
    if is_zip:
        check_if_file = await create_archive(to_upload_file)
        if check_if_file is not None:
            to_upload_file = check_if_file
    #
    if is_unzip:
        try:
            check_ifi_file = get_base_name(to_upload_file)
            await unzip_me(to_upload_file)
            if os.path.exists(check_ifi_file):
                to_upload_file = check_ifi_file
        except Exception as ge:
            LOGGER.info(ge)
            LOGGER.info(
                f"Can't extract {os.path.basename(to_upload_file)}, Uploading the same file"
            )

    if to_upload_file:
        if CUSTOM_FILE_NAME:
            if os.path.isfile(to_upload_file):
                os.rename(to_upload_file,
                          f"{CUSTOM_FILE_NAME}{to_upload_file}")
                to_upload_file = f"{CUSTOM_FILE_NAME}{to_upload_file}"
            else:
                for root, _, files in os.walk(to_upload_file):
                    LOGGER.info(files)
                    for org in files:
                        p_name = f"{root}/{org}"
                        n_name = f"{root}/{CUSTOM_FILE_NAME}{org}"
                        os.rename(p_name, n_name)
                to_upload_file = to_upload_file

    if cstom_file_name:
        os.rename(to_upload_file, cstom_file_name)
        to_upload_file = cstom_file_name
    #
    response = {}
    LOGGER.info(response)
    user_id = user_message.from_user.id
    if com_g:
        if is_cloud:
            await upload_to_gdrive(to_upload_file, sent_message_to_update_tg_p,
                                   user_message, user_id)
        else:
            final_response = await upload_to_tg(sent_message_to_update_tg_p,
                                                to_upload_file, user_id,
                                                response, client)
            if not final_response:
                return True, None
            try:
                message_to_send = ""
                for key_f_res_se in final_response:
                    local_file_name = key_f_res_se
                    message_id = final_response[key_f_res_se]
                    channel_id = str(sent_message_to_update_tg_p.chat.id)[4:]
                    private_link = f"https://t.me/c/{channel_id}/{message_id}"
                    message_to_send += "👉 <a href='"
                    message_to_send += private_link
                    message_to_send += "'>"
                    message_to_send += local_file_name
                    message_to_send += "</a>"
                    message_to_send += "\n"
                if message_to_send != "":
                    mention_req_user = (
                        f"<a href='tg://user?id={user_id}'>Your Requested Files</a>\n\n"
                    )
                    message_to_send = mention_req_user + message_to_send
                    message_to_send = message_to_send + "\n\n" + "#uploads"
                else:
                    message_to_send = "<i>FAILED</i> to upload files. 😞😞"
                await user_message.reply_text(text=message_to_send,
                                              quote=True,
                                              disable_web_page_preview=True)
            except Exception as go:
                LOGGER.error(go)
    return True, None
コード例 #13
0
 usr_id = message.from_user.id
 if not message.reply_to_message:
     await message.reply("😔 No downloading source provided 🙄", quote=True)
     return
 if len(message.command) > 1:
     new_name = (
         str(Path().resolve()) + "/" + message.text.split(" ", maxsplit=1)[1].strip()
     )
     file, mess_age = await download_tg(client, message)
     try:
         if file:
             os.rename(file, new_name)
         else:
             return
     except Exception as g_g:
         LOGGER.error(g_g)
         await message.reply_text("g_g")
     response = {}
     final_response = await upload_to_tg(
         mess_age, new_name, usr_id, response, client
     )
     LOGGER.info(final_response)
     if not final_response:
         return
     try:
         message_to_send = ""
         for key_f_res_se in final_response:
             local_file_name = key_f_res_se
             message_id = final_response[key_f_res_se]
             channel_id = str(message.chat.id)[4:]
             private_link = f"https://t.me/c/{channel_id}/{message_id}"