-
-
Notifications
You must be signed in to change notification settings - Fork 135
/
stickers.go
69 lines (58 loc) · 1.93 KB
/
stickers.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package message
import (
"context"
"github.com/gotd/td/tg"
)
// UploadedSticker creates new UploadedStickerBuilder to create sticker attachment.
func (u *UploadedDocumentBuilder) UploadedSticker() *UploadedStickerBuilder {
b := u
if u.doc.MimeType == "" {
b = u.MIME(DefaultStickerMIME)
}
return &UploadedStickerBuilder{
doc: b,
attr: tg.DocumentAttributeSticker{
Stickerset: &tg.InputStickerSetEmpty{},
},
}
}
// UploadedSticker adds uploaded sticker attachment.
func UploadedSticker(file tg.InputFileClass, caption ...StyledTextOption) *UploadedStickerBuilder {
return UploadedDocument(file, caption...).UploadedSticker()
}
// UploadedStickerBuilder is a uploaded sticker media option.
type UploadedStickerBuilder struct {
doc *UploadedDocumentBuilder
attr tg.DocumentAttributeSticker
}
// Mask sets flag that is a mask sticker.
func (u *UploadedStickerBuilder) Mask(mask bool) *UploadedStickerBuilder {
u.attr.Mask = mask
return u
}
// Alt sets alternative emoji representation of sticker.
func (u *UploadedStickerBuilder) Alt(alt string) *UploadedStickerBuilder {
u.attr.Alt = alt
return u
}
// StickerSet sets associated sticker set.
func (u *UploadedStickerBuilder) StickerSet(stickerSet tg.InputStickerSetClass) *UploadedStickerBuilder {
u.attr.Stickerset = stickerSet
return u
}
// MaskCoords sets mask coordinates (if this is a mask sticker, attached to a photo).
func (u *UploadedStickerBuilder) MaskCoords(maskCoords tg.MaskCoords) *UploadedStickerBuilder {
u.attr.MaskCoords = maskCoords
return u
}
// apply implements MediaOption.
func (u *UploadedStickerBuilder) apply(ctx context.Context, b *multiMediaBuilder) error {
return u.doc.Attributes(&u.attr).apply(ctx, b)
}
// UploadedSticker sends uploaded file as sticker.
func (b *Builder) UploadedSticker(
ctx context.Context,
file tg.InputFileClass, caption ...StyledTextOption,
) (tg.UpdatesClass, error) {
return b.Media(ctx, UploadedSticker(file, caption...))
}