### Python __add__ Method Example Source: https://github.com/sky-alin/telegram-text/blob/dev/docs/source/user_guide/index.rst Demonstrates the use of the __add__ magic method for combining text elements and strings. This operation results in a Chain object, which aggregates multiple elements. ```python >>> text = Bold("Hello") + Italic("world") + "!!!" >>> text + + , sep=' '> ``` -------------------------------- ### Advanced Telegram Text Formatting with Python Source: https://github.com/sky-alin/telegram-text/blob/dev/docs/source/index.rst Illustrates advanced text structuring using Chain, TOMLSection, Hashtag, Link, and UnorderedList. This example shows how to build complex message layouts with nested structures and formatted lists for Telegram. ```python from telegram_text import Bold, Chain, Italic, TOMLSection, Hashtag, Link, UnorderedList description = "A Channel about software developing and distributing. Subscribe to follow new technologies." tags: dict[str, str] = {...} # Tags description with following format `tag: tag_description` links: dict[str, str] = {...} # Links with following format `text: url` menu = Chain( TOMLSection( 'Menu', Italic(description), ), TOMLSection( 'Tags', *[Hashtag(tag, style=Bold) + f"- {about}" for tag, about in tags.items()], ), TOMLSection( 'Links', UnorderedList(*[Link(text, url) for text, url in links.items()]), ), sep='\n\n' ) ``` -------------------------------- ### Telegram Text Formatting Methods (MarkdownV2, HTML, PlainText) Source: https://github.com/sky-alin/telegram-text/blob/dev/docs/source/user_guide/index.rst Provides examples of formatting text elements for Telegram using MarkdownV2, HTML, and plain text. Includes methods for escaping special characters and converting elements to different formats. ```APIDOC telegram_text.bases.Chain.to_plain_text() Formats the element to plain text without escaping, tags, or special characters. Useful for debugging or logging, but not recommended for direct use with the Telegram API due to potential rejection by the API if escaping is needed. telegram_text.bases.Chain.to_markdown() Formats the element to Markdown/MarkdownV2 format according to Telegram's specification, including necessary escaping. Example: >>> text.to_markdown() '*Hello* _world_ \!\!\!' telegram_text.bases.Chain.to_html() Formats the element to HTML format according to Telegram's specification. Example: >>> text.to_html() 'Hello world !!!' telegram_text.bases.PlainText.to_markdown() Demonstrates escaping special characters when converting to Markdown. Example: >>> PlainText(text).to_markdown() 'Hello world \!\!\!' ``` -------------------------------- ### Build Complex Telegram Text Markup with Chain, TOMLSection, Hashtag, Link, UnorderedList in Python Source: https://github.com/sky-alin/telegram-text/blob/dev/README.md This advanced example showcases the use of multiple components from the telegram-text library to construct a structured message. It utilizes Chain for combining sections, TOMLSection for creating distinct blocks, Hashtag for clickable tags, Link for URLs, and UnorderedList for bullet points, demonstrating a more sophisticated message formatting capability. ```python from telegram_text import Bold, Chain, Italic, TOMLSection, Hashtag, Link, UnorderedList description = "A Channel about software developing and distributing. Subscribe to follow new technologies." tags: dict[str, str] = {...} # Tags description with following format `tag: tag_description` links: dict[str, str] = {...} # Links with following format `text: url` menu = Chain( TOMLSection( 'Menu', Italic(description), ), TOMLSection( 'Tags', *[Hashtag(tag, style=Bold) + f"- {about}" for tag, about in tags.items()], ), TOMLSection( 'Links', UnorderedList(*[Link(text, url) for text, url in links.items()]), ), sep='\n\n' ) ``` -------------------------------- ### Basic Telegram Text Formatting with Python Source: https://github.com/sky-alin/telegram-text/blob/dev/docs/source/index.rst Demonstrates basic text formatting using Bold, Italic, and Underline components from the telegram-text library. It shows how to combine these components to create styled text for Telegram messages. ```python from telegram_text import Bold, Italic, Underline text = Underline(Bold("Bold") + "and" + Italic("italic") + "with underline.") ``` -------------------------------- ### Telegram Text Library API Reference Source: https://github.com/sky-alin/telegram-text/blob/dev/docs/source/api_reference.rst This section provides a detailed API reference for the telegram-text library. It covers various modules including bases, styles, elements, markdown formatting, and custom components. Each class is documented with its inheritance, special methods, and public members, offering insights into how to construct rich text for Telegram messages. ```APIDOC Module: telegram_text.bases Classes: AbstractElement: Inheritance: Element Special Members: __add__ Members: (All public members) Element: Inheritance: (None specified) Special Members: __add__, __eq__, __str__ Members: (All public members) Text: Inheritance: (None specified) Members: (All public members) PlainText: Inheritance: Text Members: (All public members) Chain: Inheritance: (None specified) Special Members: __contains__ Members: (All public members) Module: telegram_text.styles Classes: Style: Inheritance: (None specified) Members: (All public members) Bold: Inheritance: Style Members: (All public members) Code: Inheritance: Style Members: (All public members) InlineCode: Inheritance: Style Members: (All public members) Italic: Inheritance: Style Members: (All public members) Quote: Inheritance: Style Members: (All public members) Spoiler: Inheritance: Style Members: (All public members) Strikethrough: Inheritance: Style Members: (All public members) Underline: Inheritance: Style Members: (All public members) Module: telegram_text.elements Classes: Emoji: Inheritance: (None specified) Members: (All public members) Hashtag: Inheritance: (None specified) Members: (All public members) InlineUser: Inheritance: (None specified) Members: (All public members) Link: Inheritance: (None specified) Members: (All public members) User: Inheritance: (None specified) Members: (All public members) Module: telegram_text.markdown Classes: OrderedList: Inheritance: (None specified) Members: (All public members) UnorderedList: Inheritance: (None specified) Members: (All public members) Module: telegram_text.custom Classes: TOMLSection: Inheritance: (None specified) Members: (All public members) ``` -------------------------------- ### Create Bold and Italic Text with Underline in Python Source: https://github.com/sky-alin/telegram-text/blob/dev/README.md This snippet demonstrates how to use the Bold, Italic, and Underline components from the telegram-text library to format text. It shows how to combine these components and apply them to create a message with mixed formatting. ```python from telegram_text import Bold, Italic, Underline text = Underline(Bold("Bold") + "and" + Italic("italic") + "with underline.") ``` -------------------------------- ### Telegram Text AbstractElement Base Class Source: https://github.com/sky-alin/telegram-text/blob/dev/docs/source/user_guide/index.rst Describes the base interface for elements within the telegram_text module, highlighting inheritance and special members like __add__. ```APIDOC telegram_text.bases.AbstractElement Base class for all elements in the telegram_text module. Inherits from: - (Implicitly, common object methods) Members: - __add__(self, other): Magic method for element concatenation. Special Members: - __add__: Enables summing elements with strings or other elements, creating a Chain object. ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.