@@ -625,3 +625,117 @@ def last_error_date(self) -> int:
625625 def last_error_message (self ) -> typing .Optional [str ]:
626626 """The last exception message or error response information when trying to reach the bot."""
627627 return self ._raw_data ["last_error_message" ]
628+
629+
630+ @dataclasses .dataclass
631+ class PollDetail :
632+ """Detail about who voted for option."""
633+
634+ def __init__ (self , raw_data : dict ):
635+ self ._raw_data = raw_data
636+
637+ @property
638+ def actor_type (self ) -> str :
639+ """The actor type of the participant that voted: **users**, **groups**, **circles**, **guests**, **emails**."""
640+ return self ._raw_data ["actorType" ]
641+
642+ @property
643+ def actor_id (self ) -> str :
644+ """The actor id of the participant that voted."""
645+ return self ._raw_data ["actorId" ]
646+
647+ @property
648+ def actor_display_name (self ) -> str :
649+ """The display name of the participant that voted."""
650+ return self ._raw_data ["actorDisplayName" ]
651+
652+ @property
653+ def option (self ) -> int :
654+ """The option that was voted for."""
655+ return self ._raw_data ["optionId" ]
656+
657+
658+ @dataclasses .dataclass
659+ class Poll :
660+ """Conversation Poll information."""
661+
662+ def __init__ (self , raw_data : dict , conversation_token : str ):
663+ self ._raw_data = raw_data
664+ self ._conversation_token = conversation_token
665+
666+ @property
667+ def conversation_token (self ) -> str :
668+ """Token identifier of the conversation to which poll belongs."""
669+ return self ._conversation_token
670+
671+ @property
672+ def poll_id (self ) -> int :
673+ """ID of the poll."""
674+ return self ._raw_data ["id" ]
675+
676+ @property
677+ def question (self ) -> str :
678+ """The question of the poll."""
679+ return self ._raw_data ["question" ]
680+
681+ @property
682+ def options (self ) -> list [str ]:
683+ """Options participants can vote for."""
684+ return self ._raw_data ["options" ]
685+
686+ @property
687+ def votes (self ) -> dict [str , int ]:
688+ """Map with 'option-' + optionId => number of votes.
689+
690+ .. note:: Only available for when the actor voted on the public poll or the poll is closed.
691+ """
692+ return self ._raw_data .get ("votes" , {})
693+
694+ @property
695+ def actor_type (self ) -> str :
696+ """Actor type of the poll author: **users**, **groups**, **circles**, **guests**, **emails**."""
697+ return self ._raw_data ["actorType" ]
698+
699+ @property
700+ def actor_id (self ) -> str :
701+ """Actor ID identifying the poll author."""
702+ return self ._raw_data ["actorId" ]
703+
704+ @property
705+ def actor_display_name (self ) -> str :
706+ """The display name of the poll author."""
707+ return self ._raw_data ["actorDisplayName" ]
708+
709+ @property
710+ def closed (self ) -> bool :
711+ """Participants can no longer cast votes and the result is displayed."""
712+ return bool (self ._raw_data ["status" ] == 1 )
713+
714+ @property
715+ def hidden_results (self ) -> bool :
716+ """The results are hidden until the poll is closed."""
717+ return bool (self ._raw_data ["resultMode" ] == 1 )
718+
719+ @property
720+ def max_votes (self ) -> int :
721+ """The maximum amount of options a user can vote for, ``0`` means unlimited."""
722+ return self ._raw_data ["maxVotes" ]
723+
724+ @property
725+ def voted_self (self ) -> list [int ]:
726+ """Array of option ids the participant voted for."""
727+ return self ._raw_data ["votedSelf" ]
728+
729+ @property
730+ def num_voters (self ) -> int :
731+ """The number of unique voters that voted.
732+
733+ .. note:: only available when the actor voted on the public poll or the
734+ poll is closed unless for the creator and moderators.
735+ """
736+ return self ._raw_data .get ("numVoters" , 0 )
737+
738+ @property
739+ def details (self ) -> list [PollDetail ]:
740+ """Detailed list who voted for which option (only available for public closed polls)."""
741+ return [PollDetail (i ) for i in self ._raw_data .get ("details" , [])]
0 commit comments