-
-
Notifications
You must be signed in to change notification settings - Fork 128
/
message_auto_media.go
55 lines (47 loc) · 1.59 KB
/
message_auto_media.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package inline
import (
"github.com/gotd/td/telegram/message/entity"
"github.com/gotd/td/telegram/message/markup"
"github.com/gotd/td/telegram/message/styling"
"github.com/gotd/td/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...))
}