Hide navigation sidebar
Hide table of contents sidebar
PTB has undergone significant changes in v20. Please read the documentation carefully and also check out the transition guide in the wiki.
Back to top
Toggle table of contents sidebar

# ChatMemberUpdated

class telegram.ChatMemberUpdated(chat, from_user, date, old_chat_member, new_chat_member, invite_link=None, via_chat_folder_invite_link=None, *, api_kwargs=None)

  Bases: `telegram.TelegramObject`

  This object represents changes in the status of a chat member.

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

  Available In

  - `telegram.Update.chat_member`

  - `telegram.Update.my_chat_member`

  New in version 13.4.

  Note

  In Python `from` is a reserved word. Use `from_user` instead.

  Examples

  Chat Member Bot

  Parameters:

    - chat (`telegram.Chat`) – Chat the user belongs to.

    - from_user (`telegram.User`) – Performer of the action, which resulted in the change.

    - date (`datetime.datetime`) –

      Date the change was done in Unix time. Converted to `datetime.datetime`.

      Changed in version 20.3: The default timezone of the bot is used for localization, which is UTC unless `telegram.ext.Defaults.tzinfo` is used.

    - old_chat_member (`telegram.ChatMember`) – Previous information about the chat member.

    - new_chat_member (`telegram.ChatMember`) – New information about the chat member.

    - invite_link (`telegram.ChatInviteLink`, optional) – Chat invite link, which was used by the user to join the chat. For joining by invite link events only.

    - via_chat_folder_invite_link (`bool`, optional) –

      `True`, if the user joined the chat via a chat folder invite link

      New in version 20.3.

  chat

    Chat the user belongs to.

    Type:

      `telegram.Chat`

  from_user

    Performer of the action, which resulted in the change.

    Type:

      `telegram.User`

  date

    Date the change was done in Unix time. Converted to `datetime.datetime`.

    Changed in version 20.3: The default timezone of the bot is used for localization, which is UTC unless `telegram.ext.Defaults.tzinfo` is used.

    Type:

      `datetime.datetime`

  old_chat_member

    Previous information about the chat member.

    Type:

      `telegram.ChatMember`

  new_chat_member

    New information about the chat member.

    Type:

      `telegram.ChatMember`

  invite_link

    Optional. Chat invite link, which was used by the user to join the chat. For joining by invite link events only.

    Type:

      `telegram.ChatInviteLink`

  via_chat_folder_invite_link

    Optional. `True`, if the user joined the chat via a chat folder invite link

    New in version 20.3.

    Type:

      `bool`

  classmethod de_json(data, bot)

    See `telegram.TelegramObject.de_json()`.

  difference()

    Computes the difference between `old_chat_member` and `new_chat_member`.

    Example

        >>> chat_member_updated.difference()
        {'custom_title': ('old title', 'new title')}

    Note

    To determine, if the `telegram.ChatMember.user` attribute has changed, every attribute of the user will be checked.

    New in version 13.5.

    Returns:

      A dictionary mapping attribute names to tuples of the form `(old_value, new_value)`

    Return type:

      Dict[`str`, Tuple[`object`, `object`]]