diff --git a/sukuinote/plugins/pyexec.py b/sukuinote/plugins/pyexec.py
index 9553d16..1a856e0 100644
--- a/sukuinote/plugins/pyexec.py
+++ b/sukuinote/plugins/pyexec.py
@@ -5,7 +5,7 @@ import sys
import html
import inspect
import asyncio
-from io import StringIO
+from io import StringIO, BytesIO
from pyrogram import Client, filters
from .. import config, help_dict, log_errors, slave, apps, session, public_log_errors
@@ -57,15 +57,26 @@ async def pyexec(client, message):
wrapped_stdout.seek(0)
output = ''
wrapped_stderr_text = wrapped_stderr.read().strip()
+ wrapped_stdout_text = wrapped_stdout.read().strip()
if wrapped_stderr_text:
output += f'{html.escape(wrapped_stderr_text)}
\n'
- wrapped_stdout_text = wrapped_stdout.read().strip()
if wrapped_stdout_text:
output += f'{html.escape(wrapped_stdout_text)}
\n'
for i in returned:
output += f'{html.escape(str(i).strip())}
\n'
if not output.strip():
output = 'Executed'
- await reply.edit_text(output)
+
+ # send as a file if it's longer than 4096 bytes
+ if len(output) > 4096:
+ out = wrapped_stderr_text + "\n" + wrapped_stdout_text + "\n"
+ for i in returned:
+ out += str(i).strip() + "\n"
+ f = BytesIO(out.strip().encode('utf-8'))
+ f.name = "output.txt"
+ await reply.delete()
+ await message.reply_document(f)
+ else:
+ await reply.edit_text(output)
help_dict['exec'] = ('Exec', '{prefix}exec <python code> - Executes python code')
diff --git a/sukuinote/plugins/shell.py b/sukuinote/plugins/shell.py
index 333d9e1..de215fb 100644
--- a/sukuinote/plugins/shell.py
+++ b/sukuinote/plugins/shell.py
@@ -1,6 +1,7 @@
import re
import html
import asyncio
+from io import BytesIO
from pyrogram import Client, filters
from .. import config, help_dict, log_errors, public_log_errors
@@ -21,7 +22,16 @@ async def shell(client, message):
text += f'{html.escape(stderr)}
\n'
if stdout:
text += f'{html.escape(stdout)}
'
- await reply.edit_text(text)
+
+ # send as a file if it's longer than 4096 bytes
+ if len(text) > 4096:
+ out = stderr.strip() + "\n" + stdout.strip()
+ f = BytesIO(out.strip().encode('utf-8'))
+ f.name = "output.txt"
+ await reply.delete()
+ await message.reply_document(f)
+ else:
+ await reply.edit_text(text)
help_dict['shell'] = ('Shell',
'''{prefix}sh <command> \\n [stdin] - Executes <command> in shell