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

# ChatJoinRequestHandler

class telegram.ext.ChatJoinRequestHandler(callback, chat_id=None, username=None, block=True)

  Bases: `telegram.ext.BaseHandler`

  Handler class to handle Telegram updates that contain `telegram.Update.chat_join_request`.

  Note

  If neither of `username` and the `chat_id` are passed, this handler accepts any join request. Otherwise, this handler accepts all requests to join chats for which the chat ID is listed in `chat_id` or the username is listed in `username`, or both.

  New in version 20.0.

  Warning

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

  Available In

  `telegram.ext.Application.handlers`

  New in version 13.8.

  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_id (`int` | Collection[`int`], optional) –

      Filters requests to allow only those which are asking to join the specified chat ID(s).

      New in version 20.0.

    - username (`str` | Collection[`str`], optional) –

      Filters requests to allow only those which are asking to join the specified username(s).

      New in version 20.0.

    - 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

  callback

    The callback function for this handler.

    Type:

      coroutine function

  block

    Determines whether the callback will run in a blocking way..

    Type:

      `bool`

  check_update(update)

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

    Parameters:

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

    Returns:

      `bool`