Skip to content
Back to top
View this page

# Checklist

class telegram.Checklist(title, tasks, title_entities=None, others_can_add_tasks=None, others_can_mark_tasks_as_done=None, *, api_kwargs=None)

  Bases: `telegram.TelegramObject`

  Describes a checklist.

  Objects of this class are comparable in terms of equality. Two objects of this class are considered equal, if all their `tasks` are equal.

  Available In

  - `telegram.ExternalReplyInfo.checklist`

  - `telegram.Message.checklist`

  Added in version 22.3.

  Parameters:

    - title (`str`) – Title of the checklist.

    - title_entities (Sequence[`telegram.MessageEntity`], optional) – Special entities that appear in the checklist title.

    - tasks (Sequence[`telegram.ChecklistTask`]) – List of tasks in the checklist.

    - others_can_add_tasks (`bool`, optional) – `True` if users other than the creator of the list can add tasks to the list

    - others_can_mark_tasks_as_done (`bool`, optional) – `True` if users other than the creator of the list can mark tasks as done or not done

  title

    Title of the checklist.

    Type:

      `str`

  title_entities

    Optional. Special entities that appear in the checklist title.

    Type:

      Tuple[`telegram.MessageEntity`]

  tasks

    List of tasks in the checklist.

    Type:

      Tuple[`telegram.ChecklistTask`]

  others_can_add_tasks

    Optional. `True` if users other than the creator of the list can add tasks to the list

    Type:

      `bool`

  others_can_mark_tasks_as_done

    Optional. `True` if users other than the creator of the list can mark tasks as done or not done

    Type:

      `bool`

  classmethod de_json(data, bot=None)

    See `telegram.TelegramObject.de_json()`.

  parse_entities(types=None)

    Returns a `dict` that maps `telegram.MessageEntity` to `str`. It contains entities from this checklist’s title filtered by their `type` attribute as the key, and the text that each entity belongs to as the value of the `dict`.

    Note

    This method should always be used instead of the `title_entities` attribute, since it calculates the correct substring from the message text based on UTF-16 codepoints. See `parse_entity` for more info.

    Parameters:

      types (list[`str`], optional) – List of `MessageEntity` types as strings. If the `type` attribute of an entity is contained in this list, it will be returned. Defaults to `telegram.MessageEntity.ALL_TYPES`.

    Returns:

      A dictionary of entities mapped to the text that belongs to them, calculated based on UTF-16 codepoints.

    Return type:

      dict[`telegram.MessageEntity`, `str`]

  parse_entity(entity)

    Returns the text in `title` from a given `telegram.MessageEntity` of `title_entities`.

    Note

    This method is present because Telegram calculates the offset and length in UTF-16 codepoint pairs, which some versions of Python don’t handle automatically. (That is, you can’t just slice `title` with the offset and length.)

    Parameters:

      entity (`telegram.MessageEntity`) – The entity to extract the text from. It must be an entity that belongs to `title_entities`.

    Returns:

      The text of the given entity.

    Return type:

      `str`