Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Parse ¶
func Parse(ctx context.Context, message string, entities []tg.MessageEntityClass, params FormatParams) *event.MessageEventContent
Types ¶
type BodyRange ¶
type BodyRange struct {
Start int
Length int
Value BodyRangeValue
}
func (BodyRange) TruncateEnd ¶
TruncateEnd changes the length of the range, so it ends at or before the given index and starts at the same index as before.
func (BodyRange) TruncateStart ¶
TruncateStart changes the length of the range, so it starts at the given index and ends at the same index as before.
type BodyRangeList ¶
type BodyRangeList []BodyRange
func (BodyRangeList) Len ¶
func (b BodyRangeList) Len() int
func (BodyRangeList) Less ¶
func (b BodyRangeList) Less(i, j int) bool
func (BodyRangeList) Swap ¶
func (b BodyRangeList) Swap(i, j int)
type BodyRangeValue ¶
type FormatParams ¶
type FormatParams struct {
CustomEmojis map[networkid.EmojiID]emojis.EmojiInfo
GetUserInfoByUsername func(ctx context.Context, username string) (UserInfo, error)
GetUserInfoByID func(ctx context.Context, id int64) (UserInfo, error)
NormalizeURL func(ctx context.Context, url string) string
}
func (FormatParams) WithCustomEmojis ¶
func (fp FormatParams) WithCustomEmojis(emojis map[networkid.EmojiID]emojis.EmojiInfo) FormatParams
type LinkedRangeTree ¶
type LinkedRangeTree struct {
Node *BodyRange
Sibling *LinkedRangeTree
Child *LinkedRangeTree
}
LinkedRangeTree is a linked tree of formatting entities.
It's meant to parse a list of Telegram entity ranges into nodes that either overlap completely or not at all, which enables more natural conversion to HTML.
func (*LinkedRangeTree) Add ¶
func (lrt *LinkedRangeTree) Add(r *BodyRange)
Add adds the given formatting entity to this tree.
func (*LinkedRangeTree) Format ¶
func (lrt *LinkedRangeTree) Format(message UTF16String, ctx formatContext) string
type Style ¶
type Style struct {
// Type is the type of style.
Type StyleType
// Language is the language of the code block, if applicable.
Language string
// URL is the URL to link to, if applicable.
URL string
// EmojiInfo is the emoji to display, if applicable.
EmojiInfo emojis.EmojiInfo
}
Style represents a style to apply to a range of text.
type UTF16String ¶
type UTF16String []uint16
func NewUTF16String ¶
func NewUTF16String(s string) UTF16String
func (UTF16String) String ¶
func (u UTF16String) String() string
Click to show internal directories.
Click to hide internal directories.