7a04f298d2
- update to latest telegram layer - remove some references to fields in tg.Entities that don't exist in the schema - originally added here: https://github.com/beeper/td/commit/820929062a2ba0104397bc01235ab58a9cff780e - referenced here - https://github.com/mautrix/telegramgo/commit/124f0967ed195b5a380c9bd02e170ada9710dde3 - https://github.com/mautrix/telegramgo/commit/4205047aab2e0639217148b5d125bfaab668bd8e
53 lines
2.1 KiB
Go
53 lines
2.1 KiB
Go
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, `<b>bold</b>, <strong>bold</strong>
|
|
<i>italic</i>, <em>italic</em>
|
|
<u>underline</u>, <ins>underline</ins>
|
|
<s>strikethrough</s>, <strike>strikethrough</strike>, <del>strikethrough</del>
|
|
<span class="tg-spoiler">spoiler</span>, <tg-spoiler>spoiler</tg-spoiler>
|
|
<b>bold <i>italic bold <s>italic bold strikethrough <span class="tg-spoiler">italic bold strikethrough spoiler</span></s> <u>underline italic bold</u></i> bold</b>
|
|
<a href="http://www.example.com/">inline URL</a>
|
|
<a href="tg://user?id=123456789">inline mention of a user</a>
|
|
<tg-emoji emoji-id="5368324170671202286">👍</tg-emoji>
|
|
<code>inline fixed-width code</code>
|
|
<pre>pre-formatted fixed-width code block</pre>
|
|
<pre><code class="language-python">pre-formatted fixed-width code block written in the Python programming language</code></pre>
|
|
<blockquote>Block quotation started\nBlock quotation continued\nThe last line of the block quotation</blockquote>
|
|
<blockquote expandable>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</blockquote>`))
|
|
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)
|
|
}
|
|
}
|