Search code examples
telethon

How send answer in group poll?


How can I vote poll in a group? I need to select 1 of the options, but I have not found a function that is responsible for this

I can create poll, but not vote as client like Lonami show in another question

await client.send_message('@username',file=types.InputMediaPoll(
    poll=types.Poll(
        id=..., # type: long (random id)
        question=..., # type: string (the question)
        answers=... # type: list of PollAnswer (up to 10 answers)
    )
))

Solution

  • Use message.click(index) as stated in the docs.

    message = await client.get_messages(chat, ids=xx) 
    # ^ get the message containing poll or from events
    await message.click(0)  # index starts from 0 == first
    

    For multiple choice polls, pass a list of indexes.