Overview#

Python markup module for Telegram messenger. This module provides a rich list of components to build any possible markup fast and render it to specific html or MarkdownV2 formats.

https://img.shields.io/pypi/pyversions/telegram-text.svg https://github.com/SKY-ALIN/telegram-text/actions/workflows/tests.yml/badge.svg https://github.com/SKY-ALIN/telegram-text/actions/workflows/code-quality.yml/badge.svg https://codecov.io/gh/SKY-ALIN/telegram-text/branch/dev/graph/badge.svg?token=BK0ASC89B9 https://badge.fury.io/py/telegram-text.svg https://img.shields.io/github/license/SKY-ALIN/telegram-text.svg

Installation#

Install using pip install telegram-text or poetry add telegram-text.

Also, telegram-text is integrated into following packages:

Module

Installation

Import

Documentation

python-telegram

pip install python-telegram

from telegram.text import ...

Readme

OrigamiBot

pip install origamibot[telegram-text]

from origamibot.text import ...

Release

TGramBot

pip install tgrambot

from tgrambot.text import ...

Readme

Basic Example#

from telegram_text import Bold, Italic, Underline

text = Underline(Bold("Bold") + "and" + Italic("italic") + "with underline.")
Basic example result

Advanced Example#

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'
)
Advanced example result