fix(parser): cast poll question and option texts to string
Convert poll.question and option.text to strings before processing to avoid type errors when they are not already strings.
This commit is contained in:
+3
-3
@@ -188,7 +188,7 @@ class PostParser:
|
||||
if message.media:
|
||||
if message.media == MessageMediaType.POLL:
|
||||
if message.poll is not None and hasattr(message.poll, 'question'):
|
||||
poll_question = message.poll.question.strip()
|
||||
poll_question = str(message.poll.question).strip()
|
||||
if poll_question:
|
||||
return f"📊 Poll: {poll_question}"
|
||||
return "📊 Poll"
|
||||
@@ -898,10 +898,10 @@ class PostParser:
|
||||
|
||||
try:
|
||||
if poll := getattr(message, "poll", None):
|
||||
poll_text = f"📊 Poll: {poll.question}\n"
|
||||
poll_text = f"📊 Poll: {str(poll.question)}\n"
|
||||
if hasattr(poll, "options") and poll.options:
|
||||
for i, option in enumerate(poll.options, 1):
|
||||
poll_text += f"{i}. {getattr(option, 'text', '')}\n"
|
||||
poll_text += f"{i}. {str(getattr(option, 'text', ''))}\n"
|
||||
poll_text += "\n→ Vote in Telegram 🔗\n"
|
||||
return f'<div class="message-poll">{poll_text.replace(chr(10), "<br>")}</div>'
|
||||
return None
|
||||
|
||||
Reference in New Issue
Block a user