cat: Open file in text mode
This commit is contained in:
parent
d44759d871
commit
c933266bbe
|
@ -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:
|
||||||
|
|
Loading…
Reference in New Issue