pytdbot.utils.text_format

pytdbot.utils.text_format.bold(text, html=True, escape=True)[source]

Convert the given text to bold format

Parameters:
  • text (str) – The text to convert

  • html (bool, optional) – If True, returns HTML format, if False returns MarkdownV2. Default is True

  • escape (bool, optional) – Whether escape special characters to the given text or not. Default is True

Returns:

The formated text

Return type:

str

pytdbot.utils.text_format.code(text, html=True, escape=True)[source]

Convert the given text to code format

Parameters:
  • text (str) – The text to convert

  • html (bool, optional) – If True, returns HTML format, if False returns MarkdownV2. Default is True

  • escape (bool, optional) – Whether escape special characters to the given text or not. Default is True

Returns:

The formated text

Return type:

str

pytdbot.utils.text_format.custom_emoji(emoji, custom_emoji_id, html=True)[source]

Convert the given emoji to custom emoji format

Parameters:
  • emoji (str) – The emoji of the custom emoji

  • custom_emoji_id (str) – Identifier of the custom emoji

  • html (bool, optional) – If True, returns HTML format, if False returns MarkdownV2. Default is True

Returns:

The formated text

Return type:

str

Convert the given text to hyperlink format

Parameters:
  • text (str) – The hyperlink text

  • url (str) – The hyperlink url

  • html (bool, optional) – If True, returns HTML format, if False returns MarkdownV2. Default is True

  • escape (bool, optional) – Whether escape special characters to the given text or not. Default is True

Returns:

The formated text

Return type:

str

pytdbot.utils.text_format.italic(text, html=True, escape=True)[source]

Convert the given text to italic format

Parameters:
  • text (str) – The text to convert

  • html (bool, optional) – If True, returns HTML format, if False returns MarkdownV2. Default is True

  • escape (bool, optional) – Whether escape special characters to the given text or not. Default is True

Returns:

The formated text

Return type:

str

pytdbot.utils.text_format.ltr(text)[source]

Add LTR (Left-to-Right) mark to the given text

Parameters:

text (str) – The text to convert

Returns:

The formated text

Return type:

str

pytdbot.utils.text_format.mention(text, user_id, html=True, escape=True)[source]

Convert the given text to inline mention format

Parameters:
  • text (str) – The text of inline mention

  • user_id (str) – The inline user id to mention

  • html (bool, optional) – If True, returns HTML format, if False returns MarkdownV2. Default is True

  • escape (bool, optional) – Whether escape special characters to the given text or not. Default is True

Returns:

The formated text

Return type:

str

pytdbot.utils.text_format.pre(text, html=True, escape=True)[source]

Convert the given text to pre format

Parameters:
  • text (str) – The text to convert

  • html (bool, optional) – If True, returns HTML format, if False returns MarkdownV2. Default is True

  • escape (bool, optional) – Whether escape special characters to the given text or not. Default is True

Returns:

The formated text

Return type:

str

pytdbot.utils.text_format.pre_code(text, language, html=True, escape=True)[source]

Convert the given text to pre-formatted fixed-width code block

Parameters:
  • text (str) – The text to convert

  • language (str) – The name of the programming language written in the given code block

  • html (bool, optional) – If True, returns HTML format, if False returns MarkdownV2. Default is True

  • escape (bool, optional) – Whether escape special characters to the given text or not. Default is True

Returns:

The formated text

Return type:

str

pytdbot.utils.text_format.quote(text, expandable=False, html=True, escape=True)[source]

Convert the given text to quote block

Parameters:
  • text (str) – The text to convert

  • expandable (bool, optional) – Wether the quote is expandable or not. Default is False

  • html (bool, optional) – If True, returns HTML format, if False returns MarkdownV2. Default is True

  • escape (bool, optional) – Whether escape special characters to the given text or not. Default is True

Returns:

The formated text

Return type:

str

pytdbot.utils.text_format.rtl(text)[source]

Add RTL (Right-to-Left) mark to the given text

Parameters:

text (str) – The text to convert

Returns:

The formated text

Return type:

str

pytdbot.utils.text_format.spoiler(text, html=True, escape=True)[source]

Convert the given text to spoiler format

Parameters:
  • text (str) – The text to convert

  • html (bool, optional) – If True, returns HTML format, if False returns MarkdownV2. Default is True

  • escape (bool, optional) – Whether escape special characters to the given text or not. Default is True

Returns:

The formated text

Return type:

str

pytdbot.utils.text_format.strikethrough(text, html=True, escape=True)[source]

Convert the given text to strikethrough format

Parameters:
  • text (str) – The text to convert

  • html (bool, optional) – If True, returns HTML format, if False returns MarkdownV2. Default is True

  • escape (bool, optional) – Whether escape special characters to the given text or not. Default is True

Returns:

The formated text

Return type:

str

pytdbot.utils.text_format.underline(text, html=True, escape=True)[source]

Convert the given text to underline format

Parameters:
  • text (str) – The text to convert

  • html (bool, optional) – If True, returns HTML format, if False returns MarkdownV2. Default is True

  • escape (bool, optional) – Whether escape special characters to the given text or not. Default is True

Returns:

The formated text

Return type:

str