Skip to content

Commit

Permalink
pyrofork: Add recent_voters field to Poll
Browse files Browse the repository at this point in the history
Signed-off-by: wulan17 <wulan17@nusantararom.org>
  • Loading branch information
wulan17 committed Jul 23, 2024
1 parent 08442de commit ebd13d3
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion pyrogram/types/messages_and_media/poll.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ class Poll(Object, Update):
close_date (:py:obj:`~datetime.datetime`, *optional*):
Point in time when the poll will be automatically closed.
recent_voters (List of :obj:`~pyrogram.types.User`, *optional*):
List of user whos recently vote.
"""

def __init__(
Expand All @@ -98,7 +101,8 @@ def __init__(
explanation: Optional[str] = None,
explanation_entities: Optional[List["types.MessageEntity"]] = None,
open_period: Optional[int] = None,
close_date: Optional[datetime] = None
close_date: Optional[datetime] = None,
recent_voters: List["types.User"] = None
):
super().__init__(client)

Expand All @@ -117,6 +121,7 @@ def __init__(
self.explanation_entities = explanation_entities
self.open_period = open_period
self.close_date = close_date
self.recent_voters = recent_voters

@staticmethod
def _parse(client, media_poll: Union["raw.types.MessageMediaPoll", "raw.types.UpdateMessagePoll"]) -> "Poll":
Expand Down Expand Up @@ -176,6 +181,10 @@ def _parse(client, media_poll: Union["raw.types.MessageMediaPoll", "raw.types.Up
] if poll_results.solution_entities else None,
open_period=poll.close_period,
close_date=utils.timestamp_to_datetime(poll.close_date),
recent_voters=[
await client.get_users(user_id=user.user_id)
for user in poll_results.recent_voters
] if poll_results.recent_voters else None,
client=client
)

Expand Down Expand Up @@ -213,6 +222,10 @@ def _parse_update(client, update: "raw.types.UpdateMessagePoll"):
is_closed=False,
chosen_option_id=chosen_option_id,
correct_option_id=correct_option_id,
recent_voters=[
await client.get_users(user_id=user.user_id)
for user in update.results.recent_voters
] if update.results.recent_voters else None,
client=client
)

Expand Down

0 comments on commit ebd13d3

Please sign in to comment.