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

# ChatBoostHandler

New in version 20.8.

class telegram.ext.ChatBoostHandler(callback, chat_boost_types=-1, chat_id=None, chat_username=None, block=True)

  Bases: `telegram.ext.BaseHandler`

  Handler class to handle Telegram updates that contain a chat boost.

  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 20.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_boost_types (`int`, optional) – Pass one of `CHAT_BOOST`, `REMOVED_CHAT_BOOST` or `ANY_CHAT_BOOST` to specify if this handler should handle only updates with `telegram.Update.chat_boost`, `telegram.Update.removed_chat_boost` or both. Defaults to `CHAT_BOOST`.

    - chat_id (`int` | Collection[`int`], optional) – Filters reactions to allow only those which happen in the specified chat ID(s).

    - chat_username (`str` | Collection[`str`], optional) – Filters reactions to allow only those which happen in the specified username(s).

    - 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

  chat_boost_types

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

    Type:

      `int`

  block

    Determines whether the callback will run in a blocking way.

    Type:

      `bool`

  ANY_CHAT_BOOST = 1

    Used as a constant to handle both `telegram.Update.chat_boost` and `telegram.Update.removed_chat_boost`.

    Type:

      `int`

  CHAT_BOOST = -1

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

    Type:

      `int`

  REMOVED_CHAT_BOOST = 0

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

    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`