← Developer guides

Telegram entities

Send Markdown to the Telegram Bot API with explicit formatting entities. Passing the returned text and entities together preserves formatting when the input contains emoji.

Installation guide Β· Examples tested with 0.3.1

Result

The result contains β€œπŸ˜€ Ready” and a bold entity starting at UTF-16 offset 3 with length 5. Pass the text and entities together, add the chat ID and send each part in order.

Code examples

  • TypeScript
  • Python
  • Go

TypeScript

import { toMessages } from "mdto-messages";

const batch = toMessages("πŸ˜€ **Ready**", "telegram");
console.log(batch.messages);

Python

from mdto_messages import to_messages

batch = to_messages("πŸ˜€ **Ready**", "telegram")
print(batch.messages)

Go

package main

import (
    "fmt"
    "log"

    "github.com/jmeinke/mdto-messages"
)

func main() {
    batch, err := mdto.ToMessages("πŸ˜€ **Ready**", mdto.Telegram)
    if err != nil {
        log.Fatal(err)
    }
    fmt.Println(batch.Messages)
}

Format a draft for the Telegram app

References

  • Original example and platform reference
  • API reference and limits

Source: mdto-messages 0.3.1 Β· MIT license