Код: Выделить всё
from typing import Optional
from telethon.sync import TelegramClient
from telethon.tl.types import *
from telethon.tl.functions.messages import *
def _build_poll(question: str, *answers: str, closed: Optional[bool] = None,
id: int = 0) -> InputMediaPoll:
"""Build a poll object."""
return InputMediaPoll(Poll(
id=id, question=question, answers=[
PollAnswer(text=i, option=bytes([idx]))
for idx, i in enumerate(answers)
],
closed=closed
))
poll = _build_poll(f"Question", "Answer 1", "Answer 2", "Answer 3")
message = client.send_message(-325188743, file=poll)
Подробнее здесь: https://stackoverflow.com/questions/594 ... legram-bot