Documentation ¶
Overview ¶
Package entity contains message formatting and styling helpers.
Index ¶
- func ComputeLength(s string) int
- func HTML(r io.Reader, b *Builder, ...) error
- 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) Email(s string) *Builder
- 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) 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, lang string) *Builder
- func (b *Builder) Strike(s string) *Builder
- func (b *Builder) TextURL(s, url string) *Builder
- func (b *Builder) URL(s string) *Builder
- func (b *Builder) Underline(s string) *Builder
- type Formatter
- func BankCard() Formatter
- func Blockquote() Formatter
- func Bold() Formatter
- func BotCommand() Formatter
- func Cashtag() Formatter
- func Code() Formatter
- func Email() Formatter
- func Hashtag() Formatter
- func Italic() Formatter
- func Mention() Formatter
- func MentionName(userID tg.InputUserClass) Formatter
- func Phone() Formatter
- func Pre(lang string) Formatter
- func Strike() Formatter
- func TextURL(url string) Formatter
- func URL() Formatter
- func Underline() Formatter
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 HTML ¶ added in v0.30.0
HTML parses given input from reader and adds parsed entities to given builder. Notice that this parser ignores unsupported tags.
Parameter userResolver is used to resolve user by ID during formatting. May be nil. If userResolver is nil, formatter will create tg.InputUser using only ID. Notice that it's okay for bots, but not for users.
Types ¶
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
Builder builds message string and text entities.
func (*Builder) BankCard ¶
BankCard formats message as formats message entity. See https://core.telegram.org/constructor/messageEntityBankCard.
func (*Builder) Blockquote ¶
Blockquote formats message as Blockquote message entity. See https://core.telegram.org/constructor/messageEntityBlockquote.
func (*Builder) Bold ¶
Bold formats message as Bold message entity. See https://core.telegram.org/constructor/messageEntityBold.
func (*Builder) BotCommand ¶
BotCommand formats message as BotCommand message entity. See https://core.telegram.org/constructor/messageEntityBotCommand.
func (*Builder) Cashtag ¶
Cashtag formats message as Cashtag message entity. See https://core.telegram.org/constructor/messageEntityCashtag.
func (*Builder) Code ¶
Code 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) Email ¶
Email formats message as Email message entity. See https://core.telegram.org/constructor/messageEntityEmail.
func (*Builder) GrowEntities ¶
GrowEntities grows internal buffer capacity.
func (*Builder) Hashtag ¶
Hashtag formats message as Hashtag message entity. See https://core.telegram.org/constructor/messageEntityHashtag.
func (*Builder) Italic ¶
Italic formats message as Italic message entity. See https://core.telegram.org/constructor/messageEntityItalic.
func (*Builder) Mention ¶
Mention 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 formats message as MentionName message entity. See https://core.telegram.org/constructor/inputMessageEntityMentionName.
func (*Builder) Phone ¶
Phone formats message as Phone message entity. See https://core.telegram.org/constructor/messageEntityPhone.
func (*Builder) Pre ¶
Pre formats message as Pre message entity. See https://core.telegram.org/constructor/messageEntityPre.
func (*Builder) Strike ¶
Strike formats message as Strike message entity. See https://core.telegram.org/constructor/messageEntityStrike.
func (*Builder) TextURL ¶
TextURL formats message as TextUrl message entity. See https://core.telegram.org/constructor/messageEntityTextUrl.
func (*Builder) URL ¶
URL formats message as Url message entity. See https://core.telegram.org/constructor/messageEntityUrl.
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 formats message as formats message entity. See https://core.telegram.org/constructor/messageEntityBankCard.
func Blockquote ¶ added in v0.30.0
func Blockquote() Formatter
Blockquote formats message as Blockquote message entity. See https://core.telegram.org/constructor/messageEntityBlockquote.
func Bold ¶ added in v0.30.0
func Bold() Formatter
Bold formats message as Bold message entity. See https://core.telegram.org/constructor/messageEntityBold.
func BotCommand ¶ added in v0.30.0
func BotCommand() Formatter
BotCommand formats message as BotCommand message entity. See https://core.telegram.org/constructor/messageEntityBotCommand.
func Cashtag ¶ added in v0.30.0
func Cashtag() Formatter
Cashtag formats message as Cashtag message entity. See https://core.telegram.org/constructor/messageEntityCashtag.
func Code ¶ added in v0.30.0
func Code() Formatter
Code formats message as Code message entity. See https://core.telegram.org/constructor/messageEntityCode.
func Email ¶ added in v0.30.0
func Email() Formatter
Email formats message as Email message entity. See https://core.telegram.org/constructor/messageEntityEmail.
func Hashtag ¶ added in v0.30.0
func Hashtag() Formatter
Hashtag formats message as Hashtag message entity. See https://core.telegram.org/constructor/messageEntityHashtag.
func Italic ¶ added in v0.30.0
func Italic() Formatter
Italic formats message as Italic message entity. See https://core.telegram.org/constructor/messageEntityItalic.
func Mention ¶ added in v0.30.0
func Mention() Formatter
Mention formats message as Mention message entity. See https://core.telegram.org/constructor/messageEntityMention.
func MentionName ¶ added in v0.30.0
func MentionName(userID tg.InputUserClass) Formatter
MentionName formats message as MentionName message entity. See https://core.telegram.org/constructor/inputMessageEntityMentionName.
func Phone ¶ added in v0.30.0
func Phone() Formatter
Phone formats message as Phone message entity. See https://core.telegram.org/constructor/messageEntityPhone.
func Pre ¶ added in v0.30.0
Pre formats message as Pre message entity. See https://core.telegram.org/constructor/messageEntityPre.
func Strike ¶ added in v0.30.0
func Strike() Formatter
Strike formats message as Strike message entity. See https://core.telegram.org/constructor/messageEntityStrike.
func TextURL ¶ added in v0.30.0
TextURL formats message as TextUrl message entity. See https://core.telegram.org/constructor/messageEntityTextUrl.
func URL ¶ added in v0.30.0
func URL() Formatter
URL formats message as Url message entity. See https://core.telegram.org/constructor/messageEntityUrl.
func Underline ¶ added in v0.30.0
func Underline() Formatter
Underline formats message as Underline message entity. See https://core.telegram.org/constructor/messageEntityUnderline.