Skip to content
Back to top
View this page

# ChecklistTask

class telegram.ChecklistTask(id, text, text_entities=None, completed_by_user=None, completion_date=None, completed_by_chat=None, *, api_kwargs=None)

  Bases: `telegram.TelegramObject`

  Describes a task in a checklist.

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

  Available In

  - `telegram.Checklist.tasks`

  - `telegram.ChecklistTasksAdded.tasks`

  Added in version 22.3.

  Parameters:

    - id (`int`) – Unique identifier of the task.

    - text (`str`) – Text of the task.

    - text_entities (Sequence[`telegram.MessageEntity`], optional) – Special entities that appear in the task text.

    - completed_by_user (`telegram.User`, optional) – User that completed the task; omitted if the task wasn’t completed

    - completed_by_chat (`telegram.Chat`, optional) –

      Chat that completed the task; omitted if the task wasn’t completed by a chat

      Added in version 22.6.

    - completion_date (`datetime.datetime`, optional) –

      Point in time when the task was completed; `ZERO_DATE` if the task wasn’t completed

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

  id

    Unique identifier of the task.

    Type:

      `int`

  text

    Text of the task.

    Type:

      `str`

  text_entities

    Optional. Special entities that appear in the task text.

    Type:

      Tuple[`telegram.MessageEntity`]

  completed_by_user

    Optional. User that completed the task; omitted if the task wasn’t completed

    Type:

      `telegram.User`

  completed_by_chat

    Optional. Chat that completed the task; omitted if the task wasn’t completed by a chat

    Added in version 22.6.

    Type:

      `telegram.Chat`

  completion_date

    Optional. Point in time when the task was completed; `ZERO_DATE` if the task wasn’t completed

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

    Type:

      `datetime.datetime`

  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 task 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 `text_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 `text` from a given `telegram.MessageEntity` of `text_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 `ChecklistTask.text` with the offset and length.)

    Parameters:

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

    Returns:

      The text of the given entity.

    Return type:

      `str`