package html_test
import (
"context"
"fmt"
"os"
"os/signal"
"go.mau.fi/mautrix-telegram/pkg/gotd/telegram"
"go.mau.fi/mautrix-telegram/pkg/gotd/telegram/message"
"go.mau.fi/mautrix-telegram/pkg/gotd/telegram/message/html"
"go.mau.fi/mautrix-telegram/pkg/gotd/tg"
)
func sendHTML(ctx context.Context) error {
client, err := telegram.ClientFromEnvironment(telegram.Options{})
if err != nil {
return err
}
// This example creates a styled message from BotAPI examples
// and sends to your Saved Messages folder.
// See https://core.telegram.org/bots/api#html-style.
return client.Run(ctx, func(ctx context.Context) error {
_, err := message.NewSender(tg.NewClient(client)).
Self().StyledText(ctx, html.String(nil, `bold, bold
italic, italic
underline, underline
strikethrough, strikethrough, strikethrough
spoiler, italic bold strikethrough italic bold strikethrough spoiler underline italic bold bold
inline URL
inline mention of a user
inline fixed-width code
pre-formatted fixed-width code block
pre-formatted fixed-width code block written in the Python programming language
Block quotation started\nBlock quotation continued\nThe last line of the block quotation
Expandable block quotation started\nExpandable block quotation continued\nExpandable block quotation continued\nHidden by default part of the block quotation started\nExpandable block quotation continued\nThe last line of the block quotation`)) return err }) } func ExampleString() { ctx, cancel := signal.NotifyContext(context.Background(), os.Interrupt) defer cancel() if err := sendHTML(ctx); err != nil { _, _ = fmt.Fprintf(os.Stderr, "%+v\n", err) os.Exit(2) } }