mirror of
https://github.com/pyrogram/pyrogram
synced 2025-08-29 05:18:10 +00:00
Update Poll object for Polls 2.0
This commit is contained in:
parent
aa1c0e226e
commit
af2035951a
@ -38,11 +38,20 @@ class Poll(Object, Update):
|
|||||||
options (List of :obj:`PollOption`):
|
options (List of :obj:`PollOption`):
|
||||||
List of poll options.
|
List of poll options.
|
||||||
|
|
||||||
|
total_voter_count (``int``):
|
||||||
|
Total number of users that voted in the poll.
|
||||||
|
|
||||||
is_closed (``bool``):
|
is_closed (``bool``):
|
||||||
True, if the poll is closed.
|
True, if the poll is closed.
|
||||||
|
|
||||||
total_voters (``int``):
|
is_anonymous (``bool``, *optional*):
|
||||||
Total count of voters for this poll.
|
True, if the poll is anonymous
|
||||||
|
|
||||||
|
type (``str``, *optional*):
|
||||||
|
Poll type, currently can be "regular" or "quiz".
|
||||||
|
|
||||||
|
allows_multiple_answers (``bool``, *optional*):
|
||||||
|
True, if the poll allows multiple answers.
|
||||||
|
|
||||||
chosen_option (``int``, *optional*):
|
chosen_option (``int``, *optional*):
|
||||||
Index of your chosen option (0-9), None in case you haven't voted yet.
|
Index of your chosen option (0-9), None in case you haven't voted yet.
|
||||||
@ -55,8 +64,12 @@ class Poll(Object, Update):
|
|||||||
id: str,
|
id: str,
|
||||||
question: str,
|
question: str,
|
||||||
options: List[PollOption],
|
options: List[PollOption],
|
||||||
|
total_voter_count: int,
|
||||||
is_closed: bool,
|
is_closed: bool,
|
||||||
total_voters: int,
|
is_anonymous: bool = None,
|
||||||
|
type: str = None,
|
||||||
|
allows_multiple_answers: bool = None,
|
||||||
|
# correct_option_id: int,
|
||||||
chosen_option: int = None
|
chosen_option: int = None
|
||||||
):
|
):
|
||||||
super().__init__(client)
|
super().__init__(client)
|
||||||
@ -64,15 +77,18 @@ class Poll(Object, Update):
|
|||||||
self.id = id
|
self.id = id
|
||||||
self.question = question
|
self.question = question
|
||||||
self.options = options
|
self.options = options
|
||||||
|
self.total_voter_count = total_voter_count
|
||||||
self.is_closed = is_closed
|
self.is_closed = is_closed
|
||||||
self.total_voters = total_voters
|
self.is_anonymous = is_anonymous
|
||||||
|
self.type = type
|
||||||
|
self.allows_multiple_answers = allows_multiple_answers
|
||||||
|
# self.correct_option_id = correct_option_id
|
||||||
self.chosen_option = chosen_option
|
self.chosen_option = chosen_option
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _parse(client, media_poll: Union[types.MessageMediaPoll, types.UpdateMessagePoll]) -> "Poll":
|
def _parse(client, media_poll: Union[types.MessageMediaPoll, types.UpdateMessagePoll]) -> "Poll":
|
||||||
poll = media_poll.poll
|
poll = media_poll.poll # type: types.Poll
|
||||||
results = media_poll.results.results
|
results = media_poll.results.results # type: types.PollResults
|
||||||
total_voters = media_poll.results.total_voters
|
|
||||||
chosen_option = None
|
chosen_option = None
|
||||||
options = []
|
options = []
|
||||||
|
|
||||||
@ -99,8 +115,11 @@ class Poll(Object, Update):
|
|||||||
id=str(poll.id),
|
id=str(poll.id),
|
||||||
question=poll.question,
|
question=poll.question,
|
||||||
options=options,
|
options=options,
|
||||||
|
total_voter_count=media_poll.results.total_voters,
|
||||||
is_closed=poll.closed,
|
is_closed=poll.closed,
|
||||||
total_voters=total_voters,
|
is_anonymous=not poll.public_voters,
|
||||||
|
type="quiz" if poll.quiz else "regular",
|
||||||
|
allows_multiple_answers=poll.multiple_choice,
|
||||||
chosen_option=chosen_option,
|
chosen_option=chosen_option,
|
||||||
client=client
|
client=client
|
||||||
)
|
)
|
||||||
@ -131,8 +150,8 @@ class Poll(Object, Update):
|
|||||||
id=str(update.poll_id),
|
id=str(update.poll_id),
|
||||||
question="",
|
question="",
|
||||||
options=options,
|
options=options,
|
||||||
|
total_voter_count=update.results.total_voters,
|
||||||
is_closed=False,
|
is_closed=False,
|
||||||
total_voters=update.results.total_voters,
|
|
||||||
chosen_option=chosen_option,
|
chosen_option=chosen_option,
|
||||||
client=client
|
client=client
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user