ptbtest.entityparser module

This module provides a helper class to transform marked-up messages to plain text with entities. Docs: https://core.telegram.org/bots/api#formatting-options

ptbtest.entityparser.get_item(seq: Sequence, index: int, default: Any = None) Any

Safely gets item from the sequence by its index. If the index is out of the range, then the default value is returned.

ptbtest.entityparser.get_utf_16_length(char: str) int

Telegram uses UTF-16 for message entities: https://core.telegram.org/api/entities#utf-16

A simple way of computing the entity length is converting the text to UTF-16, and then taking the byte length divided by 2 (=number of UTF-16 code units). Source: https://core.telegram.org/api/entities#computing-entity-length