MCPcopy Index your code
hub / github.com/python-telegram-bot/python-telegram-bot / __init__

Method __init__

src/telegram/_poll.py:982–1064  ·  view source on GitHub ↗
(
        self,
        id: str,  # pylint: disable=redefined-builtin
        question: str,
        options: Sequence[PollOption],
        total_voter_count: int,
        is_closed: bool,
        is_anonymous: bool,
        type: str,  # pylint: disable=redefined-builtin
        allows_multiple_answers: bool,
        # tags: deprecated 22.8
        # Removed in bot api 9.6:
        correct_option_id: int | None = None,
        # ---
        explanation: str | None = None,
        explanation_entities: Sequence[MessageEntity] | None = None,
        open_period: TimePeriod | None = None,
        close_date: dtm.datetime | None = None,
        question_entities: Sequence[MessageEntity] | None = None,
        # tags: required in 22.8
        # temporarily optional to avoid breaking changes
        allows_revoting: bool | None = None,
        members_only: bool | None = None,
        # ---
        correct_option_ids: Sequence[int] | None = None,
        description: str | None = None,
        description_entities: Sequence[MessageEntity] | None = None,
        country_codes: Sequence[str] | None = None,
        media: PollMedia | None = None,
        explanation_media: PollMedia | None = None,
        *,
        api_kwargs: JSONDict | None = None,
    )

Source from the content-addressed store, hash-verified

980 )
981
982 def __init__(
983 self,
984 id: str, # pylint: disable=redefined-builtin
985 question: str,
986 options: Sequence[PollOption],
987 total_voter_count: int,
988 is_closed: bool,
989 is_anonymous: bool,
990 type: str, # pylint: disable=redefined-builtin
991 allows_multiple_answers: bool,
992 # tags: deprecated 22.8
993 # Removed in bot api 9.6:
994 correct_option_id: int | None = None,
995 # ---
996 explanation: str | None = None,
997 explanation_entities: Sequence[MessageEntity] | None = None,
998 open_period: TimePeriod | None = None,
999 close_date: dtm.datetime | None = None,
1000 question_entities: Sequence[MessageEntity] | None = None,
1001 # tags: required in 22.8
1002 # temporarily optional to avoid breaking changes
1003 allows_revoting: bool | None = None,
1004 members_only: bool | None = None,
1005 # ---
1006 correct_option_ids: Sequence[int] | None = None,
1007 description: str | None = None,
1008 description_entities: Sequence[MessageEntity] | None = None,
1009 country_codes: Sequence[str] | None = None,
1010 media: PollMedia | None = None,
1011 explanation_media: PollMedia | None = None,
1012 *,
1013 api_kwargs: JSONDict | None = None,
1014 ):
1015 if allows_revoting is None:
1016 raise TypeError("`allows_revoting` is a required argument since Bot API 9.6")
1017
1018 if members_only is None:
1019 raise TypeError("`members_only` is a required argument since Bot API 10.0")
1020
1021 super().__init__(api_kwargs=api_kwargs)
1022 self.id: str = id
1023 self.question: str = question
1024 self.options: tuple[PollOption, ...] = parse_sequence_arg(options)
1025 self.total_voter_count: int = total_voter_count
1026 self.is_closed: bool = is_closed
1027 self.is_anonymous: bool = is_anonymous
1028 self.type: str = enum.get_member(constants.PollType, type, type)
1029 self.allows_multiple_answers: bool = allows_multiple_answers
1030 self.allows_revoting: bool = allows_revoting
1031 self.members_only: bool = members_only
1032
1033 # tag: deprecated 22.8
1034 if correct_option_id is not None:
1035 warn(
1036 PTBDeprecationWarning(
1037 "22.8",
1038 "The parameter `correct_option_id` is deprecated. "
1039 "Use `correct_option_ids` instead.",

Callers 6

__init__Method · 0.45
__init__Method · 0.45
__init__Method · 0.45
__init__Method · 0.45
__init__Method · 0.45
__init__Method · 0.45

Calls 6

parse_sequence_argFunction · 0.90
warnFunction · 0.90
to_timedeltaFunction · 0.90
get_memberMethod · 0.80
_freezeMethod · 0.80

Tested by

no test coverage detected