From f11aa9a33e2b8599ea27d1409447a67e9fec6c11 Mon Sep 17 00:00:00 2001 From: Ivan Filipenkov Date: Thu, 26 Sep 2024 17:55:55 +0200 Subject: [PATCH] fix: parse_tgpy_message no longer returns positive result for `TGPy error>` messages --- tgpy/api/parse_tgpy_message.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tgpy/api/parse_tgpy_message.py b/tgpy/api/parse_tgpy_message.py index a509591..f0abd22 100644 --- a/tgpy/api/parse_tgpy_message.py +++ b/tgpy/api/parse_tgpy_message.py @@ -14,7 +14,11 @@ class MessageParseResult: def parse_tgpy_message(message: Message) -> MessageParseResult: e = get_title_entity(message) - if not e: + if ( + not e + # Likely a `TGPy error>` message + or e.offset == 0 + ): return MessageParseResult(False, None, None) msg_text = Utf16CodepointsWrapper(message.raw_text) code = msg_text[: e.offset].strip()