Skip to content

Commit

Permalink
fix(piston): avoid MessageTooLong
Browse files Browse the repository at this point in the history
  • Loading branch information
HitaloM committed Sep 13, 2024
1 parent c1a03f5 commit d9c0ac7
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/korone/modules/piston/handlers/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from hairydogm.chat_action import ChatActionSender
from hydrogram import Client
from hydrogram.enums import ChatAction
from hydrogram.errors import MessageTooLong
from hydrogram.types import Message

from korone.decorators import router
Expand Down Expand Up @@ -76,4 +77,12 @@ async def piston_command(client: Client, message: Message) -> None:
output=html.escape(response.compiler_output)
)

await message.reply(text, disable_web_page_preview=True)
try:
await message.reply(text, disable_web_page_preview=True)
except MessageTooLong:
await message.reply(
_(
"The result exceeds the 4096 character limit of Telegram. "
"Please refine your code."
)
)

0 comments on commit d9c0ac7

Please sign in to comment.