/
photo.go
52 lines (45 loc) · 1.01 KB
/
photo.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
package inline
import (
"github.com/gotd/td/tg"
)
// PhotoResultBuilder is photo result option builder.
type PhotoResultBuilder struct {
result *tg.InputBotInlineResultPhoto
msg MessageOption
}
func (b *PhotoResultBuilder) apply(r *resultPageBuilder) error {
m, err := b.msg.apply()
if err != nil {
return err
}
t := tg.InputBotInlineResultPhoto{
ID: b.result.ID,
Type: b.result.Type,
Photo: b.result.Photo,
}
if t.ID == "" {
t.ID, err = r.generateID()
if err != nil {
return err
}
}
t.SendMessage = m
r.results = append(r.results, &t)
return nil
}
// ID sets ID of result.
// Should not be empty, so if id is not provided, random will be used.
func (b *PhotoResultBuilder) ID(id string) *PhotoResultBuilder {
b.result.ID = id
return b
}
// Photo creates game result option builder.
func Photo(photo tg.InputPhotoClass, msg MessageOption) *PhotoResultBuilder {
return &PhotoResultBuilder{
result: &tg.InputBotInlineResultPhoto{
Type: PhotoType,
Photo: photo,
},
msg: msg,
}
}