Skip to content
Back to top
View this page

# PaidMediaPreview

class telegram.PaidMediaPreview(width=None, height=None, duration=None, *, api_kwargs=None)

  Bases: `telegram.PaidMedia`

  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 `width`, `height`, and `duration` are equal.

  Available In

  - `telegram.PaidMediaInfo.paid_media`

  - `telegram.TransactionPartnerUser.paid_media`

  Added in version 21.4.

  Changed in version v22.2: As part of the migration to representing time periods using `datetime.timedelta`, equality comparison now considers integer durations and equivalent timedeltas as equal.

  Parameters:

    - type (`str`) – Type of the paid media, always `'preview'`.

    - width (`int`, optional) – Media width as defined by the sender.

    - height (`int`, optional) – Media height as defined by the sender.

    - duration (`int` | `datetime.timedelta`, optional) –

      Duration of the media in seconds as defined by the sender.

      Changed in version v22.2: `datetime.timedelta` objects are accepted in addition to plain `int` values.

  type

    Type of the paid media, always `'preview'`.

    Type:

      `str`

  width

    Optional. Media width as defined by the sender.

    Type:

      `int`

  height

    Optional. Media height as defined by the sender.

    Type:

      `int`

  duration

    Optional. Duration of the media in seconds as defined by the sender.

    Deprecated since version v22.2: In a future major version this attribute will be of type `datetime.timedelta`. You can opt-in early by setting PTB_TIMEDELTA=true or `PTB_TIMEDELTA=1` as an environment variable.

    Type:

      `int` | `datetime.timedelta`