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 ¶ added in v0.30.0
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 ¶ added in v0.54.0
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 ¶ added in v0.54.0
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 ¶ added in v0.63.0
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 ¶ added in v0.54.0
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 ¶ added in v0.54.0
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 ¶ added in v0.54.0
func (b *Builder) Raw() (string, []tg.MessageEntityClass)
Raw returns raw result and resets builder without fixing spaces.
func (*Builder) Reset ¶ added in v0.54.0
func (b *Builder) Reset()
Reset resets the Builder to be empty.
func (*Builder) ShrinkPreCode ¶ added in v0.54.0
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 ¶ added in v0.54.0
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 ¶ added in v0.54.0
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 ¶ added in v0.54.0
Unknown adds and formats message as Unknown message entity.
See https://core.telegram.org/constructor/messageEntityUnknown.
type Formatter ¶ added in v0.30.0
type Formatter func(offset, limit int) tg.MessageEntityClass
Formatter is a message entity constructor.
func BankCard ¶ added in v0.30.0
func BankCard() Formatter
BankCard creates Formatter of BankCard message entity.
See https://core.telegram.org/constructor/messageEntityBankCard.
func Blockquote ¶ added in v0.30.0
func Blockquote() Formatter
Blockquote creates Formatter of Blockquote message entity.
See https://core.telegram.org/constructor/messageEntityBlockquote.
func Bold ¶ added in v0.30.0
func Bold() Formatter
Bold creates Formatter of Bold message entity.
See https://core.telegram.org/constructor/messageEntityBold.
func BotCommand ¶ added in v0.30.0
func BotCommand() Formatter
BotCommand creates Formatter of BotCommand message entity.
See https://core.telegram.org/constructor/messageEntityBotCommand.
func Cashtag ¶ added in v0.30.0
func Cashtag() Formatter
Cashtag creates Formatter of Cashtag message entity.
See https://core.telegram.org/constructor/messageEntityCashtag.
func Code ¶ added in v0.30.0
func Code() Formatter
Code creates Formatter of Code message entity.
See https://core.telegram.org/constructor/messageEntityCode.
func CustomEmoji ¶ added in v0.63.0
CustomEmoji creates Formatter of CustomEmoji message entity.
See https://core.telegram.org/constructor/messageEntityCustomEmoji.
func Email ¶ added in v0.30.0
func Email() Formatter
Email creates Formatter of Email message entity.
See https://core.telegram.org/constructor/messageEntityEmail.
func Hashtag ¶ added in v0.30.0
func Hashtag() Formatter
Hashtag creates Formatter of Hashtag message entity.
See https://core.telegram.org/constructor/messageEntityHashtag.
func Italic ¶ added in v0.30.0
func Italic() Formatter
Italic creates Formatter of Italic message entity.
See https://core.telegram.org/constructor/messageEntityItalic.
func Mention ¶ added in v0.30.0
func Mention() Formatter
Mention creates Formatter of Mention message entity.
See https://core.telegram.org/constructor/messageEntityMention.
func MentionName ¶ added in v0.30.0
func MentionName(userID tg.InputUserClass) Formatter
MentionName creates Formatter of MentionName message entity.
See https://core.telegram.org/constructor/inputMessageEntityMentionName.
func Phone ¶ added in v0.30.0
func Phone() Formatter
Phone creates Formatter of Phone message entity.
See https://core.telegram.org/constructor/messageEntityPhone.
func Spoiler ¶ added in v0.54.0
func Spoiler() Formatter
Spoiler creates Formatter of Spoiler message entity.
See https://core.telegram.org/constructor/messageEntitySpoiler.
func Strike ¶ added in v0.30.0
func Strike() Formatter
Strike creates Formatter of Strike message entity.
See https://core.telegram.org/constructor/messageEntityStrike.
func TextURL ¶ added in v0.30.0
TextURL creates Formatter of TextURL message entity.
See https://core.telegram.org/constructor/messageEntityTextUrl.
func Underline ¶ added in v0.30.0
func Underline() Formatter
Underline creates Formatter of Underline message entity.
See https://core.telegram.org/constructor/messageEntityUnderline.
func Unknown ¶ added in v0.54.0
func Unknown() Formatter
Unknown creates Formatter of Unknown message entity.
See https://core.telegram.org/constructor/messageEntityUnknown.
type Token ¶ added in v0.54.0
type Token struct {
// contains filtered or unexported fields
}
Token represents raw point in a message string.
func (Token) Apply ¶ added in v0.54.0
Apply formats range between token start and current state using given Formatter slice.
func (Token) UTF16Length ¶ added in v0.54.0
UTF16Length returns UTF-16 length between token start and current state.
func (Token) UTF16Offset ¶ added in v0.54.0
UTF16Offset returns UTF-16 offset.
func (Token) UTF8Length ¶ added in v0.54.0
UTF8Length return UTF-8 length between token start and current state.
func (Token) UTF8Offset ¶ added in v0.54.0
UTF8Offset return UTF-8 offset.
type UserResolver ¶ added in v0.54.0
type UserResolver = func(id int64) (tg.InputUserClass, error)
UserResolver is callback for resolving InputUser by ID.