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

Class PaidMediaPreview

src/telegram/_paidmedia.py:118–173  ·  view source on GitHub ↗

The paid media isn't available before the payment. Objects of this class are comparable in terms of equality. Two objects of this class are considered equal, if their :attr:`width`, :attr:`height`, and :attr:`duration` are equal. .. versionadded:: 21.4 .. versionchanged:: v22.

Source from the content-addressed store, hash-verified

116
117
118class PaidMediaPreview(PaidMedia):
119 """The paid media isn't available before the payment.
120
121 Objects of this class are comparable in terms of equality. Two objects of this class are
122 considered equal, if their :attr:`width`, :attr:`height`, and :attr:`duration`
123 are equal.
124
125 .. versionadded:: 21.4
126
127 .. versionchanged:: v22.2
128 As part of the migration to representing time periods using ``datetime.timedelta``,
129 equality comparison now considers integer durations and equivalent timedeltas as equal.
130
131 Args:
132 type (:obj:`str`): Type of the paid media, always :tg-const:`telegram.PaidMedia.PREVIEW`.
133 width (:obj:`int`, optional): Media width as defined by the sender.
134 height (:obj:`int`, optional): Media height as defined by the sender.
135 duration (:obj:`int` | :class:`datetime.timedelta`, optional): Duration of the media in
136 seconds as defined by the sender.
137
138 .. versionchanged:: v22.2
139 |time-period-input|
140
141 Attributes:
142 type (:obj:`str`): Type of the paid media, always :tg-const:`telegram.PaidMedia.PREVIEW`.
143 width (:obj:`int`): Optional. Media width as defined by the sender.
144 height (:obj:`int`): Optional. Media height as defined by the sender.
145 duration (:obj:`int` | :class:`datetime.timedelta`): Optional. Duration of the media in
146 seconds as defined by the sender.
147
148 .. deprecated:: v22.2
149 |time-period-int-deprecated|
150 """
151
152 __slots__ = ("_duration", "height", "width")
153
154 def __init__(
155 self,
156 width: int | None = None,
157 height: int | None = None,
158 duration: TimePeriod | None = None,
159 *,
160 api_kwargs: JSONDict | None = None,
161 ) -> None:
162 super().__init__(type=PaidMedia.PREVIEW, api_kwargs=api_kwargs)
163
164 with self._unfrozen():
165 self.width: int | None = width
166 self.height: int | None = height
167 self._duration: dtm.timedelta | None = to_timedelta(duration)
168
169 self._id_attrs = (self.type, self.width, self.height, self._duration)
170
171 @property
172 def duration(self) -> int | dtm.timedelta | None:
173 return get_timedelta_value(self._duration, attribute="duration")
174
175

Callers 3

paid_media_previewFunction · 0.90
test_equalityMethod · 0.90

Calls

no outgoing calls

Tested by 2

paid_media_previewFunction · 0.72
test_equalityMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…