Documentation ¶
Overview ¶
Package entity contains message formatting and styling helpers.
Code generated by mkentity, DO NOT EDIT.
Index ¶
- func ComputeLength(s string) int
- func ComputeLengthBytes(s []byte) (n int)
- func SortEntities(entity []tg.MessageEntityClass)
- type Builder
- func (b *Builder) BankCard(s string) *Builder
- func (b *Builder) Blockquote(s string) *Builder
- func (b *Builder) Bold(s string) *Builder
- func (b *Builder) BotCommand(s string) *Builder
- func (b *Builder) Cashtag(s string) *Builder
- func (b *Builder) Code(s string) *Builder
- func (b *Builder) Complete() (string, []tg.MessageEntityClass)
- func (b *Builder) CustomEmoji(s string, documentID int64) *Builder
- func (b *Builder) Email(s string) *Builder
- func (b *Builder) EntitiesLen() int
- func (b *Builder) Format(s string, formats ...Formatter) *Builder
- func (b *Builder) GrowEntities(n int)
- func (b *Builder) GrowText(n int)
- func (b *Builder) Hashtag(s string) *Builder
- func (b *Builder) Italic(s string) *Builder
- func (b *Builder) LastEntity() (tg.MessageEntityClass, bool)
- func (b *Builder) Mention(s string) *Builder
- func (b *Builder) MentionName(s string, userID tg.InputUserClass) *Builder
- func (b *Builder) Phone(s string) *Builder
- func (b *Builder) Plain(s string) *Builder
- func (b *Builder) Pre(s string, language string) *Builder
- func (b *Builder) Raw() (string, []tg.MessageEntityClass)
- func (b *Builder) Reset()
- func (b *Builder) ShrinkPreCode()
- func (b *Builder) Spoiler(s string) *Builder
- func (b *Builder) Strike(s string) *Builder
- func (b *Builder) TextRange(from, to int) string
- func (b *Builder) TextURL(s string, uRL string) *Builder
- func (b *Builder) Token() Token
- func (b *Builder) URL(s string) *Builder
- func (b *Builder) UTF16Len() int
- func (b *Builder) UTF8Len() int
- func (b *Builder) Underline(s string) *Builder
- func (b *Builder) Unknown(s string) *Builder
- func (b *Builder) Write(s []byte) (int, error)
- func (b *Builder) WriteByte(s byte) error
- func (b *Builder) WriteRune(s rune) (int, error)
- func (b *Builder) WriteString(s string) (int, error)
- type Formatter
- func BankCard() Formatter
- func Blockquote() Formatter
- func Bold() Formatter
- func BotCommand() Formatter
- func Cashtag() Formatter
- func Code() Formatter
- func CustomEmoji(documentID int64) Formatter
- func Email() Formatter
- func Hashtag() Formatter
- func Italic() Formatter
- func Mention() Formatter
- func MentionName(userID tg.InputUserClass) Formatter
- func Phone() Formatter
- func Pre(language string) Formatter
- func Spoiler() Formatter
- func Strike() Formatter
- func TextURL(uRL string) Formatter
- func URL() Formatter
- func Underline() Formatter
- func Unknown() Formatter
- type Token
- type UserResolver
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ComputeLength ¶
ComputeLength returns length of s encoded as UTF-16 string.
While Telegram API docs state that they expect the number of UTF-8 code points, in fact they are talking about UTF-16 code units.
func ComputeLengthBytes ¶
ComputeLengthBytes returns length of s encoded as UTF-16 string.
While Telegram API docs state that they expect the number of UTF-8 code points, in fact they are talking about UTF-16 code units.
func SortEntities ¶
func SortEntities(entity []tg.MessageEntityClass)
SortEntities sorts entities as TDLib does it.
Types ¶
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
Builder builds message string and text entities.
func (*Builder) BankCard ¶
BankCard adds and formats message as BankCard message entity.
See https://core.telegram.org/constructor/messageEntityBankCard.
func (*Builder) Blockquote ¶
Blockquote adds and formats message as Blockquote message entity.
See https://core.telegram.org/constructor/messageEntityBlockquote.
func (*Builder) Bold ¶
Bold adds and formats message as Bold message entity.
See https://core.telegram.org/constructor/messageEntityBold.
func (*Builder) BotCommand ¶
BotCommand adds and formats message as BotCommand message entity.
See https://core.telegram.org/constructor/messageEntityBotCommand.
func (*Builder) Cashtag ¶
Cashtag adds and formats message as Cashtag message entity.
See https://core.telegram.org/constructor/messageEntityCashtag.
func (*Builder) Code ¶
Code adds and formats message as Code message entity.
See https://core.telegram.org/constructor/messageEntityCode.
func (*Builder) Complete ¶
func (b *Builder) Complete() (string, []tg.MessageEntityClass)
Complete returns build result and resets builder.
func (*Builder) CustomEmoji ¶
CustomEmoji adds and formats message as CustomEmoji message entity.
See https://core.telegram.org/constructor/messageEntityCustomEmoji.
func (*Builder) Email ¶
Email adds and formats message as Email message entity.
See https://core.telegram.org/constructor/messageEntityEmail.
func (*Builder) EntitiesLen ¶
EntitiesLen return length of added entities.
func (*Builder) GrowEntities ¶
GrowEntities grows internal buffer capacity.
func (*Builder) Hashtag ¶
Hashtag adds and formats message as Hashtag message entity.
See https://core.telegram.org/constructor/messageEntityHashtag.
func (*Builder) Italic ¶
Italic adds and formats message as Italic message entity.
See https://core.telegram.org/constructor/messageEntityItalic.
func (*Builder) LastEntity ¶
func (b *Builder) LastEntity() (tg.MessageEntityClass, bool)
LastEntity returns last entity if any.
func (*Builder) Mention ¶
Mention adds and formats message as Mention message entity.
See https://core.telegram.org/constructor/messageEntityMention.
func (*Builder) MentionName ¶
func (b *Builder) MentionName(s string, userID tg.InputUserClass) *Builder
MentionName adds and formats message as MentionName message entity.
See https://core.telegram.org/constructor/inputMessageEntityMentionName.
func (*Builder) Phone ¶
Phone adds and formats message as Phone message entity.
See https://core.telegram.org/constructor/messageEntityPhone.
func (*Builder) Raw ¶
func (b *Builder) Raw() (string, []tg.MessageEntityClass)
Raw returns raw result and resets builder without fixing spaces.
func (*Builder) ShrinkPreCode ¶
func (b *Builder) ShrinkPreCode()
ShrinkPreCode merges following <pre> and <code> entities, if needed.
This function is used by formatters to be compliant with TDLib.
func (*Builder) Spoiler ¶
Spoiler adds and formats message as Spoiler message entity.
See https://core.telegram.org/constructor/messageEntitySpoiler.
func (*Builder) Strike ¶
Strike adds and formats message as Strike message entity.
See https://core.telegram.org/constructor/messageEntityStrike.
func (*Builder) TextRange ¶
TextRange returns message text of given byte (UTF-8) range.
If range is invalid, it will panic.
func (*Builder) TextURL ¶
TextURL adds and formats message as TextURL message entity.
See https://core.telegram.org/constructor/messageEntityTextUrl.
func (*Builder) Underline ¶
Underline adds and formats message as Underline message entity.
See https://core.telegram.org/constructor/messageEntityUnderline.
func (*Builder) Unknown ¶
Unknown adds and formats message as Unknown message entity.
See https://core.telegram.org/constructor/messageEntityUnknown.
type Formatter ¶
type Formatter func(offset, limit int) tg.MessageEntityClass
Formatter is a message entity constructor.
func BankCard ¶
func BankCard() Formatter
BankCard creates Formatter of BankCard message entity.
See https://core.telegram.org/constructor/messageEntityBankCard.
func Blockquote ¶
func Blockquote() Formatter
Blockquote creates Formatter of Blockquote message entity.
See https://core.telegram.org/constructor/messageEntityBlockquote.
func Bold ¶
func Bold() Formatter
Bold creates Formatter of Bold message entity.
See https://core.telegram.org/constructor/messageEntityBold.
func BotCommand ¶
func BotCommand() Formatter
BotCommand creates Formatter of BotCommand message entity.
See https://core.telegram.org/constructor/messageEntityBotCommand.
func Cashtag ¶
func Cashtag() Formatter
Cashtag creates Formatter of Cashtag message entity.
See https://core.telegram.org/constructor/messageEntityCashtag.
func Code ¶
func Code() Formatter
Code creates Formatter of Code message entity.
See https://core.telegram.org/constructor/messageEntityCode.
func CustomEmoji ¶
CustomEmoji creates Formatter of CustomEmoji message entity.
See https://core.telegram.org/constructor/messageEntityCustomEmoji.
func Email ¶
func Email() Formatter
Email creates Formatter of Email message entity.
See https://core.telegram.org/constructor/messageEntityEmail.
func Hashtag ¶
func Hashtag() Formatter
Hashtag creates Formatter of Hashtag message entity.
See https://core.telegram.org/constructor/messageEntityHashtag.
func Italic ¶
func Italic() Formatter
Italic creates Formatter of Italic message entity.
See https://core.telegram.org/constructor/messageEntityItalic.
func Mention ¶
func Mention() Formatter
Mention creates Formatter of Mention message entity.
See https://core.telegram.org/constructor/messageEntityMention.
func MentionName ¶
func MentionName(userID tg.InputUserClass) Formatter
MentionName creates Formatter of MentionName message entity.
See https://core.telegram.org/constructor/inputMessageEntityMentionName.
func Phone ¶
func Phone() Formatter
Phone creates Formatter of Phone message entity.
See https://core.telegram.org/constructor/messageEntityPhone.
func Spoiler ¶
func Spoiler() Formatter
Spoiler creates Formatter of Spoiler message entity.
See https://core.telegram.org/constructor/messageEntitySpoiler.
func Strike ¶
func Strike() Formatter
Strike creates Formatter of Strike message entity.
See https://core.telegram.org/constructor/messageEntityStrike.
func TextURL ¶
TextURL creates Formatter of TextURL message entity.
See https://core.telegram.org/constructor/messageEntityTextUrl.
func Underline ¶
func Underline() Formatter
Underline creates Formatter of Underline message entity.
See https://core.telegram.org/constructor/messageEntityUnderline.
func Unknown ¶
func Unknown() Formatter
Unknown creates Formatter of Unknown message entity.
See https://core.telegram.org/constructor/messageEntityUnknown.
type Token ¶
type Token struct {
// contains filtered or unexported fields
}
Token represents raw point in a message string.
func (Token) Apply ¶
Apply formats range between token start and current state using given Formatter slice.
func (Token) UTF16Length ¶
UTF16Length returns UTF-16 length between token start and current state.
func (Token) UTF8Length ¶
UTF8Length return UTF-8 length between token start and current state.
type UserResolver ¶
type UserResolver = func(id int64) (tg.InputUserClass, error)
UserResolver is callback for resolving InputUser by ID.