From 9f9e952c4e77f7c2cb895253f1a789da6da53721 Mon Sep 17 00:00:00 2001 From: vvzvlad Date: Thu, 16 Apr 2026 02:43:53 +0300 Subject: [PATCH] fix(parser): handle poll question/option objects with .text Update poll handling to extract the `text` attribute from question and option objects when present, falling back to string conversion otherwise. This ensures proper rendering of poll content from Telegram objects that expose a `text` field. --- post_parser.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/post_parser.py b/post_parser.py index d206dfe..171ba8f 100644 --- a/post_parser.py +++ b/post_parser.py @@ -188,7 +188,8 @@ class PostParser: if message.media: if message.media == MessageMediaType.POLL: if message.poll is not None and hasattr(message.poll, 'question'): - poll_question = str(message.poll.question).strip() + q = message.poll.question + poll_question = (q.text if hasattr(q, 'text') else str(q)).strip() if poll_question: return f"šŸ“Š Poll: {poll_question}" return "šŸ“Š Poll" @@ -898,10 +899,14 @@ class PostParser: try: if poll := getattr(message, "poll", None): - poll_text = f"šŸ“Š Poll: {str(poll.question)}\n" + q = poll.question + question_str = q.text if hasattr(q, 'text') else str(q) + poll_text = f"šŸ“Š Poll: {question_str}\n" if hasattr(poll, "options") and poll.options: for i, option in enumerate(poll.options, 1): - poll_text += f"{i}. {str(getattr(option, 'text', ''))}\n" + opt_text = getattr(option, 'text', '') + opt_str = opt_text.text if hasattr(opt_text, 'text') else str(opt_text) + poll_text += f"{i}. {opt_str}\n" poll_text += "\n→ Vote in Telegram šŸ”—\n" return f'
{poll_text.replace(chr(10), "
")}
' return None