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