This commit is contained in:
blank X 2021-04-09 10:45:14 +07:00
parent 4f5920866a
commit cf83bbab73
Signed by: blankie
GPG Key ID: CC15FC822C7F61F5
1 changed files with 6 additions and 2 deletions

View File

@ -228,18 +228,22 @@ async def _upload_worker():
is_big = total_size > size_limit
files_sent = size_sent = 0
messages = []
file = bopen(video_filename, size_limit)
file = bopen(video_filename, None)
while total_size > 0:
file.capped_size = None
file.seek(size_sent)
file.capped_size = size_limit
if is_big:
file.name = f'{base_filename}.part{str(files_sent).rjust(2, "0")}'
else:
file.name = base_filename
messages.append((await client.send_message(config['config']['storage_chat_id'], f'Uploading {file.name}...', parse_mode=None)).id)
message = await client.send_file(config['config']['storage_chat_id'], file, caption=file.name, parse_mode=None)
total_size -= message.document.size
if total_size > 0:
size_sent += message.document.size
files_sent += 1
file = bopen(video_filename, size_limit)
file = bopen(video_filename, None)
if messages:
await client.delete_messages(config['config']['storage_chat_id'], messages)
finally: