user14023488
user14023488

Reputation:

How can I send multiple answer poll using Telethon (user can select more then one options)

I did my best but I'm unable to find a resource and my current code sends an anonymous poll but I want to send 'Multiple Answer poll' so one user can choose more than one option.

also, how do the bot will know which option is pressed?

await bot.send_message(event.chat.id, file=InputMediaPoll(
                poll=Poll(id=event.chat.id, question="This is a test poll",answers=[PollAnswer('Option 1', b'1'), PollAnswer('Option 2', b'2')])))

Upvotes: 1

Views: 526

Answers (1)

Benkendorf
Benkendorf

Reputation: 146

According to documentation you should use poll constructor with multiple_choice set to True:

from telethon import types


await bot.send_message(
    event.chat_id,
    file=types.InputMediaPoll(
        poll=types.Poll(
            id=1,
            question="This is a test poll",
            answers=[types.PollAnswer('Option 1', b'1'), types.PollAnswer('Option 2', b'2')],
            multiple_choice=True
        ),
    )
)

To know your voters just get this poll message in any way and check the results.

Upvotes: 3

Related Questions