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.
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
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