entity

package
v0.33.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 9, 2021 License: MIT Imports: 9 Imported by: 21

Documentation

Overview

Package entity contains message formatting and styling helpers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ComputeLength added in v0.30.0

func ComputeLength(s string) int

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

func HTML(r io.Reader, b *Builder) error

HTML parses given input from reader and adds parsed entities to given builder.

See https://core.telegram.org/bots/api#html-style.

Types

type Builder

type Builder struct {
	// contains filtered or unexported fields
}

Builder builds message string and text entities.

func (*Builder) AddEntities added in v0.30.0

func (b *Builder) AddEntities(e ...tg.MessageEntityClass) *Builder

AddEntities adds given raw entities to the builder. Use carefully.

func (*Builder) BankCard

func (b *Builder) BankCard(s string) *Builder

BankCard formats message as formats message entity. See https://core.telegram.org/constructor/messageEntityBankCard.

func (*Builder) Blockquote

func (b *Builder) Blockquote(s string) *Builder

Blockquote formats message as Blockquote message entity. See https://core.telegram.org/constructor/messageEntityBlockquote.

func (*Builder) Bold

func (b *Builder) Bold(s string) *Builder

Bold formats message as Bold message entity. See https://core.telegram.org/constructor/messageEntityBold.

func (*Builder) BotCommand

func (b *Builder) BotCommand(s string) *Builder

BotCommand formats message as BotCommand message entity. See https://core.telegram.org/constructor/messageEntityBotCommand.

func (*Builder) Cashtag

func (b *Builder) Cashtag(s string) *Builder

Cashtag formats message as Cashtag message entity. See https://core.telegram.org/constructor/messageEntityCashtag.

func (*Builder) Code

func (b *Builder) Code(s string) *Builder

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

func (b *Builder) Email(s string) *Builder

Email formats message as Email message entity. See https://core.telegram.org/constructor/messageEntityEmail.

func (*Builder) Format added in v0.30.0

func (b *Builder) Format(s string, formats ...Formatter) *Builder

Format formats message using given formatters.

func (*Builder) GrowEntities

func (b *Builder) GrowEntities(n int)

GrowEntities grows internal buffer capacity.

func (*Builder) GrowText

func (b *Builder) GrowText(n int)

GrowText grows internal buffer capacity.

func (*Builder) Hashtag

func (b *Builder) Hashtag(s string) *Builder

Hashtag formats message as Hashtag message entity. See https://core.telegram.org/constructor/messageEntityHashtag.

func (*Builder) Italic

func (b *Builder) Italic(s string) *Builder

Italic formats message as Italic message entity. See https://core.telegram.org/constructor/messageEntityItalic.

func (*Builder) Mention

func (b *Builder) Mention(s string) *Builder

Mention formats message as Mention message entity. See https://core.telegram.org/constructor/messageEntityMention.

func (*Builder) MentionName

func (b *Builder) MentionName(s string, userID int) *Builder

MentionName formats message as MentionName message entity. See https://core.telegram.org/constructor/messageEntityMentionName.

func (*Builder) Phone

func (b *Builder) Phone(s string) *Builder

Phone formats message as Phone message entity. See https://core.telegram.org/constructor/messageEntityPhone.

func (*Builder) Plain

func (b *Builder) Plain(s string) *Builder

Plain formats message as plain text.

func (*Builder) Pre

func (b *Builder) Pre(s, lang string) *Builder

Pre formats message as Pre message entity. See https://core.telegram.org/constructor/messageEntityPre.

func (*Builder) Strike

func (b *Builder) Strike(s string) *Builder

Strike formats message as Strike message entity. See https://core.telegram.org/constructor/messageEntityStrike.

func (*Builder) TextURL

func (b *Builder) TextURL(s, url string) *Builder

TextURL formats message as TextUrl message entity. See https://core.telegram.org/constructor/messageEntityTextUrl.

func (*Builder) URL

func (b *Builder) URL(s string) *Builder

URL formats message as Url message entity. See https://core.telegram.org/constructor/messageEntityUrl.

func (*Builder) Underline

func (b *Builder) Underline(s string) *Builder

Underline formats message as Underline message entity. See https://core.telegram.org/constructor/messageEntityUnderline.

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 int) Formatter

MentionName formats message as MentionName message entity. See https://core.telegram.org/constructor/messageEntityMentionName.

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

func Pre(lang string) Formatter

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

func TextURL(url string) Formatter

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL