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
70 lines
1.9 KiB
Go
70 lines
1.9 KiB
Go
package message
|
|
|
|
import (
|
|
"context"
|
|
|
|
"go.mau.fi/mautrix-telegram/pkg/gotd/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...))
|
|
}
|