Skip to content
Back to top
View this page

# MessageOrigin

class telegram.MessageOrigin(type, date, *, api_kwargs=None)

  Bases: `telegram.TelegramObject`

  Base class for telegram MessageOrigin object, it can be one of:

  - `MessageOriginUser`

  - `MessageOriginHiddenUser`

  - `MessageOriginChat`

  - `MessageOriginChannel`

  Objects of this class are comparable in terms of equality. Two objects of this class are considered equal, if their `type` and `date` are equal.

  Available In

  - `telegram.ExternalReplyInfo.origin`

  - `telegram.Message.forward_origin`

  Added in version 20.8.

  Parameters:

    - type (`str`) – Type of the message origin, can be on of: `USER`, `HIDDEN_USER`, `CHAT`, or `CHANNEL`.

    - date (`datetime.datetime`) – Date the message was sent originally. The default timezone of the bot is used for localization, which is UTC unless `telegram.ext.Defaults.tzinfo` is used.

  type

    Type of the message origin, can be on of: `USER`, `HIDDEN_USER`, `CHAT`, or `CHANNEL`.

    Type:

      `str`

  date

    Date the message was sent originally. The default timezone of the bot is used for localization, which is UTC unless `telegram.ext.Defaults.tzinfo` is used.

    Type:

      `datetime.datetime`

  CHANNEL = 'channel'

    `telegram.constants.MessageOriginType.CHANNEL`

  CHAT = 'chat'

    `telegram.constants.MessageOriginType.CHAT`

  HIDDEN_USER = 'hidden_user'

    `telegram.constants.MessageOriginType.HIDDEN_USER`

  USER = 'user'

    `telegram.constants.MessageOriginType.USER`

  classmethod de_json(data, bot=None)

    Converts JSON data to the appropriate `MessageOrigin` object, i.e. takes care of selecting the correct subclass.