You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
691 B

package styling
import (
"github.com/go-faster/errors"
"github.com/gotd/td/telegram/message/entity"
)
type textBuilder struct {
*entity.Builder
}
func (b *textBuilder) Perform(texts ...StyledTextOption) error {
b.GrowEntities(len(texts))
var length int
for i := range texts {
length += texts[i].size
}
b.GrowText(length)
for idx, opt := range texts {
if err := opt.perform(b); err != nil {
return errors.Wrapf(err, "perform %d styling option", idx+2)
}
}
return nil
}
// Perform performs all options to the given builder.
func Perform(builder *entity.Builder, texts ...StyledTextOption) error {
tb := &textBuilder{Builder: builder}
return tb.Perform(texts...)
}