From bceacb97a0a862fb9a626959a83442c616c0c65f Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Fri, 4 Oct 2024 00:58:15 +0300 Subject: [PATCH] Cut off plaintext body if the event is too long --- maubot/matrix.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/maubot/matrix.py b/maubot/matrix.py index 0f3e36b..87c7b70 100644 --- a/maubot/matrix.py +++ b/maubot/matrix.py @@ -62,7 +62,10 @@ async def parse_formatted( html = message else: return message, escape(message) - return (await MaubotHTMLParser().parse(html)).text, html + text = (await MaubotHTMLParser().parse(html)).text + if len(text) + len(html) > 60000: + text = text[:100] + "[long message cut off]" + return text, html class MaubotMessageEvent(MessageEvent):