7a04f298d2
- update to latest telegram layer - remove some references to fields in tg.Entities that don't exist in the schema - originally added here: https://github.com/beeper/td/commit/820929062a2ba0104397bc01235ab58a9cff780e - referenced here - https://github.com/mautrix/telegramgo/commit/124f0967ed195b5a380c9bd02e170ada9710dde3 - https://github.com/mautrix/telegramgo/commit/4205047aab2e0639217148b5d125bfaab668bd8e
56 lines
1.7 KiB
Go
56 lines
1.7 KiB
Go
package inline
|
|
|
|
import (
|
|
"go.mau.fi/mautrix-telegram/pkg/gotd/telegram/message/entity"
|
|
"go.mau.fi/mautrix-telegram/pkg/gotd/telegram/message/markup"
|
|
"go.mau.fi/mautrix-telegram/pkg/gotd/telegram/message/styling"
|
|
"go.mau.fi/mautrix-telegram/pkg/gotd/tg"
|
|
)
|
|
|
|
// MessageMediaAutoBuilder is a builder of inline result text message.
|
|
type MessageMediaAutoBuilder struct {
|
|
message *tg.InputBotInlineMessageMediaAuto
|
|
options []styling.StyledTextOption
|
|
}
|
|
|
|
func (b *MessageMediaAutoBuilder) apply() (tg.InputBotInlineMessageClass, error) {
|
|
tb := entity.Builder{}
|
|
if err := styling.Perform(&tb, b.options...); err != nil {
|
|
return nil, err
|
|
}
|
|
msg, entities := tb.Complete()
|
|
r := *b.message
|
|
|
|
r.Message = msg
|
|
r.Entities = entities
|
|
return &r, nil
|
|
}
|
|
|
|
// MediaAuto creates new message text option builder.
|
|
func MediaAuto(msg string) *MessageMediaAutoBuilder {
|
|
return MediaAutoStyled(styling.Plain(msg))
|
|
}
|
|
|
|
// MediaAutoStyled creates new message text option builder.
|
|
func MediaAutoStyled(texts ...styling.StyledTextOption) *MessageMediaAutoBuilder {
|
|
return &MessageMediaAutoBuilder{
|
|
message: &tg.InputBotInlineMessageMediaAuto{},
|
|
options: texts,
|
|
}
|
|
}
|
|
|
|
// Markup sets reply markup for sending bot buttons.
|
|
// NB: markup will not be used, if you send multiple media attachments.
|
|
func (b *MessageMediaAutoBuilder) Markup(m tg.ReplyMarkupClass) *MessageMediaAutoBuilder {
|
|
b.message.ReplyMarkup = m
|
|
return b
|
|
}
|
|
|
|
// Row sets single row keyboard markup for sending bot buttons.
|
|
// NB: markup will not be used, if you send multiple media attachments.
|
|
func (b *MessageMediaAutoBuilder) Row(
|
|
buttons ...tg.KeyboardButtonClass,
|
|
) *MessageMediaAutoBuilder {
|
|
return b.Markup(markup.InlineRow(buttons...))
|
|
}
|