Skip to content
Nill edited this page Sep 8, 2021 · 9 revisions

Telegram internally stores message formatting as plain text plus several entities that describe bold, underline, hyperlinks, etc., but the various Telegram APIs accept text in several forms.

Often times bugs occur when strings are not properly escaped and are parsed by Telegram as Markdown or HTML when they are in fact plan text; Telegram will refuse messages with invalid markup, such as an unescaped '<' or '&' character.

Because of this Telefrag offers a strongly-typed mechanism to address text. The following options can be used anyplace a method or property accepts the TelegramText type.

Parse Mode Type C# Usage
Plain text System.String "this text will be treated as plain and thus can safely contain unescaped <.< & other weirdness"
HTML Telefrag.HTML "This will be <b>bold</b> and <i>italic</i>" as HTML
Markdown Telefrag.Markdown "**hi**" as Markdown
MarkdownV2 Telefrag.MarkdownV2 "*hello*" as MarkdownV2

Clone this wiki locally