Hide navigation sidebar
Hide table of contents sidebar
Skip to content
Back to top
View this page
Toggle table of contents sidebar

# ChatMemberHandler

class telegram.ext.ChatMemberHandler(callback, chat_member_types=-1, block=True, chat_id=None)

  Bases: `telegram.ext.BaseHandler`

  Handler class to handle Telegram updates that contain a chat member update.

  Warning

  When setting `block` to `False`, you cannot rely on adding custom attributes to `telegram.ext.CallbackContext`. See its docs for more info.

  Examples

  Chat Member Bot

  Available In

  `telegram.ext.Application.handlers`

  Added in version 13.4.

  Parameters:

    - callback (coroutine function) –

      The callback function for this handler. Will be called when `check_update()` has determined that an update should be processed by this handler. Callback signature:

          async def callback(update: Update, context: CallbackContext)

      The return value of the callback is usually ignored except for the special case of `telegram.ext.ConversationHandler`.

    - chat_member_types (`int`, optional) – Pass one of `MY_CHAT_MEMBER`, `CHAT_MEMBER` or `ANY_CHAT_MEMBER` to specify if this handler should handle only updates with `telegram.Update.my_chat_member`, `telegram.Update.chat_member` or both. Defaults to `MY_CHAT_MEMBER`.

    - block (`bool`, optional) –

      Determines whether the return value of the callback should be awaited before processing the next handler in `telegram.ext.Application.process_update()`. Defaults to `True`.

      See also

      Concurrency

    - chat_id (`int` | Collection[`int`], optional) – Filters chat member updates from specified chat ID(s) only. .. versionadded:: 21.3

  callback

    The callback function for this handler.

    Type:

      coroutine function

  chat_member_types

    Optional. Specifies if this handler should handle only updates with `telegram.Update.my_chat_member`, `telegram.Update.chat_member` or both.

    Type:

      `int`

  block

    Determines whether the return value of the callback should be awaited before processing the next handler in `telegram.ext.Application.process_update()`.

    Type:

      `bool`

  ANY_CHAT_MEMBER = 1

    Used as a constant to handle both `telegram.Update.my_chat_member` and `telegram.Update.chat_member`.

    Type:

      `int`

  CHAT_MEMBER = 0

    Used as a constant to handle only `telegram.Update.chat_member`.

    Type:

      `int`

  MY_CHAT_MEMBER = -1

    Used as a constant to handle only `telegram.Update.my_chat_member`.

    Type:

      `int`

  check_update(update)

    Determines whether an update should be passed to this handler’s `callback`.

    Parameters:

      update (`telegram.Update` | `object`) – Incoming update.

    Returns:

      `bool`