cat: Open file in text mode

This commit is contained in:
blank X 2021-09-27 00:12:25 +07:00
parent d44759d871
commit c933266bbe
Signed by: blankie
GPG Key ID: CC15FC822C7F61F5
1 changed files with 2 additions and 2 deletions

View File

@ -26,14 +26,14 @@ async def cat(client, message):
reply = await message.reply_text('Downloading...') reply = await message.reply_text('Downloading...')
await client.download_media(media, file_name=rfile.name, progress=progress_callback, progress_args=(reply, 'Downloading...', False)) await client.download_media(media, file_name=rfile.name, progress=progress_callback, progress_args=(reply, 'Downloading...', False))
media = rfile.name media = rfile.name
with open(media, 'rb') as file: with open(media, 'r') as file:
while True: while True:
chunk = file.read(4096) chunk = file.read(4096)
if not chunk: if not chunk:
break break
if not chunk.strip(): if not chunk.strip():
continue continue
chunk = f'<code>{html.escape(chunk.decode())}</code>' chunk = f'<code>{html.escape(chunk)}</code>'
if done: if done:
await message.reply_text(chunk, quote=False) await message.reply_text(chunk, quote=False)
else: else: