Files
mautrix-telegram/pkg/gotd/tg/tl_input_media_gen.go
T
2025-06-27 20:03:37 -07:00

5290 lines
130 KiB
Go

// Code generated by gotdgen, DO NOT EDIT.
package tg
import (
"context"
"errors"
"fmt"
"sort"
"strings"
"go.uber.org/multierr"
"go.mau.fi/mautrix-telegram/pkg/gotd/bin"
"go.mau.fi/mautrix-telegram/pkg/gotd/tdjson"
"go.mau.fi/mautrix-telegram/pkg/gotd/tdp"
"go.mau.fi/mautrix-telegram/pkg/gotd/tgerr"
)
// No-op definition for keeping imports.
var (
_ = bin.Buffer{}
_ = context.Background()
_ = fmt.Stringer(nil)
_ = strings.Builder{}
_ = errors.Is
_ = multierr.AppendInto
_ = sort.Ints
_ = tdp.Format
_ = tgerr.Error{}
_ = tdjson.Encoder{}
)
// InputMediaEmpty represents TL type `inputMediaEmpty#9664f57f`.
// Empty media content of a message.
//
// See https://core.telegram.org/constructor/inputMediaEmpty for reference.
type InputMediaEmpty struct {
}
// InputMediaEmptyTypeID is TL type id of InputMediaEmpty.
const InputMediaEmptyTypeID = 0x9664f57f
// construct implements constructor of InputMediaClass.
func (i InputMediaEmpty) construct() InputMediaClass { return &i }
// Ensuring interfaces in compile-time for InputMediaEmpty.
var (
_ bin.Encoder = &InputMediaEmpty{}
_ bin.Decoder = &InputMediaEmpty{}
_ bin.BareEncoder = &InputMediaEmpty{}
_ bin.BareDecoder = &InputMediaEmpty{}
_ InputMediaClass = &InputMediaEmpty{}
)
func (i *InputMediaEmpty) Zero() bool {
if i == nil {
return true
}
return true
}
// String implements fmt.Stringer.
func (i *InputMediaEmpty) String() string {
if i == nil {
return "InputMediaEmpty(nil)"
}
type Alias InputMediaEmpty
return fmt.Sprintf("InputMediaEmpty%+v", Alias(*i))
}
// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*InputMediaEmpty) TypeID() uint32 {
return InputMediaEmptyTypeID
}
// TypeName returns name of type in TL schema.
func (*InputMediaEmpty) TypeName() string {
return "inputMediaEmpty"
}
// TypeInfo returns info about TL type.
func (i *InputMediaEmpty) TypeInfo() tdp.Type {
typ := tdp.Type{
Name: "inputMediaEmpty",
ID: InputMediaEmptyTypeID,
}
if i == nil {
typ.Null = true
return typ
}
typ.Fields = []tdp.Field{}
return typ
}
// Encode implements bin.Encoder.
func (i *InputMediaEmpty) Encode(b *bin.Buffer) error {
if i == nil {
return fmt.Errorf("can't encode inputMediaEmpty#9664f57f as nil")
}
b.PutID(InputMediaEmptyTypeID)
return i.EncodeBare(b)
}
// EncodeBare implements bin.BareEncoder.
func (i *InputMediaEmpty) EncodeBare(b *bin.Buffer) error {
if i == nil {
return fmt.Errorf("can't encode inputMediaEmpty#9664f57f as nil")
}
return nil
}
// Decode implements bin.Decoder.
func (i *InputMediaEmpty) Decode(b *bin.Buffer) error {
if i == nil {
return fmt.Errorf("can't decode inputMediaEmpty#9664f57f to nil")
}
if err := b.ConsumeID(InputMediaEmptyTypeID); err != nil {
return fmt.Errorf("unable to decode inputMediaEmpty#9664f57f: %w", err)
}
return i.DecodeBare(b)
}
// DecodeBare implements bin.BareDecoder.
func (i *InputMediaEmpty) DecodeBare(b *bin.Buffer) error {
if i == nil {
return fmt.Errorf("can't decode inputMediaEmpty#9664f57f to nil")
}
return nil
}
// InputMediaUploadedPhoto represents TL type `inputMediaUploadedPhoto#1e287d04`.
// Photo
//
// See https://core.telegram.org/constructor/inputMediaUploadedPhoto for reference.
type InputMediaUploadedPhoto struct {
// Flags, see TL conditional fields¹
//
// Links:
// 1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
Flags bin.Fields
// Whether this media should be hidden behind a spoiler warning
Spoiler bool
// The uploaded file¹
//
// Links:
// 1) https://core.telegram.org/api/files
File InputFileClass
// Attached mask stickers
//
// Use SetStickers and GetStickers helpers.
Stickers []InputDocumentClass
// Time to live in seconds of self-destructing photo
//
// Use SetTTLSeconds and GetTTLSeconds helpers.
TTLSeconds int
}
// InputMediaUploadedPhotoTypeID is TL type id of InputMediaUploadedPhoto.
const InputMediaUploadedPhotoTypeID = 0x1e287d04
// construct implements constructor of InputMediaClass.
func (i InputMediaUploadedPhoto) construct() InputMediaClass { return &i }
// Ensuring interfaces in compile-time for InputMediaUploadedPhoto.
var (
_ bin.Encoder = &InputMediaUploadedPhoto{}
_ bin.Decoder = &InputMediaUploadedPhoto{}
_ bin.BareEncoder = &InputMediaUploadedPhoto{}
_ bin.BareDecoder = &InputMediaUploadedPhoto{}
_ InputMediaClass = &InputMediaUploadedPhoto{}
)
func (i *InputMediaUploadedPhoto) Zero() bool {
if i == nil {
return true
}
if !(i.Flags.Zero()) {
return false
}
if !(i.Spoiler == false) {
return false
}
if !(i.File == nil) {
return false
}
if !(i.Stickers == nil) {
return false
}
if !(i.TTLSeconds == 0) {
return false
}
return true
}
// String implements fmt.Stringer.
func (i *InputMediaUploadedPhoto) String() string {
if i == nil {
return "InputMediaUploadedPhoto(nil)"
}
type Alias InputMediaUploadedPhoto
return fmt.Sprintf("InputMediaUploadedPhoto%+v", Alias(*i))
}
// FillFrom fills InputMediaUploadedPhoto from given interface.
func (i *InputMediaUploadedPhoto) FillFrom(from interface {
GetSpoiler() (value bool)
GetFile() (value InputFileClass)
GetStickers() (value []InputDocumentClass, ok bool)
GetTTLSeconds() (value int, ok bool)
}) {
i.Spoiler = from.GetSpoiler()
i.File = from.GetFile()
if val, ok := from.GetStickers(); ok {
i.Stickers = val
}
if val, ok := from.GetTTLSeconds(); ok {
i.TTLSeconds = val
}
}
// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*InputMediaUploadedPhoto) TypeID() uint32 {
return InputMediaUploadedPhotoTypeID
}
// TypeName returns name of type in TL schema.
func (*InputMediaUploadedPhoto) TypeName() string {
return "inputMediaUploadedPhoto"
}
// TypeInfo returns info about TL type.
func (i *InputMediaUploadedPhoto) TypeInfo() tdp.Type {
typ := tdp.Type{
Name: "inputMediaUploadedPhoto",
ID: InputMediaUploadedPhotoTypeID,
}
if i == nil {
typ.Null = true
return typ
}
typ.Fields = []tdp.Field{
{
Name: "Spoiler",
SchemaName: "spoiler",
Null: !i.Flags.Has(2),
},
{
Name: "File",
SchemaName: "file",
},
{
Name: "Stickers",
SchemaName: "stickers",
Null: !i.Flags.Has(0),
},
{
Name: "TTLSeconds",
SchemaName: "ttl_seconds",
Null: !i.Flags.Has(1),
},
}
return typ
}
// SetFlags sets flags for non-zero fields.
func (i *InputMediaUploadedPhoto) SetFlags() {
if !(i.Spoiler == false) {
i.Flags.Set(2)
}
if !(i.Stickers == nil) {
i.Flags.Set(0)
}
if !(i.TTLSeconds == 0) {
i.Flags.Set(1)
}
}
// Encode implements bin.Encoder.
func (i *InputMediaUploadedPhoto) Encode(b *bin.Buffer) error {
if i == nil {
return fmt.Errorf("can't encode inputMediaUploadedPhoto#1e287d04 as nil")
}
b.PutID(InputMediaUploadedPhotoTypeID)
return i.EncodeBare(b)
}
// EncodeBare implements bin.BareEncoder.
func (i *InputMediaUploadedPhoto) EncodeBare(b *bin.Buffer) error {
if i == nil {
return fmt.Errorf("can't encode inputMediaUploadedPhoto#1e287d04 as nil")
}
i.SetFlags()
if err := i.Flags.Encode(b); err != nil {
return fmt.Errorf("unable to encode inputMediaUploadedPhoto#1e287d04: field flags: %w", err)
}
if i.File == nil {
return fmt.Errorf("unable to encode inputMediaUploadedPhoto#1e287d04: field file is nil")
}
if err := i.File.Encode(b); err != nil {
return fmt.Errorf("unable to encode inputMediaUploadedPhoto#1e287d04: field file: %w", err)
}
if i.Flags.Has(0) {
b.PutVectorHeader(len(i.Stickers))
for idx, v := range i.Stickers {
if v == nil {
return fmt.Errorf("unable to encode inputMediaUploadedPhoto#1e287d04: field stickers element with index %d is nil", idx)
}
if err := v.Encode(b); err != nil {
return fmt.Errorf("unable to encode inputMediaUploadedPhoto#1e287d04: field stickers element with index %d: %w", idx, err)
}
}
}
if i.Flags.Has(1) {
b.PutInt(i.TTLSeconds)
}
return nil
}
// Decode implements bin.Decoder.
func (i *InputMediaUploadedPhoto) Decode(b *bin.Buffer) error {
if i == nil {
return fmt.Errorf("can't decode inputMediaUploadedPhoto#1e287d04 to nil")
}
if err := b.ConsumeID(InputMediaUploadedPhotoTypeID); err != nil {
return fmt.Errorf("unable to decode inputMediaUploadedPhoto#1e287d04: %w", err)
}
return i.DecodeBare(b)
}
// DecodeBare implements bin.BareDecoder.
func (i *InputMediaUploadedPhoto) DecodeBare(b *bin.Buffer) error {
if i == nil {
return fmt.Errorf("can't decode inputMediaUploadedPhoto#1e287d04 to nil")
}
{
if err := i.Flags.Decode(b); err != nil {
return fmt.Errorf("unable to decode inputMediaUploadedPhoto#1e287d04: field flags: %w", err)
}
}
i.Spoiler = i.Flags.Has(2)
{
value, err := DecodeInputFile(b)
if err != nil {
return fmt.Errorf("unable to decode inputMediaUploadedPhoto#1e287d04: field file: %w", err)
}
i.File = value
}
if i.Flags.Has(0) {
headerLen, err := b.VectorHeader()
if err != nil {
return fmt.Errorf("unable to decode inputMediaUploadedPhoto#1e287d04: field stickers: %w", err)
}
if headerLen > 0 {
i.Stickers = make([]InputDocumentClass, 0, headerLen%bin.PreallocateLimit)
}
for idx := 0; idx < headerLen; idx++ {
value, err := DecodeInputDocument(b)
if err != nil {
return fmt.Errorf("unable to decode inputMediaUploadedPhoto#1e287d04: field stickers: %w", err)
}
i.Stickers = append(i.Stickers, value)
}
}
if i.Flags.Has(1) {
value, err := b.Int()
if err != nil {
return fmt.Errorf("unable to decode inputMediaUploadedPhoto#1e287d04: field ttl_seconds: %w", err)
}
i.TTLSeconds = value
}
return nil
}
// SetSpoiler sets value of Spoiler conditional field.
func (i *InputMediaUploadedPhoto) SetSpoiler(value bool) {
if value {
i.Flags.Set(2)
i.Spoiler = true
} else {
i.Flags.Unset(2)
i.Spoiler = false
}
}
// GetSpoiler returns value of Spoiler conditional field.
func (i *InputMediaUploadedPhoto) GetSpoiler() (value bool) {
if i == nil {
return
}
return i.Flags.Has(2)
}
// GetFile returns value of File field.
func (i *InputMediaUploadedPhoto) GetFile() (value InputFileClass) {
if i == nil {
return
}
return i.File
}
// SetStickers sets value of Stickers conditional field.
func (i *InputMediaUploadedPhoto) SetStickers(value []InputDocumentClass) {
i.Flags.Set(0)
i.Stickers = value
}
// GetStickers returns value of Stickers conditional field and
// boolean which is true if field was set.
func (i *InputMediaUploadedPhoto) GetStickers() (value []InputDocumentClass, ok bool) {
if i == nil {
return
}
if !i.Flags.Has(0) {
return value, false
}
return i.Stickers, true
}
// SetTTLSeconds sets value of TTLSeconds conditional field.
func (i *InputMediaUploadedPhoto) SetTTLSeconds(value int) {
i.Flags.Set(1)
i.TTLSeconds = value
}
// GetTTLSeconds returns value of TTLSeconds conditional field and
// boolean which is true if field was set.
func (i *InputMediaUploadedPhoto) GetTTLSeconds() (value int, ok bool) {
if i == nil {
return
}
if !i.Flags.Has(1) {
return value, false
}
return i.TTLSeconds, true
}
// MapStickers returns field Stickers wrapped in InputDocumentClassArray helper.
func (i *InputMediaUploadedPhoto) MapStickers() (value InputDocumentClassArray, ok bool) {
if !i.Flags.Has(0) {
return value, false
}
return InputDocumentClassArray(i.Stickers), true
}
// InputMediaPhoto represents TL type `inputMediaPhoto#b3ba0635`.
// Forwarded photo
//
// See https://core.telegram.org/constructor/inputMediaPhoto for reference.
type InputMediaPhoto struct {
// Flags, see TL conditional fields¹
//
// Links:
// 1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
Flags bin.Fields
// Whether this media should be hidden behind a spoiler warning
Spoiler bool
// Photo to be forwarded
ID InputPhotoClass
// Time to live in seconds of self-destructing photo
//
// Use SetTTLSeconds and GetTTLSeconds helpers.
TTLSeconds int
}
// InputMediaPhotoTypeID is TL type id of InputMediaPhoto.
const InputMediaPhotoTypeID = 0xb3ba0635
// construct implements constructor of InputMediaClass.
func (i InputMediaPhoto) construct() InputMediaClass { return &i }
// Ensuring interfaces in compile-time for InputMediaPhoto.
var (
_ bin.Encoder = &InputMediaPhoto{}
_ bin.Decoder = &InputMediaPhoto{}
_ bin.BareEncoder = &InputMediaPhoto{}
_ bin.BareDecoder = &InputMediaPhoto{}
_ InputMediaClass = &InputMediaPhoto{}
)
func (i *InputMediaPhoto) Zero() bool {
if i == nil {
return true
}
if !(i.Flags.Zero()) {
return false
}
if !(i.Spoiler == false) {
return false
}
if !(i.ID == nil) {
return false
}
if !(i.TTLSeconds == 0) {
return false
}
return true
}
// String implements fmt.Stringer.
func (i *InputMediaPhoto) String() string {
if i == nil {
return "InputMediaPhoto(nil)"
}
type Alias InputMediaPhoto
return fmt.Sprintf("InputMediaPhoto%+v", Alias(*i))
}
// FillFrom fills InputMediaPhoto from given interface.
func (i *InputMediaPhoto) FillFrom(from interface {
GetSpoiler() (value bool)
GetID() (value InputPhotoClass)
GetTTLSeconds() (value int, ok bool)
}) {
i.Spoiler = from.GetSpoiler()
i.ID = from.GetID()
if val, ok := from.GetTTLSeconds(); ok {
i.TTLSeconds = val
}
}
// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*InputMediaPhoto) TypeID() uint32 {
return InputMediaPhotoTypeID
}
// TypeName returns name of type in TL schema.
func (*InputMediaPhoto) TypeName() string {
return "inputMediaPhoto"
}
// TypeInfo returns info about TL type.
func (i *InputMediaPhoto) TypeInfo() tdp.Type {
typ := tdp.Type{
Name: "inputMediaPhoto",
ID: InputMediaPhotoTypeID,
}
if i == nil {
typ.Null = true
return typ
}
typ.Fields = []tdp.Field{
{
Name: "Spoiler",
SchemaName: "spoiler",
Null: !i.Flags.Has(1),
},
{
Name: "ID",
SchemaName: "id",
},
{
Name: "TTLSeconds",
SchemaName: "ttl_seconds",
Null: !i.Flags.Has(0),
},
}
return typ
}
// SetFlags sets flags for non-zero fields.
func (i *InputMediaPhoto) SetFlags() {
if !(i.Spoiler == false) {
i.Flags.Set(1)
}
if !(i.TTLSeconds == 0) {
i.Flags.Set(0)
}
}
// Encode implements bin.Encoder.
func (i *InputMediaPhoto) Encode(b *bin.Buffer) error {
if i == nil {
return fmt.Errorf("can't encode inputMediaPhoto#b3ba0635 as nil")
}
b.PutID(InputMediaPhotoTypeID)
return i.EncodeBare(b)
}
// EncodeBare implements bin.BareEncoder.
func (i *InputMediaPhoto) EncodeBare(b *bin.Buffer) error {
if i == nil {
return fmt.Errorf("can't encode inputMediaPhoto#b3ba0635 as nil")
}
i.SetFlags()
if err := i.Flags.Encode(b); err != nil {
return fmt.Errorf("unable to encode inputMediaPhoto#b3ba0635: field flags: %w", err)
}
if i.ID == nil {
return fmt.Errorf("unable to encode inputMediaPhoto#b3ba0635: field id is nil")
}
if err := i.ID.Encode(b); err != nil {
return fmt.Errorf("unable to encode inputMediaPhoto#b3ba0635: field id: %w", err)
}
if i.Flags.Has(0) {
b.PutInt(i.TTLSeconds)
}
return nil
}
// Decode implements bin.Decoder.
func (i *InputMediaPhoto) Decode(b *bin.Buffer) error {
if i == nil {
return fmt.Errorf("can't decode inputMediaPhoto#b3ba0635 to nil")
}
if err := b.ConsumeID(InputMediaPhotoTypeID); err != nil {
return fmt.Errorf("unable to decode inputMediaPhoto#b3ba0635: %w", err)
}
return i.DecodeBare(b)
}
// DecodeBare implements bin.BareDecoder.
func (i *InputMediaPhoto) DecodeBare(b *bin.Buffer) error {
if i == nil {
return fmt.Errorf("can't decode inputMediaPhoto#b3ba0635 to nil")
}
{
if err := i.Flags.Decode(b); err != nil {
return fmt.Errorf("unable to decode inputMediaPhoto#b3ba0635: field flags: %w", err)
}
}
i.Spoiler = i.Flags.Has(1)
{
value, err := DecodeInputPhoto(b)
if err != nil {
return fmt.Errorf("unable to decode inputMediaPhoto#b3ba0635: field id: %w", err)
}
i.ID = value
}
if i.Flags.Has(0) {
value, err := b.Int()
if err != nil {
return fmt.Errorf("unable to decode inputMediaPhoto#b3ba0635: field ttl_seconds: %w", err)
}
i.TTLSeconds = value
}
return nil
}
// SetSpoiler sets value of Spoiler conditional field.
func (i *InputMediaPhoto) SetSpoiler(value bool) {
if value {
i.Flags.Set(1)
i.Spoiler = true
} else {
i.Flags.Unset(1)
i.Spoiler = false
}
}
// GetSpoiler returns value of Spoiler conditional field.
func (i *InputMediaPhoto) GetSpoiler() (value bool) {
if i == nil {
return
}
return i.Flags.Has(1)
}
// GetID returns value of ID field.
func (i *InputMediaPhoto) GetID() (value InputPhotoClass) {
if i == nil {
return
}
return i.ID
}
// SetTTLSeconds sets value of TTLSeconds conditional field.
func (i *InputMediaPhoto) SetTTLSeconds(value int) {
i.Flags.Set(0)
i.TTLSeconds = value
}
// GetTTLSeconds returns value of TTLSeconds conditional field and
// boolean which is true if field was set.
func (i *InputMediaPhoto) GetTTLSeconds() (value int, ok bool) {
if i == nil {
return
}
if !i.Flags.Has(0) {
return value, false
}
return i.TTLSeconds, true
}
// InputMediaGeoPoint represents TL type `inputMediaGeoPoint#f9c44144`.
// Map.
//
// See https://core.telegram.org/constructor/inputMediaGeoPoint for reference.
type InputMediaGeoPoint struct {
// GeoPoint
GeoPoint InputGeoPointClass
}
// InputMediaGeoPointTypeID is TL type id of InputMediaGeoPoint.
const InputMediaGeoPointTypeID = 0xf9c44144
// construct implements constructor of InputMediaClass.
func (i InputMediaGeoPoint) construct() InputMediaClass { return &i }
// Ensuring interfaces in compile-time for InputMediaGeoPoint.
var (
_ bin.Encoder = &InputMediaGeoPoint{}
_ bin.Decoder = &InputMediaGeoPoint{}
_ bin.BareEncoder = &InputMediaGeoPoint{}
_ bin.BareDecoder = &InputMediaGeoPoint{}
_ InputMediaClass = &InputMediaGeoPoint{}
)
func (i *InputMediaGeoPoint) Zero() bool {
if i == nil {
return true
}
if !(i.GeoPoint == nil) {
return false
}
return true
}
// String implements fmt.Stringer.
func (i *InputMediaGeoPoint) String() string {
if i == nil {
return "InputMediaGeoPoint(nil)"
}
type Alias InputMediaGeoPoint
return fmt.Sprintf("InputMediaGeoPoint%+v", Alias(*i))
}
// FillFrom fills InputMediaGeoPoint from given interface.
func (i *InputMediaGeoPoint) FillFrom(from interface {
GetGeoPoint() (value InputGeoPointClass)
}) {
i.GeoPoint = from.GetGeoPoint()
}
// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*InputMediaGeoPoint) TypeID() uint32 {
return InputMediaGeoPointTypeID
}
// TypeName returns name of type in TL schema.
func (*InputMediaGeoPoint) TypeName() string {
return "inputMediaGeoPoint"
}
// TypeInfo returns info about TL type.
func (i *InputMediaGeoPoint) TypeInfo() tdp.Type {
typ := tdp.Type{
Name: "inputMediaGeoPoint",
ID: InputMediaGeoPointTypeID,
}
if i == nil {
typ.Null = true
return typ
}
typ.Fields = []tdp.Field{
{
Name: "GeoPoint",
SchemaName: "geo_point",
},
}
return typ
}
// Encode implements bin.Encoder.
func (i *InputMediaGeoPoint) Encode(b *bin.Buffer) error {
if i == nil {
return fmt.Errorf("can't encode inputMediaGeoPoint#f9c44144 as nil")
}
b.PutID(InputMediaGeoPointTypeID)
return i.EncodeBare(b)
}
// EncodeBare implements bin.BareEncoder.
func (i *InputMediaGeoPoint) EncodeBare(b *bin.Buffer) error {
if i == nil {
return fmt.Errorf("can't encode inputMediaGeoPoint#f9c44144 as nil")
}
if i.GeoPoint == nil {
return fmt.Errorf("unable to encode inputMediaGeoPoint#f9c44144: field geo_point is nil")
}
if err := i.GeoPoint.Encode(b); err != nil {
return fmt.Errorf("unable to encode inputMediaGeoPoint#f9c44144: field geo_point: %w", err)
}
return nil
}
// Decode implements bin.Decoder.
func (i *InputMediaGeoPoint) Decode(b *bin.Buffer) error {
if i == nil {
return fmt.Errorf("can't decode inputMediaGeoPoint#f9c44144 to nil")
}
if err := b.ConsumeID(InputMediaGeoPointTypeID); err != nil {
return fmt.Errorf("unable to decode inputMediaGeoPoint#f9c44144: %w", err)
}
return i.DecodeBare(b)
}
// DecodeBare implements bin.BareDecoder.
func (i *InputMediaGeoPoint) DecodeBare(b *bin.Buffer) error {
if i == nil {
return fmt.Errorf("can't decode inputMediaGeoPoint#f9c44144 to nil")
}
{
value, err := DecodeInputGeoPoint(b)
if err != nil {
return fmt.Errorf("unable to decode inputMediaGeoPoint#f9c44144: field geo_point: %w", err)
}
i.GeoPoint = value
}
return nil
}
// GetGeoPoint returns value of GeoPoint field.
func (i *InputMediaGeoPoint) GetGeoPoint() (value InputGeoPointClass) {
if i == nil {
return
}
return i.GeoPoint
}
// InputMediaContact represents TL type `inputMediaContact#f8ab7dfb`.
// Phone book contact
//
// See https://core.telegram.org/constructor/inputMediaContact for reference.
type InputMediaContact struct {
// Phone number
PhoneNumber string
// Contact's first name
FirstName string
// Contact's last name
LastName string
// Contact vcard
Vcard string
}
// InputMediaContactTypeID is TL type id of InputMediaContact.
const InputMediaContactTypeID = 0xf8ab7dfb
// construct implements constructor of InputMediaClass.
func (i InputMediaContact) construct() InputMediaClass { return &i }
// Ensuring interfaces in compile-time for InputMediaContact.
var (
_ bin.Encoder = &InputMediaContact{}
_ bin.Decoder = &InputMediaContact{}
_ bin.BareEncoder = &InputMediaContact{}
_ bin.BareDecoder = &InputMediaContact{}
_ InputMediaClass = &InputMediaContact{}
)
func (i *InputMediaContact) Zero() bool {
if i == nil {
return true
}
if !(i.PhoneNumber == "") {
return false
}
if !(i.FirstName == "") {
return false
}
if !(i.LastName == "") {
return false
}
if !(i.Vcard == "") {
return false
}
return true
}
// String implements fmt.Stringer.
func (i *InputMediaContact) String() string {
if i == nil {
return "InputMediaContact(nil)"
}
type Alias InputMediaContact
return fmt.Sprintf("InputMediaContact%+v", Alias(*i))
}
// FillFrom fills InputMediaContact from given interface.
func (i *InputMediaContact) FillFrom(from interface {
GetPhoneNumber() (value string)
GetFirstName() (value string)
GetLastName() (value string)
GetVcard() (value string)
}) {
i.PhoneNumber = from.GetPhoneNumber()
i.FirstName = from.GetFirstName()
i.LastName = from.GetLastName()
i.Vcard = from.GetVcard()
}
// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*InputMediaContact) TypeID() uint32 {
return InputMediaContactTypeID
}
// TypeName returns name of type in TL schema.
func (*InputMediaContact) TypeName() string {
return "inputMediaContact"
}
// TypeInfo returns info about TL type.
func (i *InputMediaContact) TypeInfo() tdp.Type {
typ := tdp.Type{
Name: "inputMediaContact",
ID: InputMediaContactTypeID,
}
if i == nil {
typ.Null = true
return typ
}
typ.Fields = []tdp.Field{
{
Name: "PhoneNumber",
SchemaName: "phone_number",
},
{
Name: "FirstName",
SchemaName: "first_name",
},
{
Name: "LastName",
SchemaName: "last_name",
},
{
Name: "Vcard",
SchemaName: "vcard",
},
}
return typ
}
// Encode implements bin.Encoder.
func (i *InputMediaContact) Encode(b *bin.Buffer) error {
if i == nil {
return fmt.Errorf("can't encode inputMediaContact#f8ab7dfb as nil")
}
b.PutID(InputMediaContactTypeID)
return i.EncodeBare(b)
}
// EncodeBare implements bin.BareEncoder.
func (i *InputMediaContact) EncodeBare(b *bin.Buffer) error {
if i == nil {
return fmt.Errorf("can't encode inputMediaContact#f8ab7dfb as nil")
}
b.PutString(i.PhoneNumber)
b.PutString(i.FirstName)
b.PutString(i.LastName)
b.PutString(i.Vcard)
return nil
}
// Decode implements bin.Decoder.
func (i *InputMediaContact) Decode(b *bin.Buffer) error {
if i == nil {
return fmt.Errorf("can't decode inputMediaContact#f8ab7dfb to nil")
}
if err := b.ConsumeID(InputMediaContactTypeID); err != nil {
return fmt.Errorf("unable to decode inputMediaContact#f8ab7dfb: %w", err)
}
return i.DecodeBare(b)
}
// DecodeBare implements bin.BareDecoder.
func (i *InputMediaContact) DecodeBare(b *bin.Buffer) error {
if i == nil {
return fmt.Errorf("can't decode inputMediaContact#f8ab7dfb to nil")
}
{
value, err := b.String()
if err != nil {
return fmt.Errorf("unable to decode inputMediaContact#f8ab7dfb: field phone_number: %w", err)
}
i.PhoneNumber = value
}
{
value, err := b.String()
if err != nil {
return fmt.Errorf("unable to decode inputMediaContact#f8ab7dfb: field first_name: %w", err)
}
i.FirstName = value
}
{
value, err := b.String()
if err != nil {
return fmt.Errorf("unable to decode inputMediaContact#f8ab7dfb: field last_name: %w", err)
}
i.LastName = value
}
{
value, err := b.String()
if err != nil {
return fmt.Errorf("unable to decode inputMediaContact#f8ab7dfb: field vcard: %w", err)
}
i.Vcard = value
}
return nil
}
// GetPhoneNumber returns value of PhoneNumber field.
func (i *InputMediaContact) GetPhoneNumber() (value string) {
if i == nil {
return
}
return i.PhoneNumber
}
// GetFirstName returns value of FirstName field.
func (i *InputMediaContact) GetFirstName() (value string) {
if i == nil {
return
}
return i.FirstName
}
// GetLastName returns value of LastName field.
func (i *InputMediaContact) GetLastName() (value string) {
if i == nil {
return
}
return i.LastName
}
// GetVcard returns value of Vcard field.
func (i *InputMediaContact) GetVcard() (value string) {
if i == nil {
return
}
return i.Vcard
}
// InputMediaUploadedDocument represents TL type `inputMediaUploadedDocument#37c9330`.
// New document
//
// See https://core.telegram.org/constructor/inputMediaUploadedDocument for reference.
type InputMediaUploadedDocument struct {
// Flags, see TL conditional fields¹
//
// Links:
// 1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
Flags bin.Fields
// Whether the specified document is a video file with no audio tracks (a GIF animation
// (even as MPEG4), for example)
NosoundVideo bool
// Force the media file to be uploaded as document
ForceFile bool
// Whether this media should be hidden behind a spoiler warning
Spoiler bool
// The uploaded file¹
//
// Links:
// 1) https://core.telegram.org/api/files
File InputFileClass
// Thumbnail of the document, uploaded as for the file
//
// Use SetThumb and GetThumb helpers.
Thumb InputFileClass
// MIME type of document
MimeType string
// Attributes that specify the type of the document (video, audio, voice, sticker, etc.)
Attributes []DocumentAttributeClass
// Attached stickers
//
// Use SetStickers and GetStickers helpers.
Stickers []InputDocumentClass
// VideoCover field of InputMediaUploadedDocument.
//
// Use SetVideoCover and GetVideoCover helpers.
VideoCover InputPhotoClass
// VideoTimestamp field of InputMediaUploadedDocument.
//
// Use SetVideoTimestamp and GetVideoTimestamp helpers.
VideoTimestamp int
// Time to live in seconds of self-destructing document
//
// Use SetTTLSeconds and GetTTLSeconds helpers.
TTLSeconds int
}
// InputMediaUploadedDocumentTypeID is TL type id of InputMediaUploadedDocument.
const InputMediaUploadedDocumentTypeID = 0x37c9330
// construct implements constructor of InputMediaClass.
func (i InputMediaUploadedDocument) construct() InputMediaClass { return &i }
// Ensuring interfaces in compile-time for InputMediaUploadedDocument.
var (
_ bin.Encoder = &InputMediaUploadedDocument{}
_ bin.Decoder = &InputMediaUploadedDocument{}
_ bin.BareEncoder = &InputMediaUploadedDocument{}
_ bin.BareDecoder = &InputMediaUploadedDocument{}
_ InputMediaClass = &InputMediaUploadedDocument{}
)
func (i *InputMediaUploadedDocument) Zero() bool {
if i == nil {
return true
}
if !(i.Flags.Zero()) {
return false
}
if !(i.NosoundVideo == false) {
return false
}
if !(i.ForceFile == false) {
return false
}
if !(i.Spoiler == false) {
return false
}
if !(i.File == nil) {
return false
}
if !(i.Thumb == nil) {
return false
}
if !(i.MimeType == "") {
return false
}
if !(i.Attributes == nil) {
return false
}
if !(i.Stickers == nil) {
return false
}
if !(i.VideoCover == nil) {
return false
}
if !(i.VideoTimestamp == 0) {
return false
}
if !(i.TTLSeconds == 0) {
return false
}
return true
}
// String implements fmt.Stringer.
func (i *InputMediaUploadedDocument) String() string {
if i == nil {
return "InputMediaUploadedDocument(nil)"
}
type Alias InputMediaUploadedDocument
return fmt.Sprintf("InputMediaUploadedDocument%+v", Alias(*i))
}
// FillFrom fills InputMediaUploadedDocument from given interface.
func (i *InputMediaUploadedDocument) FillFrom(from interface {
GetNosoundVideo() (value bool)
GetForceFile() (value bool)
GetSpoiler() (value bool)
GetFile() (value InputFileClass)
GetThumb() (value InputFileClass, ok bool)
GetMimeType() (value string)
GetAttributes() (value []DocumentAttributeClass)
GetStickers() (value []InputDocumentClass, ok bool)
GetVideoCover() (value InputPhotoClass, ok bool)
GetVideoTimestamp() (value int, ok bool)
GetTTLSeconds() (value int, ok bool)
}) {
i.NosoundVideo = from.GetNosoundVideo()
i.ForceFile = from.GetForceFile()
i.Spoiler = from.GetSpoiler()
i.File = from.GetFile()
if val, ok := from.GetThumb(); ok {
i.Thumb = val
}
i.MimeType = from.GetMimeType()
i.Attributes = from.GetAttributes()
if val, ok := from.GetStickers(); ok {
i.Stickers = val
}
if val, ok := from.GetVideoCover(); ok {
i.VideoCover = val
}
if val, ok := from.GetVideoTimestamp(); ok {
i.VideoTimestamp = val
}
if val, ok := from.GetTTLSeconds(); ok {
i.TTLSeconds = val
}
}
// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*InputMediaUploadedDocument) TypeID() uint32 {
return InputMediaUploadedDocumentTypeID
}
// TypeName returns name of type in TL schema.
func (*InputMediaUploadedDocument) TypeName() string {
return "inputMediaUploadedDocument"
}
// TypeInfo returns info about TL type.
func (i *InputMediaUploadedDocument) TypeInfo() tdp.Type {
typ := tdp.Type{
Name: "inputMediaUploadedDocument",
ID: InputMediaUploadedDocumentTypeID,
}
if i == nil {
typ.Null = true
return typ
}
typ.Fields = []tdp.Field{
{
Name: "NosoundVideo",
SchemaName: "nosound_video",
Null: !i.Flags.Has(3),
},
{
Name: "ForceFile",
SchemaName: "force_file",
Null: !i.Flags.Has(4),
},
{
Name: "Spoiler",
SchemaName: "spoiler",
Null: !i.Flags.Has(5),
},
{
Name: "File",
SchemaName: "file",
},
{
Name: "Thumb",
SchemaName: "thumb",
Null: !i.Flags.Has(2),
},
{
Name: "MimeType",
SchemaName: "mime_type",
},
{
Name: "Attributes",
SchemaName: "attributes",
},
{
Name: "Stickers",
SchemaName: "stickers",
Null: !i.Flags.Has(0),
},
{
Name: "VideoCover",
SchemaName: "video_cover",
Null: !i.Flags.Has(6),
},
{
Name: "VideoTimestamp",
SchemaName: "video_timestamp",
Null: !i.Flags.Has(7),
},
{
Name: "TTLSeconds",
SchemaName: "ttl_seconds",
Null: !i.Flags.Has(1),
},
}
return typ
}
// SetFlags sets flags for non-zero fields.
func (i *InputMediaUploadedDocument) SetFlags() {
if !(i.NosoundVideo == false) {
i.Flags.Set(3)
}
if !(i.ForceFile == false) {
i.Flags.Set(4)
}
if !(i.Spoiler == false) {
i.Flags.Set(5)
}
if !(i.Thumb == nil) {
i.Flags.Set(2)
}
if !(i.Stickers == nil) {
i.Flags.Set(0)
}
if !(i.VideoCover == nil) {
i.Flags.Set(6)
}
if !(i.VideoTimestamp == 0) {
i.Flags.Set(7)
}
if !(i.TTLSeconds == 0) {
i.Flags.Set(1)
}
}
// Encode implements bin.Encoder.
func (i *InputMediaUploadedDocument) Encode(b *bin.Buffer) error {
if i == nil {
return fmt.Errorf("can't encode inputMediaUploadedDocument#37c9330 as nil")
}
b.PutID(InputMediaUploadedDocumentTypeID)
return i.EncodeBare(b)
}
// EncodeBare implements bin.BareEncoder.
func (i *InputMediaUploadedDocument) EncodeBare(b *bin.Buffer) error {
if i == nil {
return fmt.Errorf("can't encode inputMediaUploadedDocument#37c9330 as nil")
}
i.SetFlags()
if err := i.Flags.Encode(b); err != nil {
return fmt.Errorf("unable to encode inputMediaUploadedDocument#37c9330: field flags: %w", err)
}
if i.File == nil {
return fmt.Errorf("unable to encode inputMediaUploadedDocument#37c9330: field file is nil")
}
if err := i.File.Encode(b); err != nil {
return fmt.Errorf("unable to encode inputMediaUploadedDocument#37c9330: field file: %w", err)
}
if i.Flags.Has(2) {
if i.Thumb == nil {
return fmt.Errorf("unable to encode inputMediaUploadedDocument#37c9330: field thumb is nil")
}
if err := i.Thumb.Encode(b); err != nil {
return fmt.Errorf("unable to encode inputMediaUploadedDocument#37c9330: field thumb: %w", err)
}
}
b.PutString(i.MimeType)
b.PutVectorHeader(len(i.Attributes))
for idx, v := range i.Attributes {
if v == nil {
return fmt.Errorf("unable to encode inputMediaUploadedDocument#37c9330: field attributes element with index %d is nil", idx)
}
if err := v.Encode(b); err != nil {
return fmt.Errorf("unable to encode inputMediaUploadedDocument#37c9330: field attributes element with index %d: %w", idx, err)
}
}
if i.Flags.Has(0) {
b.PutVectorHeader(len(i.Stickers))
for idx, v := range i.Stickers {
if v == nil {
return fmt.Errorf("unable to encode inputMediaUploadedDocument#37c9330: field stickers element with index %d is nil", idx)
}
if err := v.Encode(b); err != nil {
return fmt.Errorf("unable to encode inputMediaUploadedDocument#37c9330: field stickers element with index %d: %w", idx, err)
}
}
}
if i.Flags.Has(6) {
if i.VideoCover == nil {
return fmt.Errorf("unable to encode inputMediaUploadedDocument#37c9330: field video_cover is nil")
}
if err := i.VideoCover.Encode(b); err != nil {
return fmt.Errorf("unable to encode inputMediaUploadedDocument#37c9330: field video_cover: %w", err)
}
}
if i.Flags.Has(7) {
b.PutInt(i.VideoTimestamp)
}
if i.Flags.Has(1) {
b.PutInt(i.TTLSeconds)
}
return nil
}
// Decode implements bin.Decoder.
func (i *InputMediaUploadedDocument) Decode(b *bin.Buffer) error {
if i == nil {
return fmt.Errorf("can't decode inputMediaUploadedDocument#37c9330 to nil")
}
if err := b.ConsumeID(InputMediaUploadedDocumentTypeID); err != nil {
return fmt.Errorf("unable to decode inputMediaUploadedDocument#37c9330: %w", err)
}
return i.DecodeBare(b)
}
// DecodeBare implements bin.BareDecoder.
func (i *InputMediaUploadedDocument) DecodeBare(b *bin.Buffer) error {
if i == nil {
return fmt.Errorf("can't decode inputMediaUploadedDocument#37c9330 to nil")
}
{
if err := i.Flags.Decode(b); err != nil {
return fmt.Errorf("unable to decode inputMediaUploadedDocument#37c9330: field flags: %w", err)
}
}
i.NosoundVideo = i.Flags.Has(3)
i.ForceFile = i.Flags.Has(4)
i.Spoiler = i.Flags.Has(5)
{
value, err := DecodeInputFile(b)
if err != nil {
return fmt.Errorf("unable to decode inputMediaUploadedDocument#37c9330: field file: %w", err)
}
i.File = value
}
if i.Flags.Has(2) {
value, err := DecodeInputFile(b)
if err != nil {
return fmt.Errorf("unable to decode inputMediaUploadedDocument#37c9330: field thumb: %w", err)
}
i.Thumb = value
}
{
value, err := b.String()
if err != nil {
return fmt.Errorf("unable to decode inputMediaUploadedDocument#37c9330: field mime_type: %w", err)
}
i.MimeType = value
}
{
headerLen, err := b.VectorHeader()
if err != nil {
return fmt.Errorf("unable to decode inputMediaUploadedDocument#37c9330: field attributes: %w", err)
}
if headerLen > 0 {
i.Attributes = make([]DocumentAttributeClass, 0, headerLen%bin.PreallocateLimit)
}
for idx := 0; idx < headerLen; idx++ {
value, err := DecodeDocumentAttribute(b)
if err != nil {
return fmt.Errorf("unable to decode inputMediaUploadedDocument#37c9330: field attributes: %w", err)
}
i.Attributes = append(i.Attributes, value)
}
}
if i.Flags.Has(0) {
headerLen, err := b.VectorHeader()
if err != nil {
return fmt.Errorf("unable to decode inputMediaUploadedDocument#37c9330: field stickers: %w", err)
}
if headerLen > 0 {
i.Stickers = make([]InputDocumentClass, 0, headerLen%bin.PreallocateLimit)
}
for idx := 0; idx < headerLen; idx++ {
value, err := DecodeInputDocument(b)
if err != nil {
return fmt.Errorf("unable to decode inputMediaUploadedDocument#37c9330: field stickers: %w", err)
}
i.Stickers = append(i.Stickers, value)
}
}
if i.Flags.Has(6) {
value, err := DecodeInputPhoto(b)
if err != nil {
return fmt.Errorf("unable to decode inputMediaUploadedDocument#37c9330: field video_cover: %w", err)
}
i.VideoCover = value
}
if i.Flags.Has(7) {
value, err := b.Int()
if err != nil {
return fmt.Errorf("unable to decode inputMediaUploadedDocument#37c9330: field video_timestamp: %w", err)
}
i.VideoTimestamp = value
}
if i.Flags.Has(1) {
value, err := b.Int()
if err != nil {
return fmt.Errorf("unable to decode inputMediaUploadedDocument#37c9330: field ttl_seconds: %w", err)
}
i.TTLSeconds = value
}
return nil
}
// SetNosoundVideo sets value of NosoundVideo conditional field.
func (i *InputMediaUploadedDocument) SetNosoundVideo(value bool) {
if value {
i.Flags.Set(3)
i.NosoundVideo = true
} else {
i.Flags.Unset(3)
i.NosoundVideo = false
}
}
// GetNosoundVideo returns value of NosoundVideo conditional field.
func (i *InputMediaUploadedDocument) GetNosoundVideo() (value bool) {
if i == nil {
return
}
return i.Flags.Has(3)
}
// SetForceFile sets value of ForceFile conditional field.
func (i *InputMediaUploadedDocument) SetForceFile(value bool) {
if value {
i.Flags.Set(4)
i.ForceFile = true
} else {
i.Flags.Unset(4)
i.ForceFile = false
}
}
// GetForceFile returns value of ForceFile conditional field.
func (i *InputMediaUploadedDocument) GetForceFile() (value bool) {
if i == nil {
return
}
return i.Flags.Has(4)
}
// SetSpoiler sets value of Spoiler conditional field.
func (i *InputMediaUploadedDocument) SetSpoiler(value bool) {
if value {
i.Flags.Set(5)
i.Spoiler = true
} else {
i.Flags.Unset(5)
i.Spoiler = false
}
}
// GetSpoiler returns value of Spoiler conditional field.
func (i *InputMediaUploadedDocument) GetSpoiler() (value bool) {
if i == nil {
return
}
return i.Flags.Has(5)
}
// GetFile returns value of File field.
func (i *InputMediaUploadedDocument) GetFile() (value InputFileClass) {
if i == nil {
return
}
return i.File
}
// SetThumb sets value of Thumb conditional field.
func (i *InputMediaUploadedDocument) SetThumb(value InputFileClass) {
i.Flags.Set(2)
i.Thumb = value
}
// GetThumb returns value of Thumb conditional field and
// boolean which is true if field was set.
func (i *InputMediaUploadedDocument) GetThumb() (value InputFileClass, ok bool) {
if i == nil {
return
}
if !i.Flags.Has(2) {
return value, false
}
return i.Thumb, true
}
// GetMimeType returns value of MimeType field.
func (i *InputMediaUploadedDocument) GetMimeType() (value string) {
if i == nil {
return
}
return i.MimeType
}
// GetAttributes returns value of Attributes field.
func (i *InputMediaUploadedDocument) GetAttributes() (value []DocumentAttributeClass) {
if i == nil {
return
}
return i.Attributes
}
// SetStickers sets value of Stickers conditional field.
func (i *InputMediaUploadedDocument) SetStickers(value []InputDocumentClass) {
i.Flags.Set(0)
i.Stickers = value
}
// GetStickers returns value of Stickers conditional field and
// boolean which is true if field was set.
func (i *InputMediaUploadedDocument) GetStickers() (value []InputDocumentClass, ok bool) {
if i == nil {
return
}
if !i.Flags.Has(0) {
return value, false
}
return i.Stickers, true
}
// SetVideoCover sets value of VideoCover conditional field.
func (i *InputMediaUploadedDocument) SetVideoCover(value InputPhotoClass) {
i.Flags.Set(6)
i.VideoCover = value
}
// GetVideoCover returns value of VideoCover conditional field and
// boolean which is true if field was set.
func (i *InputMediaUploadedDocument) GetVideoCover() (value InputPhotoClass, ok bool) {
if i == nil {
return
}
if !i.Flags.Has(6) {
return value, false
}
return i.VideoCover, true
}
// SetVideoTimestamp sets value of VideoTimestamp conditional field.
func (i *InputMediaUploadedDocument) SetVideoTimestamp(value int) {
i.Flags.Set(7)
i.VideoTimestamp = value
}
// GetVideoTimestamp returns value of VideoTimestamp conditional field and
// boolean which is true if field was set.
func (i *InputMediaUploadedDocument) GetVideoTimestamp() (value int, ok bool) {
if i == nil {
return
}
if !i.Flags.Has(7) {
return value, false
}
return i.VideoTimestamp, true
}
// SetTTLSeconds sets value of TTLSeconds conditional field.
func (i *InputMediaUploadedDocument) SetTTLSeconds(value int) {
i.Flags.Set(1)
i.TTLSeconds = value
}
// GetTTLSeconds returns value of TTLSeconds conditional field and
// boolean which is true if field was set.
func (i *InputMediaUploadedDocument) GetTTLSeconds() (value int, ok bool) {
if i == nil {
return
}
if !i.Flags.Has(1) {
return value, false
}
return i.TTLSeconds, true
}
// MapAttributes returns field Attributes wrapped in DocumentAttributeClassArray helper.
func (i *InputMediaUploadedDocument) MapAttributes() (value DocumentAttributeClassArray) {
return DocumentAttributeClassArray(i.Attributes)
}
// MapStickers returns field Stickers wrapped in InputDocumentClassArray helper.
func (i *InputMediaUploadedDocument) MapStickers() (value InputDocumentClassArray, ok bool) {
if !i.Flags.Has(0) {
return value, false
}
return InputDocumentClassArray(i.Stickers), true
}
// InputMediaDocument represents TL type `inputMediaDocument#a8763ab5`.
// Forwarded document
//
// See https://core.telegram.org/constructor/inputMediaDocument for reference.
type InputMediaDocument struct {
// Flags, see TL conditional fields¹
//
// Links:
// 1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
Flags bin.Fields
// Whether this media should be hidden behind a spoiler warning
Spoiler bool
// The document to be forwarded.
ID InputDocumentClass
// VideoCover field of InputMediaDocument.
//
// Use SetVideoCover and GetVideoCover helpers.
VideoCover InputPhotoClass
// VideoTimestamp field of InputMediaDocument.
//
// Use SetVideoTimestamp and GetVideoTimestamp helpers.
VideoTimestamp int
// Time to live of self-destructing document
//
// Use SetTTLSeconds and GetTTLSeconds helpers.
TTLSeconds int
// Text query or emoji that was used by the user to find this sticker or GIF: used to
// improve search result relevance.
//
// Use SetQuery and GetQuery helpers.
Query string
}
// InputMediaDocumentTypeID is TL type id of InputMediaDocument.
const InputMediaDocumentTypeID = 0xa8763ab5
// construct implements constructor of InputMediaClass.
func (i InputMediaDocument) construct() InputMediaClass { return &i }
// Ensuring interfaces in compile-time for InputMediaDocument.
var (
_ bin.Encoder = &InputMediaDocument{}
_ bin.Decoder = &InputMediaDocument{}
_ bin.BareEncoder = &InputMediaDocument{}
_ bin.BareDecoder = &InputMediaDocument{}
_ InputMediaClass = &InputMediaDocument{}
)
func (i *InputMediaDocument) Zero() bool {
if i == nil {
return true
}
if !(i.Flags.Zero()) {
return false
}
if !(i.Spoiler == false) {
return false
}
if !(i.ID == nil) {
return false
}
if !(i.VideoCover == nil) {
return false
}
if !(i.VideoTimestamp == 0) {
return false
}
if !(i.TTLSeconds == 0) {
return false
}
if !(i.Query == "") {
return false
}
return true
}
// String implements fmt.Stringer.
func (i *InputMediaDocument) String() string {
if i == nil {
return "InputMediaDocument(nil)"
}
type Alias InputMediaDocument
return fmt.Sprintf("InputMediaDocument%+v", Alias(*i))
}
// FillFrom fills InputMediaDocument from given interface.
func (i *InputMediaDocument) FillFrom(from interface {
GetSpoiler() (value bool)
GetID() (value InputDocumentClass)
GetVideoCover() (value InputPhotoClass, ok bool)
GetVideoTimestamp() (value int, ok bool)
GetTTLSeconds() (value int, ok bool)
GetQuery() (value string, ok bool)
}) {
i.Spoiler = from.GetSpoiler()
i.ID = from.GetID()
if val, ok := from.GetVideoCover(); ok {
i.VideoCover = val
}
if val, ok := from.GetVideoTimestamp(); ok {
i.VideoTimestamp = val
}
if val, ok := from.GetTTLSeconds(); ok {
i.TTLSeconds = val
}
if val, ok := from.GetQuery(); ok {
i.Query = val
}
}
// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*InputMediaDocument) TypeID() uint32 {
return InputMediaDocumentTypeID
}
// TypeName returns name of type in TL schema.
func (*InputMediaDocument) TypeName() string {
return "inputMediaDocument"
}
// TypeInfo returns info about TL type.
func (i *InputMediaDocument) TypeInfo() tdp.Type {
typ := tdp.Type{
Name: "inputMediaDocument",
ID: InputMediaDocumentTypeID,
}
if i == nil {
typ.Null = true
return typ
}
typ.Fields = []tdp.Field{
{
Name: "Spoiler",
SchemaName: "spoiler",
Null: !i.Flags.Has(2),
},
{
Name: "ID",
SchemaName: "id",
},
{
Name: "VideoCover",
SchemaName: "video_cover",
Null: !i.Flags.Has(3),
},
{
Name: "VideoTimestamp",
SchemaName: "video_timestamp",
Null: !i.Flags.Has(4),
},
{
Name: "TTLSeconds",
SchemaName: "ttl_seconds",
Null: !i.Flags.Has(0),
},
{
Name: "Query",
SchemaName: "query",
Null: !i.Flags.Has(1),
},
}
return typ
}
// SetFlags sets flags for non-zero fields.
func (i *InputMediaDocument) SetFlags() {
if !(i.Spoiler == false) {
i.Flags.Set(2)
}
if !(i.VideoCover == nil) {
i.Flags.Set(3)
}
if !(i.VideoTimestamp == 0) {
i.Flags.Set(4)
}
if !(i.TTLSeconds == 0) {
i.Flags.Set(0)
}
if !(i.Query == "") {
i.Flags.Set(1)
}
}
// Encode implements bin.Encoder.
func (i *InputMediaDocument) Encode(b *bin.Buffer) error {
if i == nil {
return fmt.Errorf("can't encode inputMediaDocument#a8763ab5 as nil")
}
b.PutID(InputMediaDocumentTypeID)
return i.EncodeBare(b)
}
// EncodeBare implements bin.BareEncoder.
func (i *InputMediaDocument) EncodeBare(b *bin.Buffer) error {
if i == nil {
return fmt.Errorf("can't encode inputMediaDocument#a8763ab5 as nil")
}
i.SetFlags()
if err := i.Flags.Encode(b); err != nil {
return fmt.Errorf("unable to encode inputMediaDocument#a8763ab5: field flags: %w", err)
}
if i.ID == nil {
return fmt.Errorf("unable to encode inputMediaDocument#a8763ab5: field id is nil")
}
if err := i.ID.Encode(b); err != nil {
return fmt.Errorf("unable to encode inputMediaDocument#a8763ab5: field id: %w", err)
}
if i.Flags.Has(3) {
if i.VideoCover == nil {
return fmt.Errorf("unable to encode inputMediaDocument#a8763ab5: field video_cover is nil")
}
if err := i.VideoCover.Encode(b); err != nil {
return fmt.Errorf("unable to encode inputMediaDocument#a8763ab5: field video_cover: %w", err)
}
}
if i.Flags.Has(4) {
b.PutInt(i.VideoTimestamp)
}
if i.Flags.Has(0) {
b.PutInt(i.TTLSeconds)
}
if i.Flags.Has(1) {
b.PutString(i.Query)
}
return nil
}
// Decode implements bin.Decoder.
func (i *InputMediaDocument) Decode(b *bin.Buffer) error {
if i == nil {
return fmt.Errorf("can't decode inputMediaDocument#a8763ab5 to nil")
}
if err := b.ConsumeID(InputMediaDocumentTypeID); err != nil {
return fmt.Errorf("unable to decode inputMediaDocument#a8763ab5: %w", err)
}
return i.DecodeBare(b)
}
// DecodeBare implements bin.BareDecoder.
func (i *InputMediaDocument) DecodeBare(b *bin.Buffer) error {
if i == nil {
return fmt.Errorf("can't decode inputMediaDocument#a8763ab5 to nil")
}
{
if err := i.Flags.Decode(b); err != nil {
return fmt.Errorf("unable to decode inputMediaDocument#a8763ab5: field flags: %w", err)
}
}
i.Spoiler = i.Flags.Has(2)
{
value, err := DecodeInputDocument(b)
if err != nil {
return fmt.Errorf("unable to decode inputMediaDocument#a8763ab5: field id: %w", err)
}
i.ID = value
}
if i.Flags.Has(3) {
value, err := DecodeInputPhoto(b)
if err != nil {
return fmt.Errorf("unable to decode inputMediaDocument#a8763ab5: field video_cover: %w", err)
}
i.VideoCover = value
}
if i.Flags.Has(4) {
value, err := b.Int()
if err != nil {
return fmt.Errorf("unable to decode inputMediaDocument#a8763ab5: field video_timestamp: %w", err)
}
i.VideoTimestamp = value
}
if i.Flags.Has(0) {
value, err := b.Int()
if err != nil {
return fmt.Errorf("unable to decode inputMediaDocument#a8763ab5: field ttl_seconds: %w", err)
}
i.TTLSeconds = value
}
if i.Flags.Has(1) {
value, err := b.String()
if err != nil {
return fmt.Errorf("unable to decode inputMediaDocument#a8763ab5: field query: %w", err)
}
i.Query = value
}
return nil
}
// SetSpoiler sets value of Spoiler conditional field.
func (i *InputMediaDocument) SetSpoiler(value bool) {
if value {
i.Flags.Set(2)
i.Spoiler = true
} else {
i.Flags.Unset(2)
i.Spoiler = false
}
}
// GetSpoiler returns value of Spoiler conditional field.
func (i *InputMediaDocument) GetSpoiler() (value bool) {
if i == nil {
return
}
return i.Flags.Has(2)
}
// GetID returns value of ID field.
func (i *InputMediaDocument) GetID() (value InputDocumentClass) {
if i == nil {
return
}
return i.ID
}
// SetVideoCover sets value of VideoCover conditional field.
func (i *InputMediaDocument) SetVideoCover(value InputPhotoClass) {
i.Flags.Set(3)
i.VideoCover = value
}
// GetVideoCover returns value of VideoCover conditional field and
// boolean which is true if field was set.
func (i *InputMediaDocument) GetVideoCover() (value InputPhotoClass, ok bool) {
if i == nil {
return
}
if !i.Flags.Has(3) {
return value, false
}
return i.VideoCover, true
}
// SetVideoTimestamp sets value of VideoTimestamp conditional field.
func (i *InputMediaDocument) SetVideoTimestamp(value int) {
i.Flags.Set(4)
i.VideoTimestamp = value
}
// GetVideoTimestamp returns value of VideoTimestamp conditional field and
// boolean which is true if field was set.
func (i *InputMediaDocument) GetVideoTimestamp() (value int, ok bool) {
if i == nil {
return
}
if !i.Flags.Has(4) {
return value, false
}
return i.VideoTimestamp, true
}
// SetTTLSeconds sets value of TTLSeconds conditional field.
func (i *InputMediaDocument) SetTTLSeconds(value int) {
i.Flags.Set(0)
i.TTLSeconds = value
}
// GetTTLSeconds returns value of TTLSeconds conditional field and
// boolean which is true if field was set.
func (i *InputMediaDocument) GetTTLSeconds() (value int, ok bool) {
if i == nil {
return
}
if !i.Flags.Has(0) {
return value, false
}
return i.TTLSeconds, true
}
// SetQuery sets value of Query conditional field.
func (i *InputMediaDocument) SetQuery(value string) {
i.Flags.Set(1)
i.Query = value
}
// GetQuery returns value of Query conditional field and
// boolean which is true if field was set.
func (i *InputMediaDocument) GetQuery() (value string, ok bool) {
if i == nil {
return
}
if !i.Flags.Has(1) {
return value, false
}
return i.Query, true
}
// InputMediaVenue represents TL type `inputMediaVenue#c13d1c11`.
// Can be used to send a venue geolocation.
//
// See https://core.telegram.org/constructor/inputMediaVenue for reference.
type InputMediaVenue struct {
// Geolocation
GeoPoint InputGeoPointClass
// Venue name
Title string
// Physical address of the venue
Address string
// Venue provider: currently only "foursquare" and "gplaces" (Google Places) need to be
// supported
Provider string
// Venue ID in the provider's database
VenueID string
// Venue type in the provider's database
VenueType string
}
// InputMediaVenueTypeID is TL type id of InputMediaVenue.
const InputMediaVenueTypeID = 0xc13d1c11
// construct implements constructor of InputMediaClass.
func (i InputMediaVenue) construct() InputMediaClass { return &i }
// Ensuring interfaces in compile-time for InputMediaVenue.
var (
_ bin.Encoder = &InputMediaVenue{}
_ bin.Decoder = &InputMediaVenue{}
_ bin.BareEncoder = &InputMediaVenue{}
_ bin.BareDecoder = &InputMediaVenue{}
_ InputMediaClass = &InputMediaVenue{}
)
func (i *InputMediaVenue) Zero() bool {
if i == nil {
return true
}
if !(i.GeoPoint == nil) {
return false
}
if !(i.Title == "") {
return false
}
if !(i.Address == "") {
return false
}
if !(i.Provider == "") {
return false
}
if !(i.VenueID == "") {
return false
}
if !(i.VenueType == "") {
return false
}
return true
}
// String implements fmt.Stringer.
func (i *InputMediaVenue) String() string {
if i == nil {
return "InputMediaVenue(nil)"
}
type Alias InputMediaVenue
return fmt.Sprintf("InputMediaVenue%+v", Alias(*i))
}
// FillFrom fills InputMediaVenue from given interface.
func (i *InputMediaVenue) FillFrom(from interface {
GetGeoPoint() (value InputGeoPointClass)
GetTitle() (value string)
GetAddress() (value string)
GetProvider() (value string)
GetVenueID() (value string)
GetVenueType() (value string)
}) {
i.GeoPoint = from.GetGeoPoint()
i.Title = from.GetTitle()
i.Address = from.GetAddress()
i.Provider = from.GetProvider()
i.VenueID = from.GetVenueID()
i.VenueType = from.GetVenueType()
}
// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*InputMediaVenue) TypeID() uint32 {
return InputMediaVenueTypeID
}
// TypeName returns name of type in TL schema.
func (*InputMediaVenue) TypeName() string {
return "inputMediaVenue"
}
// TypeInfo returns info about TL type.
func (i *InputMediaVenue) TypeInfo() tdp.Type {
typ := tdp.Type{
Name: "inputMediaVenue",
ID: InputMediaVenueTypeID,
}
if i == nil {
typ.Null = true
return typ
}
typ.Fields = []tdp.Field{
{
Name: "GeoPoint",
SchemaName: "geo_point",
},
{
Name: "Title",
SchemaName: "title",
},
{
Name: "Address",
SchemaName: "address",
},
{
Name: "Provider",
SchemaName: "provider",
},
{
Name: "VenueID",
SchemaName: "venue_id",
},
{
Name: "VenueType",
SchemaName: "venue_type",
},
}
return typ
}
// Encode implements bin.Encoder.
func (i *InputMediaVenue) Encode(b *bin.Buffer) error {
if i == nil {
return fmt.Errorf("can't encode inputMediaVenue#c13d1c11 as nil")
}
b.PutID(InputMediaVenueTypeID)
return i.EncodeBare(b)
}
// EncodeBare implements bin.BareEncoder.
func (i *InputMediaVenue) EncodeBare(b *bin.Buffer) error {
if i == nil {
return fmt.Errorf("can't encode inputMediaVenue#c13d1c11 as nil")
}
if i.GeoPoint == nil {
return fmt.Errorf("unable to encode inputMediaVenue#c13d1c11: field geo_point is nil")
}
if err := i.GeoPoint.Encode(b); err != nil {
return fmt.Errorf("unable to encode inputMediaVenue#c13d1c11: field geo_point: %w", err)
}
b.PutString(i.Title)
b.PutString(i.Address)
b.PutString(i.Provider)
b.PutString(i.VenueID)
b.PutString(i.VenueType)
return nil
}
// Decode implements bin.Decoder.
func (i *InputMediaVenue) Decode(b *bin.Buffer) error {
if i == nil {
return fmt.Errorf("can't decode inputMediaVenue#c13d1c11 to nil")
}
if err := b.ConsumeID(InputMediaVenueTypeID); err != nil {
return fmt.Errorf("unable to decode inputMediaVenue#c13d1c11: %w", err)
}
return i.DecodeBare(b)
}
// DecodeBare implements bin.BareDecoder.
func (i *InputMediaVenue) DecodeBare(b *bin.Buffer) error {
if i == nil {
return fmt.Errorf("can't decode inputMediaVenue#c13d1c11 to nil")
}
{
value, err := DecodeInputGeoPoint(b)
if err != nil {
return fmt.Errorf("unable to decode inputMediaVenue#c13d1c11: field geo_point: %w", err)
}
i.GeoPoint = value
}
{
value, err := b.String()
if err != nil {
return fmt.Errorf("unable to decode inputMediaVenue#c13d1c11: field title: %w", err)
}
i.Title = value
}
{
value, err := b.String()
if err != nil {
return fmt.Errorf("unable to decode inputMediaVenue#c13d1c11: field address: %w", err)
}
i.Address = value
}
{
value, err := b.String()
if err != nil {
return fmt.Errorf("unable to decode inputMediaVenue#c13d1c11: field provider: %w", err)
}
i.Provider = value
}
{
value, err := b.String()
if err != nil {
return fmt.Errorf("unable to decode inputMediaVenue#c13d1c11: field venue_id: %w", err)
}
i.VenueID = value
}
{
value, err := b.String()
if err != nil {
return fmt.Errorf("unable to decode inputMediaVenue#c13d1c11: field venue_type: %w", err)
}
i.VenueType = value
}
return nil
}
// GetGeoPoint returns value of GeoPoint field.
func (i *InputMediaVenue) GetGeoPoint() (value InputGeoPointClass) {
if i == nil {
return
}
return i.GeoPoint
}
// GetTitle returns value of Title field.
func (i *InputMediaVenue) GetTitle() (value string) {
if i == nil {
return
}
return i.Title
}
// GetAddress returns value of Address field.
func (i *InputMediaVenue) GetAddress() (value string) {
if i == nil {
return
}
return i.Address
}
// GetProvider returns value of Provider field.
func (i *InputMediaVenue) GetProvider() (value string) {
if i == nil {
return
}
return i.Provider
}
// GetVenueID returns value of VenueID field.
func (i *InputMediaVenue) GetVenueID() (value string) {
if i == nil {
return
}
return i.VenueID
}
// GetVenueType returns value of VenueType field.
func (i *InputMediaVenue) GetVenueType() (value string) {
if i == nil {
return
}
return i.VenueType
}
// InputMediaPhotoExternal represents TL type `inputMediaPhotoExternal#e5bbfe1a`.
// New photo that will be uploaded by the server using the specified URL
//
// See https://core.telegram.org/constructor/inputMediaPhotoExternal for reference.
type InputMediaPhotoExternal struct {
// Flags, see TL conditional fields¹
//
// Links:
// 1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
Flags bin.Fields
// Whether this media should be hidden behind a spoiler warning
Spoiler bool
// URL of the photo
URL string
// Self-destruct time to live of photo
//
// Use SetTTLSeconds and GetTTLSeconds helpers.
TTLSeconds int
}
// InputMediaPhotoExternalTypeID is TL type id of InputMediaPhotoExternal.
const InputMediaPhotoExternalTypeID = 0xe5bbfe1a
// construct implements constructor of InputMediaClass.
func (i InputMediaPhotoExternal) construct() InputMediaClass { return &i }
// Ensuring interfaces in compile-time for InputMediaPhotoExternal.
var (
_ bin.Encoder = &InputMediaPhotoExternal{}
_ bin.Decoder = &InputMediaPhotoExternal{}
_ bin.BareEncoder = &InputMediaPhotoExternal{}
_ bin.BareDecoder = &InputMediaPhotoExternal{}
_ InputMediaClass = &InputMediaPhotoExternal{}
)
func (i *InputMediaPhotoExternal) Zero() bool {
if i == nil {
return true
}
if !(i.Flags.Zero()) {
return false
}
if !(i.Spoiler == false) {
return false
}
if !(i.URL == "") {
return false
}
if !(i.TTLSeconds == 0) {
return false
}
return true
}
// String implements fmt.Stringer.
func (i *InputMediaPhotoExternal) String() string {
if i == nil {
return "InputMediaPhotoExternal(nil)"
}
type Alias InputMediaPhotoExternal
return fmt.Sprintf("InputMediaPhotoExternal%+v", Alias(*i))
}
// FillFrom fills InputMediaPhotoExternal from given interface.
func (i *InputMediaPhotoExternal) FillFrom(from interface {
GetSpoiler() (value bool)
GetURL() (value string)
GetTTLSeconds() (value int, ok bool)
}) {
i.Spoiler = from.GetSpoiler()
i.URL = from.GetURL()
if val, ok := from.GetTTLSeconds(); ok {
i.TTLSeconds = val
}
}
// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*InputMediaPhotoExternal) TypeID() uint32 {
return InputMediaPhotoExternalTypeID
}
// TypeName returns name of type in TL schema.
func (*InputMediaPhotoExternal) TypeName() string {
return "inputMediaPhotoExternal"
}
// TypeInfo returns info about TL type.
func (i *InputMediaPhotoExternal) TypeInfo() tdp.Type {
typ := tdp.Type{
Name: "inputMediaPhotoExternal",
ID: InputMediaPhotoExternalTypeID,
}
if i == nil {
typ.Null = true
return typ
}
typ.Fields = []tdp.Field{
{
Name: "Spoiler",
SchemaName: "spoiler",
Null: !i.Flags.Has(1),
},
{
Name: "URL",
SchemaName: "url",
},
{
Name: "TTLSeconds",
SchemaName: "ttl_seconds",
Null: !i.Flags.Has(0),
},
}
return typ
}
// SetFlags sets flags for non-zero fields.
func (i *InputMediaPhotoExternal) SetFlags() {
if !(i.Spoiler == false) {
i.Flags.Set(1)
}
if !(i.TTLSeconds == 0) {
i.Flags.Set(0)
}
}
// Encode implements bin.Encoder.
func (i *InputMediaPhotoExternal) Encode(b *bin.Buffer) error {
if i == nil {
return fmt.Errorf("can't encode inputMediaPhotoExternal#e5bbfe1a as nil")
}
b.PutID(InputMediaPhotoExternalTypeID)
return i.EncodeBare(b)
}
// EncodeBare implements bin.BareEncoder.
func (i *InputMediaPhotoExternal) EncodeBare(b *bin.Buffer) error {
if i == nil {
return fmt.Errorf("can't encode inputMediaPhotoExternal#e5bbfe1a as nil")
}
i.SetFlags()
if err := i.Flags.Encode(b); err != nil {
return fmt.Errorf("unable to encode inputMediaPhotoExternal#e5bbfe1a: field flags: %w", err)
}
b.PutString(i.URL)
if i.Flags.Has(0) {
b.PutInt(i.TTLSeconds)
}
return nil
}
// Decode implements bin.Decoder.
func (i *InputMediaPhotoExternal) Decode(b *bin.Buffer) error {
if i == nil {
return fmt.Errorf("can't decode inputMediaPhotoExternal#e5bbfe1a to nil")
}
if err := b.ConsumeID(InputMediaPhotoExternalTypeID); err != nil {
return fmt.Errorf("unable to decode inputMediaPhotoExternal#e5bbfe1a: %w", err)
}
return i.DecodeBare(b)
}
// DecodeBare implements bin.BareDecoder.
func (i *InputMediaPhotoExternal) DecodeBare(b *bin.Buffer) error {
if i == nil {
return fmt.Errorf("can't decode inputMediaPhotoExternal#e5bbfe1a to nil")
}
{
if err := i.Flags.Decode(b); err != nil {
return fmt.Errorf("unable to decode inputMediaPhotoExternal#e5bbfe1a: field flags: %w", err)
}
}
i.Spoiler = i.Flags.Has(1)
{
value, err := b.String()
if err != nil {
return fmt.Errorf("unable to decode inputMediaPhotoExternal#e5bbfe1a: field url: %w", err)
}
i.URL = value
}
if i.Flags.Has(0) {
value, err := b.Int()
if err != nil {
return fmt.Errorf("unable to decode inputMediaPhotoExternal#e5bbfe1a: field ttl_seconds: %w", err)
}
i.TTLSeconds = value
}
return nil
}
// SetSpoiler sets value of Spoiler conditional field.
func (i *InputMediaPhotoExternal) SetSpoiler(value bool) {
if value {
i.Flags.Set(1)
i.Spoiler = true
} else {
i.Flags.Unset(1)
i.Spoiler = false
}
}
// GetSpoiler returns value of Spoiler conditional field.
func (i *InputMediaPhotoExternal) GetSpoiler() (value bool) {
if i == nil {
return
}
return i.Flags.Has(1)
}
// GetURL returns value of URL field.
func (i *InputMediaPhotoExternal) GetURL() (value string) {
if i == nil {
return
}
return i.URL
}
// SetTTLSeconds sets value of TTLSeconds conditional field.
func (i *InputMediaPhotoExternal) SetTTLSeconds(value int) {
i.Flags.Set(0)
i.TTLSeconds = value
}
// GetTTLSeconds returns value of TTLSeconds conditional field and
// boolean which is true if field was set.
func (i *InputMediaPhotoExternal) GetTTLSeconds() (value int, ok bool) {
if i == nil {
return
}
if !i.Flags.Has(0) {
return value, false
}
return i.TTLSeconds, true
}
// InputMediaDocumentExternal represents TL type `inputMediaDocumentExternal#779600f9`.
// Document that will be downloaded by the telegram servers
//
// See https://core.telegram.org/constructor/inputMediaDocumentExternal for reference.
type InputMediaDocumentExternal struct {
// Flags, see TL conditional fields¹
//
// Links:
// 1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
Flags bin.Fields
// Whether this media should be hidden behind a spoiler warning
Spoiler bool
// URL of the document
URL string
// Self-destruct time to live of document
//
// Use SetTTLSeconds and GetTTLSeconds helpers.
TTLSeconds int
// VideoCover field of InputMediaDocumentExternal.
//
// Use SetVideoCover and GetVideoCover helpers.
VideoCover InputPhotoClass
// VideoTimestamp field of InputMediaDocumentExternal.
//
// Use SetVideoTimestamp and GetVideoTimestamp helpers.
VideoTimestamp int
}
// InputMediaDocumentExternalTypeID is TL type id of InputMediaDocumentExternal.
const InputMediaDocumentExternalTypeID = 0x779600f9
// construct implements constructor of InputMediaClass.
func (i InputMediaDocumentExternal) construct() InputMediaClass { return &i }
// Ensuring interfaces in compile-time for InputMediaDocumentExternal.
var (
_ bin.Encoder = &InputMediaDocumentExternal{}
_ bin.Decoder = &InputMediaDocumentExternal{}
_ bin.BareEncoder = &InputMediaDocumentExternal{}
_ bin.BareDecoder = &InputMediaDocumentExternal{}
_ InputMediaClass = &InputMediaDocumentExternal{}
)
func (i *InputMediaDocumentExternal) Zero() bool {
if i == nil {
return true
}
if !(i.Flags.Zero()) {
return false
}
if !(i.Spoiler == false) {
return false
}
if !(i.URL == "") {
return false
}
if !(i.TTLSeconds == 0) {
return false
}
if !(i.VideoCover == nil) {
return false
}
if !(i.VideoTimestamp == 0) {
return false
}
return true
}
// String implements fmt.Stringer.
func (i *InputMediaDocumentExternal) String() string {
if i == nil {
return "InputMediaDocumentExternal(nil)"
}
type Alias InputMediaDocumentExternal
return fmt.Sprintf("InputMediaDocumentExternal%+v", Alias(*i))
}
// FillFrom fills InputMediaDocumentExternal from given interface.
func (i *InputMediaDocumentExternal) FillFrom(from interface {
GetSpoiler() (value bool)
GetURL() (value string)
GetTTLSeconds() (value int, ok bool)
GetVideoCover() (value InputPhotoClass, ok bool)
GetVideoTimestamp() (value int, ok bool)
}) {
i.Spoiler = from.GetSpoiler()
i.URL = from.GetURL()
if val, ok := from.GetTTLSeconds(); ok {
i.TTLSeconds = val
}
if val, ok := from.GetVideoCover(); ok {
i.VideoCover = val
}
if val, ok := from.GetVideoTimestamp(); ok {
i.VideoTimestamp = val
}
}
// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*InputMediaDocumentExternal) TypeID() uint32 {
return InputMediaDocumentExternalTypeID
}
// TypeName returns name of type in TL schema.
func (*InputMediaDocumentExternal) TypeName() string {
return "inputMediaDocumentExternal"
}
// TypeInfo returns info about TL type.
func (i *InputMediaDocumentExternal) TypeInfo() tdp.Type {
typ := tdp.Type{
Name: "inputMediaDocumentExternal",
ID: InputMediaDocumentExternalTypeID,
}
if i == nil {
typ.Null = true
return typ
}
typ.Fields = []tdp.Field{
{
Name: "Spoiler",
SchemaName: "spoiler",
Null: !i.Flags.Has(1),
},
{
Name: "URL",
SchemaName: "url",
},
{
Name: "TTLSeconds",
SchemaName: "ttl_seconds",
Null: !i.Flags.Has(0),
},
{
Name: "VideoCover",
SchemaName: "video_cover",
Null: !i.Flags.Has(2),
},
{
Name: "VideoTimestamp",
SchemaName: "video_timestamp",
Null: !i.Flags.Has(3),
},
}
return typ
}
// SetFlags sets flags for non-zero fields.
func (i *InputMediaDocumentExternal) SetFlags() {
if !(i.Spoiler == false) {
i.Flags.Set(1)
}
if !(i.TTLSeconds == 0) {
i.Flags.Set(0)
}
if !(i.VideoCover == nil) {
i.Flags.Set(2)
}
if !(i.VideoTimestamp == 0) {
i.Flags.Set(3)
}
}
// Encode implements bin.Encoder.
func (i *InputMediaDocumentExternal) Encode(b *bin.Buffer) error {
if i == nil {
return fmt.Errorf("can't encode inputMediaDocumentExternal#779600f9 as nil")
}
b.PutID(InputMediaDocumentExternalTypeID)
return i.EncodeBare(b)
}
// EncodeBare implements bin.BareEncoder.
func (i *InputMediaDocumentExternal) EncodeBare(b *bin.Buffer) error {
if i == nil {
return fmt.Errorf("can't encode inputMediaDocumentExternal#779600f9 as nil")
}
i.SetFlags()
if err := i.Flags.Encode(b); err != nil {
return fmt.Errorf("unable to encode inputMediaDocumentExternal#779600f9: field flags: %w", err)
}
b.PutString(i.URL)
if i.Flags.Has(0) {
b.PutInt(i.TTLSeconds)
}
if i.Flags.Has(2) {
if i.VideoCover == nil {
return fmt.Errorf("unable to encode inputMediaDocumentExternal#779600f9: field video_cover is nil")
}
if err := i.VideoCover.Encode(b); err != nil {
return fmt.Errorf("unable to encode inputMediaDocumentExternal#779600f9: field video_cover: %w", err)
}
}
if i.Flags.Has(3) {
b.PutInt(i.VideoTimestamp)
}
return nil
}
// Decode implements bin.Decoder.
func (i *InputMediaDocumentExternal) Decode(b *bin.Buffer) error {
if i == nil {
return fmt.Errorf("can't decode inputMediaDocumentExternal#779600f9 to nil")
}
if err := b.ConsumeID(InputMediaDocumentExternalTypeID); err != nil {
return fmt.Errorf("unable to decode inputMediaDocumentExternal#779600f9: %w", err)
}
return i.DecodeBare(b)
}
// DecodeBare implements bin.BareDecoder.
func (i *InputMediaDocumentExternal) DecodeBare(b *bin.Buffer) error {
if i == nil {
return fmt.Errorf("can't decode inputMediaDocumentExternal#779600f9 to nil")
}
{
if err := i.Flags.Decode(b); err != nil {
return fmt.Errorf("unable to decode inputMediaDocumentExternal#779600f9: field flags: %w", err)
}
}
i.Spoiler = i.Flags.Has(1)
{
value, err := b.String()
if err != nil {
return fmt.Errorf("unable to decode inputMediaDocumentExternal#779600f9: field url: %w", err)
}
i.URL = value
}
if i.Flags.Has(0) {
value, err := b.Int()
if err != nil {
return fmt.Errorf("unable to decode inputMediaDocumentExternal#779600f9: field ttl_seconds: %w", err)
}
i.TTLSeconds = value
}
if i.Flags.Has(2) {
value, err := DecodeInputPhoto(b)
if err != nil {
return fmt.Errorf("unable to decode inputMediaDocumentExternal#779600f9: field video_cover: %w", err)
}
i.VideoCover = value
}
if i.Flags.Has(3) {
value, err := b.Int()
if err != nil {
return fmt.Errorf("unable to decode inputMediaDocumentExternal#779600f9: field video_timestamp: %w", err)
}
i.VideoTimestamp = value
}
return nil
}
// SetSpoiler sets value of Spoiler conditional field.
func (i *InputMediaDocumentExternal) SetSpoiler(value bool) {
if value {
i.Flags.Set(1)
i.Spoiler = true
} else {
i.Flags.Unset(1)
i.Spoiler = false
}
}
// GetSpoiler returns value of Spoiler conditional field.
func (i *InputMediaDocumentExternal) GetSpoiler() (value bool) {
if i == nil {
return
}
return i.Flags.Has(1)
}
// GetURL returns value of URL field.
func (i *InputMediaDocumentExternal) GetURL() (value string) {
if i == nil {
return
}
return i.URL
}
// SetTTLSeconds sets value of TTLSeconds conditional field.
func (i *InputMediaDocumentExternal) SetTTLSeconds(value int) {
i.Flags.Set(0)
i.TTLSeconds = value
}
// GetTTLSeconds returns value of TTLSeconds conditional field and
// boolean which is true if field was set.
func (i *InputMediaDocumentExternal) GetTTLSeconds() (value int, ok bool) {
if i == nil {
return
}
if !i.Flags.Has(0) {
return value, false
}
return i.TTLSeconds, true
}
// SetVideoCover sets value of VideoCover conditional field.
func (i *InputMediaDocumentExternal) SetVideoCover(value InputPhotoClass) {
i.Flags.Set(2)
i.VideoCover = value
}
// GetVideoCover returns value of VideoCover conditional field and
// boolean which is true if field was set.
func (i *InputMediaDocumentExternal) GetVideoCover() (value InputPhotoClass, ok bool) {
if i == nil {
return
}
if !i.Flags.Has(2) {
return value, false
}
return i.VideoCover, true
}
// SetVideoTimestamp sets value of VideoTimestamp conditional field.
func (i *InputMediaDocumentExternal) SetVideoTimestamp(value int) {
i.Flags.Set(3)
i.VideoTimestamp = value
}
// GetVideoTimestamp returns value of VideoTimestamp conditional field and
// boolean which is true if field was set.
func (i *InputMediaDocumentExternal) GetVideoTimestamp() (value int, ok bool) {
if i == nil {
return
}
if !i.Flags.Has(3) {
return value, false
}
return i.VideoTimestamp, true
}
// InputMediaGame represents TL type `inputMediaGame#d33f43f3`.
// A game
//
// See https://core.telegram.org/constructor/inputMediaGame for reference.
type InputMediaGame struct {
// The game to forward
ID InputGameClass
}
// InputMediaGameTypeID is TL type id of InputMediaGame.
const InputMediaGameTypeID = 0xd33f43f3
// construct implements constructor of InputMediaClass.
func (i InputMediaGame) construct() InputMediaClass { return &i }
// Ensuring interfaces in compile-time for InputMediaGame.
var (
_ bin.Encoder = &InputMediaGame{}
_ bin.Decoder = &InputMediaGame{}
_ bin.BareEncoder = &InputMediaGame{}
_ bin.BareDecoder = &InputMediaGame{}
_ InputMediaClass = &InputMediaGame{}
)
func (i *InputMediaGame) Zero() bool {
if i == nil {
return true
}
if !(i.ID == nil) {
return false
}
return true
}
// String implements fmt.Stringer.
func (i *InputMediaGame) String() string {
if i == nil {
return "InputMediaGame(nil)"
}
type Alias InputMediaGame
return fmt.Sprintf("InputMediaGame%+v", Alias(*i))
}
// FillFrom fills InputMediaGame from given interface.
func (i *InputMediaGame) FillFrom(from interface {
GetID() (value InputGameClass)
}) {
i.ID = from.GetID()
}
// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*InputMediaGame) TypeID() uint32 {
return InputMediaGameTypeID
}
// TypeName returns name of type in TL schema.
func (*InputMediaGame) TypeName() string {
return "inputMediaGame"
}
// TypeInfo returns info about TL type.
func (i *InputMediaGame) TypeInfo() tdp.Type {
typ := tdp.Type{
Name: "inputMediaGame",
ID: InputMediaGameTypeID,
}
if i == nil {
typ.Null = true
return typ
}
typ.Fields = []tdp.Field{
{
Name: "ID",
SchemaName: "id",
},
}
return typ
}
// Encode implements bin.Encoder.
func (i *InputMediaGame) Encode(b *bin.Buffer) error {
if i == nil {
return fmt.Errorf("can't encode inputMediaGame#d33f43f3 as nil")
}
b.PutID(InputMediaGameTypeID)
return i.EncodeBare(b)
}
// EncodeBare implements bin.BareEncoder.
func (i *InputMediaGame) EncodeBare(b *bin.Buffer) error {
if i == nil {
return fmt.Errorf("can't encode inputMediaGame#d33f43f3 as nil")
}
if i.ID == nil {
return fmt.Errorf("unable to encode inputMediaGame#d33f43f3: field id is nil")
}
if err := i.ID.Encode(b); err != nil {
return fmt.Errorf("unable to encode inputMediaGame#d33f43f3: field id: %w", err)
}
return nil
}
// Decode implements bin.Decoder.
func (i *InputMediaGame) Decode(b *bin.Buffer) error {
if i == nil {
return fmt.Errorf("can't decode inputMediaGame#d33f43f3 to nil")
}
if err := b.ConsumeID(InputMediaGameTypeID); err != nil {
return fmt.Errorf("unable to decode inputMediaGame#d33f43f3: %w", err)
}
return i.DecodeBare(b)
}
// DecodeBare implements bin.BareDecoder.
func (i *InputMediaGame) DecodeBare(b *bin.Buffer) error {
if i == nil {
return fmt.Errorf("can't decode inputMediaGame#d33f43f3 to nil")
}
{
value, err := DecodeInputGame(b)
if err != nil {
return fmt.Errorf("unable to decode inputMediaGame#d33f43f3: field id: %w", err)
}
i.ID = value
}
return nil
}
// GetID returns value of ID field.
func (i *InputMediaGame) GetID() (value InputGameClass) {
if i == nil {
return
}
return i.ID
}
// InputMediaInvoice represents TL type `inputMediaInvoice#405fef0d`.
// Generated invoice of a bot payment¹
//
// Links:
// 1. https://core.telegram.org/bots/payments
//
// See https://core.telegram.org/constructor/inputMediaInvoice for reference.
type InputMediaInvoice struct {
// Flags, see TL conditional fields¹
//
// Links:
// 1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
Flags bin.Fields
// Product name, 1-32 characters
Title string
// Product description, 1-255 characters
Description string
// URL of the product photo for the invoice. Can be a photo of the goods or a marketing
// image for a service. People like it better when they see what they are paying for.
//
// Use SetPhoto and GetPhoto helpers.
Photo InputWebDocument
// The actual invoice
Invoice Invoice
// Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, use
// for your internal processes.
Payload []byte
// Payments provider token, obtained via Botfather¹
//
// Links:
// 1) https://t.me/botfather
//
// Use SetProvider and GetProvider helpers.
Provider string
// JSON-encoded data about the invoice, which will be shared with the payment provider. A
// detailed description of required fields should be provided by the payment provider.
ProviderData DataJSON
// Unique bot deep links start parameter¹. If present, forwarded copies of the sent
// message will have a URL button with a deep link² to the bot (instead of a Pay button)
// with the value used as the start parameter. If absent, forwarded copies of the sent
// message will have a Pay button, allowing multiple users to pay directly from the
// forwarded message, using the same invoice.
//
// Links:
// 1) https://core.telegram.org/api/links#bot-links
// 2) https://core.telegram.org/api/links#bot-links
//
// Use SetStartParam and GetStartParam helpers.
StartParam string
// Deprecated
//
// Use SetExtendedMedia and GetExtendedMedia helpers.
ExtendedMedia InputMediaClass
}
// InputMediaInvoiceTypeID is TL type id of InputMediaInvoice.
const InputMediaInvoiceTypeID = 0x405fef0d
// construct implements constructor of InputMediaClass.
func (i InputMediaInvoice) construct() InputMediaClass { return &i }
// Ensuring interfaces in compile-time for InputMediaInvoice.
var (
_ bin.Encoder = &InputMediaInvoice{}
_ bin.Decoder = &InputMediaInvoice{}
_ bin.BareEncoder = &InputMediaInvoice{}
_ bin.BareDecoder = &InputMediaInvoice{}
_ InputMediaClass = &InputMediaInvoice{}
)
func (i *InputMediaInvoice) Zero() bool {
if i == nil {
return true
}
if !(i.Flags.Zero()) {
return false
}
if !(i.Title == "") {
return false
}
if !(i.Description == "") {
return false
}
if !(i.Photo.Zero()) {
return false
}
if !(i.Invoice.Zero()) {
return false
}
if !(i.Payload == nil) {
return false
}
if !(i.Provider == "") {
return false
}
if !(i.ProviderData.Zero()) {
return false
}
if !(i.StartParam == "") {
return false
}
if !(i.ExtendedMedia == nil) {
return false
}
return true
}
// String implements fmt.Stringer.
func (i *InputMediaInvoice) String() string {
if i == nil {
return "InputMediaInvoice(nil)"
}
type Alias InputMediaInvoice
return fmt.Sprintf("InputMediaInvoice%+v", Alias(*i))
}
// FillFrom fills InputMediaInvoice from given interface.
func (i *InputMediaInvoice) FillFrom(from interface {
GetTitle() (value string)
GetDescription() (value string)
GetPhoto() (value InputWebDocument, ok bool)
GetInvoice() (value Invoice)
GetPayload() (value []byte)
GetProvider() (value string, ok bool)
GetProviderData() (value DataJSON)
GetStartParam() (value string, ok bool)
GetExtendedMedia() (value InputMediaClass, ok bool)
}) {
i.Title = from.GetTitle()
i.Description = from.GetDescription()
if val, ok := from.GetPhoto(); ok {
i.Photo = val
}
i.Invoice = from.GetInvoice()
i.Payload = from.GetPayload()
if val, ok := from.GetProvider(); ok {
i.Provider = val
}
i.ProviderData = from.GetProviderData()
if val, ok := from.GetStartParam(); ok {
i.StartParam = val
}
if val, ok := from.GetExtendedMedia(); ok {
i.ExtendedMedia = val
}
}
// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*InputMediaInvoice) TypeID() uint32 {
return InputMediaInvoiceTypeID
}
// TypeName returns name of type in TL schema.
func (*InputMediaInvoice) TypeName() string {
return "inputMediaInvoice"
}
// TypeInfo returns info about TL type.
func (i *InputMediaInvoice) TypeInfo() tdp.Type {
typ := tdp.Type{
Name: "inputMediaInvoice",
ID: InputMediaInvoiceTypeID,
}
if i == nil {
typ.Null = true
return typ
}
typ.Fields = []tdp.Field{
{
Name: "Title",
SchemaName: "title",
},
{
Name: "Description",
SchemaName: "description",
},
{
Name: "Photo",
SchemaName: "photo",
Null: !i.Flags.Has(0),
},
{
Name: "Invoice",
SchemaName: "invoice",
},
{
Name: "Payload",
SchemaName: "payload",
},
{
Name: "Provider",
SchemaName: "provider",
Null: !i.Flags.Has(3),
},
{
Name: "ProviderData",
SchemaName: "provider_data",
},
{
Name: "StartParam",
SchemaName: "start_param",
Null: !i.Flags.Has(1),
},
{
Name: "ExtendedMedia",
SchemaName: "extended_media",
Null: !i.Flags.Has(2),
},
}
return typ
}
// SetFlags sets flags for non-zero fields.
func (i *InputMediaInvoice) SetFlags() {
if !(i.Photo.Zero()) {
i.Flags.Set(0)
}
if !(i.Provider == "") {
i.Flags.Set(3)
}
if !(i.StartParam == "") {
i.Flags.Set(1)
}
if !(i.ExtendedMedia == nil) {
i.Flags.Set(2)
}
}
// Encode implements bin.Encoder.
func (i *InputMediaInvoice) Encode(b *bin.Buffer) error {
if i == nil {
return fmt.Errorf("can't encode inputMediaInvoice#405fef0d as nil")
}
b.PutID(InputMediaInvoiceTypeID)
return i.EncodeBare(b)
}
// EncodeBare implements bin.BareEncoder.
func (i *InputMediaInvoice) EncodeBare(b *bin.Buffer) error {
if i == nil {
return fmt.Errorf("can't encode inputMediaInvoice#405fef0d as nil")
}
i.SetFlags()
if err := i.Flags.Encode(b); err != nil {
return fmt.Errorf("unable to encode inputMediaInvoice#405fef0d: field flags: %w", err)
}
b.PutString(i.Title)
b.PutString(i.Description)
if i.Flags.Has(0) {
if err := i.Photo.Encode(b); err != nil {
return fmt.Errorf("unable to encode inputMediaInvoice#405fef0d: field photo: %w", err)
}
}
if err := i.Invoice.Encode(b); err != nil {
return fmt.Errorf("unable to encode inputMediaInvoice#405fef0d: field invoice: %w", err)
}
b.PutBytes(i.Payload)
if i.Flags.Has(3) {
b.PutString(i.Provider)
}
if err := i.ProviderData.Encode(b); err != nil {
return fmt.Errorf("unable to encode inputMediaInvoice#405fef0d: field provider_data: %w", err)
}
if i.Flags.Has(1) {
b.PutString(i.StartParam)
}
if i.Flags.Has(2) {
if i.ExtendedMedia == nil {
return fmt.Errorf("unable to encode inputMediaInvoice#405fef0d: field extended_media is nil")
}
if err := i.ExtendedMedia.Encode(b); err != nil {
return fmt.Errorf("unable to encode inputMediaInvoice#405fef0d: field extended_media: %w", err)
}
}
return nil
}
// Decode implements bin.Decoder.
func (i *InputMediaInvoice) Decode(b *bin.Buffer) error {
if i == nil {
return fmt.Errorf("can't decode inputMediaInvoice#405fef0d to nil")
}
if err := b.ConsumeID(InputMediaInvoiceTypeID); err != nil {
return fmt.Errorf("unable to decode inputMediaInvoice#405fef0d: %w", err)
}
return i.DecodeBare(b)
}
// DecodeBare implements bin.BareDecoder.
func (i *InputMediaInvoice) DecodeBare(b *bin.Buffer) error {
if i == nil {
return fmt.Errorf("can't decode inputMediaInvoice#405fef0d to nil")
}
{
if err := i.Flags.Decode(b); err != nil {
return fmt.Errorf("unable to decode inputMediaInvoice#405fef0d: field flags: %w", err)
}
}
{
value, err := b.String()
if err != nil {
return fmt.Errorf("unable to decode inputMediaInvoice#405fef0d: field title: %w", err)
}
i.Title = value
}
{
value, err := b.String()
if err != nil {
return fmt.Errorf("unable to decode inputMediaInvoice#405fef0d: field description: %w", err)
}
i.Description = value
}
if i.Flags.Has(0) {
if err := i.Photo.Decode(b); err != nil {
return fmt.Errorf("unable to decode inputMediaInvoice#405fef0d: field photo: %w", err)
}
}
{
if err := i.Invoice.Decode(b); err != nil {
return fmt.Errorf("unable to decode inputMediaInvoice#405fef0d: field invoice: %w", err)
}
}
{
value, err := b.Bytes()
if err != nil {
return fmt.Errorf("unable to decode inputMediaInvoice#405fef0d: field payload: %w", err)
}
i.Payload = value
}
if i.Flags.Has(3) {
value, err := b.String()
if err != nil {
return fmt.Errorf("unable to decode inputMediaInvoice#405fef0d: field provider: %w", err)
}
i.Provider = value
}
{
if err := i.ProviderData.Decode(b); err != nil {
return fmt.Errorf("unable to decode inputMediaInvoice#405fef0d: field provider_data: %w", err)
}
}
if i.Flags.Has(1) {
value, err := b.String()
if err != nil {
return fmt.Errorf("unable to decode inputMediaInvoice#405fef0d: field start_param: %w", err)
}
i.StartParam = value
}
if i.Flags.Has(2) {
value, err := DecodeInputMedia(b)
if err != nil {
return fmt.Errorf("unable to decode inputMediaInvoice#405fef0d: field extended_media: %w", err)
}
i.ExtendedMedia = value
}
return nil
}
// GetTitle returns value of Title field.
func (i *InputMediaInvoice) GetTitle() (value string) {
if i == nil {
return
}
return i.Title
}
// GetDescription returns value of Description field.
func (i *InputMediaInvoice) GetDescription() (value string) {
if i == nil {
return
}
return i.Description
}
// SetPhoto sets value of Photo conditional field.
func (i *InputMediaInvoice) SetPhoto(value InputWebDocument) {
i.Flags.Set(0)
i.Photo = value
}
// GetPhoto returns value of Photo conditional field and
// boolean which is true if field was set.
func (i *InputMediaInvoice) GetPhoto() (value InputWebDocument, ok bool) {
if i == nil {
return
}
if !i.Flags.Has(0) {
return value, false
}
return i.Photo, true
}
// GetInvoice returns value of Invoice field.
func (i *InputMediaInvoice) GetInvoice() (value Invoice) {
if i == nil {
return
}
return i.Invoice
}
// GetPayload returns value of Payload field.
func (i *InputMediaInvoice) GetPayload() (value []byte) {
if i == nil {
return
}
return i.Payload
}
// SetProvider sets value of Provider conditional field.
func (i *InputMediaInvoice) SetProvider(value string) {
i.Flags.Set(3)
i.Provider = value
}
// GetProvider returns value of Provider conditional field and
// boolean which is true if field was set.
func (i *InputMediaInvoice) GetProvider() (value string, ok bool) {
if i == nil {
return
}
if !i.Flags.Has(3) {
return value, false
}
return i.Provider, true
}
// GetProviderData returns value of ProviderData field.
func (i *InputMediaInvoice) GetProviderData() (value DataJSON) {
if i == nil {
return
}
return i.ProviderData
}
// SetStartParam sets value of StartParam conditional field.
func (i *InputMediaInvoice) SetStartParam(value string) {
i.Flags.Set(1)
i.StartParam = value
}
// GetStartParam returns value of StartParam conditional field and
// boolean which is true if field was set.
func (i *InputMediaInvoice) GetStartParam() (value string, ok bool) {
if i == nil {
return
}
if !i.Flags.Has(1) {
return value, false
}
return i.StartParam, true
}
// SetExtendedMedia sets value of ExtendedMedia conditional field.
func (i *InputMediaInvoice) SetExtendedMedia(value InputMediaClass) {
i.Flags.Set(2)
i.ExtendedMedia = value
}
// GetExtendedMedia returns value of ExtendedMedia conditional field and
// boolean which is true if field was set.
func (i *InputMediaInvoice) GetExtendedMedia() (value InputMediaClass, ok bool) {
if i == nil {
return
}
if !i.Flags.Has(2) {
return value, false
}
return i.ExtendedMedia, true
}
// InputMediaGeoLive represents TL type `inputMediaGeoLive#971fa843`.
// Live geolocation¹
//
// Links:
// 1. https://core.telegram.org/api/live-location
//
// See https://core.telegram.org/constructor/inputMediaGeoLive for reference.
type InputMediaGeoLive struct {
// Flags, see TL conditional fields¹
//
// Links:
// 1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
Flags bin.Fields
// Whether sending of the geolocation was stopped
Stopped bool
// Current geolocation
GeoPoint InputGeoPointClass
// For live locations¹, a direction in which the location moves, in degrees; 1-360.
//
// Links:
// 1) https://core.telegram.org/api/live-location
//
// Use SetHeading and GetHeading helpers.
Heading int
// Validity period of the current location
//
// Use SetPeriod and GetPeriod helpers.
Period int
// For live locations¹, a maximum distance to another chat member for proximity alerts,
// in meters (0-100000)
//
// Links:
// 1) https://core.telegram.org/api/live-location
//
// Use SetProximityNotificationRadius and GetProximityNotificationRadius helpers.
ProximityNotificationRadius int
}
// InputMediaGeoLiveTypeID is TL type id of InputMediaGeoLive.
const InputMediaGeoLiveTypeID = 0x971fa843
// construct implements constructor of InputMediaClass.
func (i InputMediaGeoLive) construct() InputMediaClass { return &i }
// Ensuring interfaces in compile-time for InputMediaGeoLive.
var (
_ bin.Encoder = &InputMediaGeoLive{}
_ bin.Decoder = &InputMediaGeoLive{}
_ bin.BareEncoder = &InputMediaGeoLive{}
_ bin.BareDecoder = &InputMediaGeoLive{}
_ InputMediaClass = &InputMediaGeoLive{}
)
func (i *InputMediaGeoLive) Zero() bool {
if i == nil {
return true
}
if !(i.Flags.Zero()) {
return false
}
if !(i.Stopped == false) {
return false
}
if !(i.GeoPoint == nil) {
return false
}
if !(i.Heading == 0) {
return false
}
if !(i.Period == 0) {
return false
}
if !(i.ProximityNotificationRadius == 0) {
return false
}
return true
}
// String implements fmt.Stringer.
func (i *InputMediaGeoLive) String() string {
if i == nil {
return "InputMediaGeoLive(nil)"
}
type Alias InputMediaGeoLive
return fmt.Sprintf("InputMediaGeoLive%+v", Alias(*i))
}
// FillFrom fills InputMediaGeoLive from given interface.
func (i *InputMediaGeoLive) FillFrom(from interface {
GetStopped() (value bool)
GetGeoPoint() (value InputGeoPointClass)
GetHeading() (value int, ok bool)
GetPeriod() (value int, ok bool)
GetProximityNotificationRadius() (value int, ok bool)
}) {
i.Stopped = from.GetStopped()
i.GeoPoint = from.GetGeoPoint()
if val, ok := from.GetHeading(); ok {
i.Heading = val
}
if val, ok := from.GetPeriod(); ok {
i.Period = val
}
if val, ok := from.GetProximityNotificationRadius(); ok {
i.ProximityNotificationRadius = val
}
}
// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*InputMediaGeoLive) TypeID() uint32 {
return InputMediaGeoLiveTypeID
}
// TypeName returns name of type in TL schema.
func (*InputMediaGeoLive) TypeName() string {
return "inputMediaGeoLive"
}
// TypeInfo returns info about TL type.
func (i *InputMediaGeoLive) TypeInfo() tdp.Type {
typ := tdp.Type{
Name: "inputMediaGeoLive",
ID: InputMediaGeoLiveTypeID,
}
if i == nil {
typ.Null = true
return typ
}
typ.Fields = []tdp.Field{
{
Name: "Stopped",
SchemaName: "stopped",
Null: !i.Flags.Has(0),
},
{
Name: "GeoPoint",
SchemaName: "geo_point",
},
{
Name: "Heading",
SchemaName: "heading",
Null: !i.Flags.Has(2),
},
{
Name: "Period",
SchemaName: "period",
Null: !i.Flags.Has(1),
},
{
Name: "ProximityNotificationRadius",
SchemaName: "proximity_notification_radius",
Null: !i.Flags.Has(3),
},
}
return typ
}
// SetFlags sets flags for non-zero fields.
func (i *InputMediaGeoLive) SetFlags() {
if !(i.Stopped == false) {
i.Flags.Set(0)
}
if !(i.Heading == 0) {
i.Flags.Set(2)
}
if !(i.Period == 0) {
i.Flags.Set(1)
}
if !(i.ProximityNotificationRadius == 0) {
i.Flags.Set(3)
}
}
// Encode implements bin.Encoder.
func (i *InputMediaGeoLive) Encode(b *bin.Buffer) error {
if i == nil {
return fmt.Errorf("can't encode inputMediaGeoLive#971fa843 as nil")
}
b.PutID(InputMediaGeoLiveTypeID)
return i.EncodeBare(b)
}
// EncodeBare implements bin.BareEncoder.
func (i *InputMediaGeoLive) EncodeBare(b *bin.Buffer) error {
if i == nil {
return fmt.Errorf("can't encode inputMediaGeoLive#971fa843 as nil")
}
i.SetFlags()
if err := i.Flags.Encode(b); err != nil {
return fmt.Errorf("unable to encode inputMediaGeoLive#971fa843: field flags: %w", err)
}
if i.GeoPoint == nil {
return fmt.Errorf("unable to encode inputMediaGeoLive#971fa843: field geo_point is nil")
}
if err := i.GeoPoint.Encode(b); err != nil {
return fmt.Errorf("unable to encode inputMediaGeoLive#971fa843: field geo_point: %w", err)
}
if i.Flags.Has(2) {
b.PutInt(i.Heading)
}
if i.Flags.Has(1) {
b.PutInt(i.Period)
}
if i.Flags.Has(3) {
b.PutInt(i.ProximityNotificationRadius)
}
return nil
}
// Decode implements bin.Decoder.
func (i *InputMediaGeoLive) Decode(b *bin.Buffer) error {
if i == nil {
return fmt.Errorf("can't decode inputMediaGeoLive#971fa843 to nil")
}
if err := b.ConsumeID(InputMediaGeoLiveTypeID); err != nil {
return fmt.Errorf("unable to decode inputMediaGeoLive#971fa843: %w", err)
}
return i.DecodeBare(b)
}
// DecodeBare implements bin.BareDecoder.
func (i *InputMediaGeoLive) DecodeBare(b *bin.Buffer) error {
if i == nil {
return fmt.Errorf("can't decode inputMediaGeoLive#971fa843 to nil")
}
{
if err := i.Flags.Decode(b); err != nil {
return fmt.Errorf("unable to decode inputMediaGeoLive#971fa843: field flags: %w", err)
}
}
i.Stopped = i.Flags.Has(0)
{
value, err := DecodeInputGeoPoint(b)
if err != nil {
return fmt.Errorf("unable to decode inputMediaGeoLive#971fa843: field geo_point: %w", err)
}
i.GeoPoint = value
}
if i.Flags.Has(2) {
value, err := b.Int()
if err != nil {
return fmt.Errorf("unable to decode inputMediaGeoLive#971fa843: field heading: %w", err)
}
i.Heading = value
}
if i.Flags.Has(1) {
value, err := b.Int()
if err != nil {
return fmt.Errorf("unable to decode inputMediaGeoLive#971fa843: field period: %w", err)
}
i.Period = value
}
if i.Flags.Has(3) {
value, err := b.Int()
if err != nil {
return fmt.Errorf("unable to decode inputMediaGeoLive#971fa843: field proximity_notification_radius: %w", err)
}
i.ProximityNotificationRadius = value
}
return nil
}
// SetStopped sets value of Stopped conditional field.
func (i *InputMediaGeoLive) SetStopped(value bool) {
if value {
i.Flags.Set(0)
i.Stopped = true
} else {
i.Flags.Unset(0)
i.Stopped = false
}
}
// GetStopped returns value of Stopped conditional field.
func (i *InputMediaGeoLive) GetStopped() (value bool) {
if i == nil {
return
}
return i.Flags.Has(0)
}
// GetGeoPoint returns value of GeoPoint field.
func (i *InputMediaGeoLive) GetGeoPoint() (value InputGeoPointClass) {
if i == nil {
return
}
return i.GeoPoint
}
// SetHeading sets value of Heading conditional field.
func (i *InputMediaGeoLive) SetHeading(value int) {
i.Flags.Set(2)
i.Heading = value
}
// GetHeading returns value of Heading conditional field and
// boolean which is true if field was set.
func (i *InputMediaGeoLive) GetHeading() (value int, ok bool) {
if i == nil {
return
}
if !i.Flags.Has(2) {
return value, false
}
return i.Heading, true
}
// SetPeriod sets value of Period conditional field.
func (i *InputMediaGeoLive) SetPeriod(value int) {
i.Flags.Set(1)
i.Period = value
}
// GetPeriod returns value of Period conditional field and
// boolean which is true if field was set.
func (i *InputMediaGeoLive) GetPeriod() (value int, ok bool) {
if i == nil {
return
}
if !i.Flags.Has(1) {
return value, false
}
return i.Period, true
}
// SetProximityNotificationRadius sets value of ProximityNotificationRadius conditional field.
func (i *InputMediaGeoLive) SetProximityNotificationRadius(value int) {
i.Flags.Set(3)
i.ProximityNotificationRadius = value
}
// GetProximityNotificationRadius returns value of ProximityNotificationRadius conditional field and
// boolean which is true if field was set.
func (i *InputMediaGeoLive) GetProximityNotificationRadius() (value int, ok bool) {
if i == nil {
return
}
if !i.Flags.Has(3) {
return value, false
}
return i.ProximityNotificationRadius, true
}
// InputMediaPoll represents TL type `inputMediaPoll#f94e5f1`.
// A poll
//
// See https://core.telegram.org/constructor/inputMediaPoll for reference.
type InputMediaPoll struct {
// Flags, see TL conditional fields¹
//
// Links:
// 1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
Flags bin.Fields
// The poll to send
Poll Poll
// Correct answer IDs (for quiz polls)
//
// Use SetCorrectAnswers and GetCorrectAnswers helpers.
CorrectAnswers [][]byte
// Explanation of quiz solution
//
// Use SetSolution and GetSolution helpers.
Solution string
// Message entities for styled text¹
//
// Links:
// 1) https://core.telegram.org/api/entities
//
// Use SetSolutionEntities and GetSolutionEntities helpers.
SolutionEntities []MessageEntityClass
}
// InputMediaPollTypeID is TL type id of InputMediaPoll.
const InputMediaPollTypeID = 0xf94e5f1
// construct implements constructor of InputMediaClass.
func (i InputMediaPoll) construct() InputMediaClass { return &i }
// Ensuring interfaces in compile-time for InputMediaPoll.
var (
_ bin.Encoder = &InputMediaPoll{}
_ bin.Decoder = &InputMediaPoll{}
_ bin.BareEncoder = &InputMediaPoll{}
_ bin.BareDecoder = &InputMediaPoll{}
_ InputMediaClass = &InputMediaPoll{}
)
func (i *InputMediaPoll) Zero() bool {
if i == nil {
return true
}
if !(i.Flags.Zero()) {
return false
}
if !(i.Poll.Zero()) {
return false
}
if !(i.CorrectAnswers == nil) {
return false
}
if !(i.Solution == "") {
return false
}
if !(i.SolutionEntities == nil) {
return false
}
return true
}
// String implements fmt.Stringer.
func (i *InputMediaPoll) String() string {
if i == nil {
return "InputMediaPoll(nil)"
}
type Alias InputMediaPoll
return fmt.Sprintf("InputMediaPoll%+v", Alias(*i))
}
// FillFrom fills InputMediaPoll from given interface.
func (i *InputMediaPoll) FillFrom(from interface {
GetPoll() (value Poll)
GetCorrectAnswers() (value [][]byte, ok bool)
GetSolution() (value string, ok bool)
GetSolutionEntities() (value []MessageEntityClass, ok bool)
}) {
i.Poll = from.GetPoll()
if val, ok := from.GetCorrectAnswers(); ok {
i.CorrectAnswers = val
}
if val, ok := from.GetSolution(); ok {
i.Solution = val
}
if val, ok := from.GetSolutionEntities(); ok {
i.SolutionEntities = val
}
}
// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*InputMediaPoll) TypeID() uint32 {
return InputMediaPollTypeID
}
// TypeName returns name of type in TL schema.
func (*InputMediaPoll) TypeName() string {
return "inputMediaPoll"
}
// TypeInfo returns info about TL type.
func (i *InputMediaPoll) TypeInfo() tdp.Type {
typ := tdp.Type{
Name: "inputMediaPoll",
ID: InputMediaPollTypeID,
}
if i == nil {
typ.Null = true
return typ
}
typ.Fields = []tdp.Field{
{
Name: "Poll",
SchemaName: "poll",
},
{
Name: "CorrectAnswers",
SchemaName: "correct_answers",
Null: !i.Flags.Has(0),
},
{
Name: "Solution",
SchemaName: "solution",
Null: !i.Flags.Has(1),
},
{
Name: "SolutionEntities",
SchemaName: "solution_entities",
Null: !i.Flags.Has(1),
},
}
return typ
}
// SetFlags sets flags for non-zero fields.
func (i *InputMediaPoll) SetFlags() {
if !(i.CorrectAnswers == nil) {
i.Flags.Set(0)
}
if !(i.Solution == "") {
i.Flags.Set(1)
}
if !(i.SolutionEntities == nil) {
i.Flags.Set(1)
}
}
// Encode implements bin.Encoder.
func (i *InputMediaPoll) Encode(b *bin.Buffer) error {
if i == nil {
return fmt.Errorf("can't encode inputMediaPoll#f94e5f1 as nil")
}
b.PutID(InputMediaPollTypeID)
return i.EncodeBare(b)
}
// EncodeBare implements bin.BareEncoder.
func (i *InputMediaPoll) EncodeBare(b *bin.Buffer) error {
if i == nil {
return fmt.Errorf("can't encode inputMediaPoll#f94e5f1 as nil")
}
i.SetFlags()
if err := i.Flags.Encode(b); err != nil {
return fmt.Errorf("unable to encode inputMediaPoll#f94e5f1: field flags: %w", err)
}
if err := i.Poll.Encode(b); err != nil {
return fmt.Errorf("unable to encode inputMediaPoll#f94e5f1: field poll: %w", err)
}
if i.Flags.Has(0) {
b.PutVectorHeader(len(i.CorrectAnswers))
for _, v := range i.CorrectAnswers {
b.PutBytes(v)
}
}
if i.Flags.Has(1) {
b.PutString(i.Solution)
}
if i.Flags.Has(1) {
b.PutVectorHeader(len(i.SolutionEntities))
for idx, v := range i.SolutionEntities {
if v == nil {
return fmt.Errorf("unable to encode inputMediaPoll#f94e5f1: field solution_entities element with index %d is nil", idx)
}
if err := v.Encode(b); err != nil {
return fmt.Errorf("unable to encode inputMediaPoll#f94e5f1: field solution_entities element with index %d: %w", idx, err)
}
}
}
return nil
}
// Decode implements bin.Decoder.
func (i *InputMediaPoll) Decode(b *bin.Buffer) error {
if i == nil {
return fmt.Errorf("can't decode inputMediaPoll#f94e5f1 to nil")
}
if err := b.ConsumeID(InputMediaPollTypeID); err != nil {
return fmt.Errorf("unable to decode inputMediaPoll#f94e5f1: %w", err)
}
return i.DecodeBare(b)
}
// DecodeBare implements bin.BareDecoder.
func (i *InputMediaPoll) DecodeBare(b *bin.Buffer) error {
if i == nil {
return fmt.Errorf("can't decode inputMediaPoll#f94e5f1 to nil")
}
{
if err := i.Flags.Decode(b); err != nil {
return fmt.Errorf("unable to decode inputMediaPoll#f94e5f1: field flags: %w", err)
}
}
{
if err := i.Poll.Decode(b); err != nil {
return fmt.Errorf("unable to decode inputMediaPoll#f94e5f1: field poll: %w", err)
}
}
if i.Flags.Has(0) {
headerLen, err := b.VectorHeader()
if err != nil {
return fmt.Errorf("unable to decode inputMediaPoll#f94e5f1: field correct_answers: %w", err)
}
if headerLen > 0 {
i.CorrectAnswers = make([][]byte, 0, headerLen%bin.PreallocateLimit)
}
for idx := 0; idx < headerLen; idx++ {
value, err := b.Bytes()
if err != nil {
return fmt.Errorf("unable to decode inputMediaPoll#f94e5f1: field correct_answers: %w", err)
}
i.CorrectAnswers = append(i.CorrectAnswers, value)
}
}
if i.Flags.Has(1) {
value, err := b.String()
if err != nil {
return fmt.Errorf("unable to decode inputMediaPoll#f94e5f1: field solution: %w", err)
}
i.Solution = value
}
if i.Flags.Has(1) {
headerLen, err := b.VectorHeader()
if err != nil {
return fmt.Errorf("unable to decode inputMediaPoll#f94e5f1: field solution_entities: %w", err)
}
if headerLen > 0 {
i.SolutionEntities = make([]MessageEntityClass, 0, headerLen%bin.PreallocateLimit)
}
for idx := 0; idx < headerLen; idx++ {
value, err := DecodeMessageEntity(b)
if err != nil {
return fmt.Errorf("unable to decode inputMediaPoll#f94e5f1: field solution_entities: %w", err)
}
i.SolutionEntities = append(i.SolutionEntities, value)
}
}
return nil
}
// GetPoll returns value of Poll field.
func (i *InputMediaPoll) GetPoll() (value Poll) {
if i == nil {
return
}
return i.Poll
}
// SetCorrectAnswers sets value of CorrectAnswers conditional field.
func (i *InputMediaPoll) SetCorrectAnswers(value [][]byte) {
i.Flags.Set(0)
i.CorrectAnswers = value
}
// GetCorrectAnswers returns value of CorrectAnswers conditional field and
// boolean which is true if field was set.
func (i *InputMediaPoll) GetCorrectAnswers() (value [][]byte, ok bool) {
if i == nil {
return
}
if !i.Flags.Has(0) {
return value, false
}
return i.CorrectAnswers, true
}
// SetSolution sets value of Solution conditional field.
func (i *InputMediaPoll) SetSolution(value string) {
i.Flags.Set(1)
i.Solution = value
}
// GetSolution returns value of Solution conditional field and
// boolean which is true if field was set.
func (i *InputMediaPoll) GetSolution() (value string, ok bool) {
if i == nil {
return
}
if !i.Flags.Has(1) {
return value, false
}
return i.Solution, true
}
// SetSolutionEntities sets value of SolutionEntities conditional field.
func (i *InputMediaPoll) SetSolutionEntities(value []MessageEntityClass) {
i.Flags.Set(1)
i.SolutionEntities = value
}
// GetSolutionEntities returns value of SolutionEntities conditional field and
// boolean which is true if field was set.
func (i *InputMediaPoll) GetSolutionEntities() (value []MessageEntityClass, ok bool) {
if i == nil {
return
}
if !i.Flags.Has(1) {
return value, false
}
return i.SolutionEntities, true
}
// MapSolutionEntities returns field SolutionEntities wrapped in MessageEntityClassArray helper.
func (i *InputMediaPoll) MapSolutionEntities() (value MessageEntityClassArray, ok bool) {
if !i.Flags.Has(1) {
return value, false
}
return MessageEntityClassArray(i.SolutionEntities), true
}
// InputMediaDice represents TL type `inputMediaDice#e66fbf7b`.
// Send a dice-based animated sticker¹
//
// Links:
// 1. https://core.telegram.org/api/dice
//
// See https://core.telegram.org/constructor/inputMediaDice for reference.
type InputMediaDice struct {
// The emoji, for now , and are supported
Emoticon string
}
// InputMediaDiceTypeID is TL type id of InputMediaDice.
const InputMediaDiceTypeID = 0xe66fbf7b
// construct implements constructor of InputMediaClass.
func (i InputMediaDice) construct() InputMediaClass { return &i }
// Ensuring interfaces in compile-time for InputMediaDice.
var (
_ bin.Encoder = &InputMediaDice{}
_ bin.Decoder = &InputMediaDice{}
_ bin.BareEncoder = &InputMediaDice{}
_ bin.BareDecoder = &InputMediaDice{}
_ InputMediaClass = &InputMediaDice{}
)
func (i *InputMediaDice) Zero() bool {
if i == nil {
return true
}
if !(i.Emoticon == "") {
return false
}
return true
}
// String implements fmt.Stringer.
func (i *InputMediaDice) String() string {
if i == nil {
return "InputMediaDice(nil)"
}
type Alias InputMediaDice
return fmt.Sprintf("InputMediaDice%+v", Alias(*i))
}
// FillFrom fills InputMediaDice from given interface.
func (i *InputMediaDice) FillFrom(from interface {
GetEmoticon() (value string)
}) {
i.Emoticon = from.GetEmoticon()
}
// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*InputMediaDice) TypeID() uint32 {
return InputMediaDiceTypeID
}
// TypeName returns name of type in TL schema.
func (*InputMediaDice) TypeName() string {
return "inputMediaDice"
}
// TypeInfo returns info about TL type.
func (i *InputMediaDice) TypeInfo() tdp.Type {
typ := tdp.Type{
Name: "inputMediaDice",
ID: InputMediaDiceTypeID,
}
if i == nil {
typ.Null = true
return typ
}
typ.Fields = []tdp.Field{
{
Name: "Emoticon",
SchemaName: "emoticon",
},
}
return typ
}
// Encode implements bin.Encoder.
func (i *InputMediaDice) Encode(b *bin.Buffer) error {
if i == nil {
return fmt.Errorf("can't encode inputMediaDice#e66fbf7b as nil")
}
b.PutID(InputMediaDiceTypeID)
return i.EncodeBare(b)
}
// EncodeBare implements bin.BareEncoder.
func (i *InputMediaDice) EncodeBare(b *bin.Buffer) error {
if i == nil {
return fmt.Errorf("can't encode inputMediaDice#e66fbf7b as nil")
}
b.PutString(i.Emoticon)
return nil
}
// Decode implements bin.Decoder.
func (i *InputMediaDice) Decode(b *bin.Buffer) error {
if i == nil {
return fmt.Errorf("can't decode inputMediaDice#e66fbf7b to nil")
}
if err := b.ConsumeID(InputMediaDiceTypeID); err != nil {
return fmt.Errorf("unable to decode inputMediaDice#e66fbf7b: %w", err)
}
return i.DecodeBare(b)
}
// DecodeBare implements bin.BareDecoder.
func (i *InputMediaDice) DecodeBare(b *bin.Buffer) error {
if i == nil {
return fmt.Errorf("can't decode inputMediaDice#e66fbf7b to nil")
}
{
value, err := b.String()
if err != nil {
return fmt.Errorf("unable to decode inputMediaDice#e66fbf7b: field emoticon: %w", err)
}
i.Emoticon = value
}
return nil
}
// GetEmoticon returns value of Emoticon field.
func (i *InputMediaDice) GetEmoticon() (value string) {
if i == nil {
return
}
return i.Emoticon
}
// InputMediaStory represents TL type `inputMediaStory#89fdd778`.
// Forwarded story
//
// See https://core.telegram.org/constructor/inputMediaStory for reference.
type InputMediaStory struct {
// Peer where the story was posted
Peer InputPeerClass
// Story ID
ID int
}
// InputMediaStoryTypeID is TL type id of InputMediaStory.
const InputMediaStoryTypeID = 0x89fdd778
// construct implements constructor of InputMediaClass.
func (i InputMediaStory) construct() InputMediaClass { return &i }
// Ensuring interfaces in compile-time for InputMediaStory.
var (
_ bin.Encoder = &InputMediaStory{}
_ bin.Decoder = &InputMediaStory{}
_ bin.BareEncoder = &InputMediaStory{}
_ bin.BareDecoder = &InputMediaStory{}
_ InputMediaClass = &InputMediaStory{}
)
func (i *InputMediaStory) Zero() bool {
if i == nil {
return true
}
if !(i.Peer == nil) {
return false
}
if !(i.ID == 0) {
return false
}
return true
}
// String implements fmt.Stringer.
func (i *InputMediaStory) String() string {
if i == nil {
return "InputMediaStory(nil)"
}
type Alias InputMediaStory
return fmt.Sprintf("InputMediaStory%+v", Alias(*i))
}
// FillFrom fills InputMediaStory from given interface.
func (i *InputMediaStory) FillFrom(from interface {
GetPeer() (value InputPeerClass)
GetID() (value int)
}) {
i.Peer = from.GetPeer()
i.ID = from.GetID()
}
// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*InputMediaStory) TypeID() uint32 {
return InputMediaStoryTypeID
}
// TypeName returns name of type in TL schema.
func (*InputMediaStory) TypeName() string {
return "inputMediaStory"
}
// TypeInfo returns info about TL type.
func (i *InputMediaStory) TypeInfo() tdp.Type {
typ := tdp.Type{
Name: "inputMediaStory",
ID: InputMediaStoryTypeID,
}
if i == nil {
typ.Null = true
return typ
}
typ.Fields = []tdp.Field{
{
Name: "Peer",
SchemaName: "peer",
},
{
Name: "ID",
SchemaName: "id",
},
}
return typ
}
// Encode implements bin.Encoder.
func (i *InputMediaStory) Encode(b *bin.Buffer) error {
if i == nil {
return fmt.Errorf("can't encode inputMediaStory#89fdd778 as nil")
}
b.PutID(InputMediaStoryTypeID)
return i.EncodeBare(b)
}
// EncodeBare implements bin.BareEncoder.
func (i *InputMediaStory) EncodeBare(b *bin.Buffer) error {
if i == nil {
return fmt.Errorf("can't encode inputMediaStory#89fdd778 as nil")
}
if i.Peer == nil {
return fmt.Errorf("unable to encode inputMediaStory#89fdd778: field peer is nil")
}
if err := i.Peer.Encode(b); err != nil {
return fmt.Errorf("unable to encode inputMediaStory#89fdd778: field peer: %w", err)
}
b.PutInt(i.ID)
return nil
}
// Decode implements bin.Decoder.
func (i *InputMediaStory) Decode(b *bin.Buffer) error {
if i == nil {
return fmt.Errorf("can't decode inputMediaStory#89fdd778 to nil")
}
if err := b.ConsumeID(InputMediaStoryTypeID); err != nil {
return fmt.Errorf("unable to decode inputMediaStory#89fdd778: %w", err)
}
return i.DecodeBare(b)
}
// DecodeBare implements bin.BareDecoder.
func (i *InputMediaStory) DecodeBare(b *bin.Buffer) error {
if i == nil {
return fmt.Errorf("can't decode inputMediaStory#89fdd778 to nil")
}
{
value, err := DecodeInputPeer(b)
if err != nil {
return fmt.Errorf("unable to decode inputMediaStory#89fdd778: field peer: %w", err)
}
i.Peer = value
}
{
value, err := b.Int()
if err != nil {
return fmt.Errorf("unable to decode inputMediaStory#89fdd778: field id: %w", err)
}
i.ID = value
}
return nil
}
// GetPeer returns value of Peer field.
func (i *InputMediaStory) GetPeer() (value InputPeerClass) {
if i == nil {
return
}
return i.Peer
}
// GetID returns value of ID field.
func (i *InputMediaStory) GetID() (value int) {
if i == nil {
return
}
return i.ID
}
// InputMediaWebPage represents TL type `inputMediaWebPage#c21b8849`.
// Specifies options that will be used to generate the link preview for the caption, or
// even a standalone link preview without an attached message.
//
// See https://core.telegram.org/constructor/inputMediaWebPage for reference.
type InputMediaWebPage struct {
// Flags, see TL conditional fields¹
//
// Links:
// 1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
Flags bin.Fields
// If set, specifies that a large media preview should be used.
ForceLargeMedia bool
// If set, specifies that a small media preview should be used.
ForceSmallMedia bool
// If not set, a WEBPAGE_NOT_FOUND RPC error will be emitted if a webpage preview cannot
// be generated for the specified url; otherwise, no error will be emitted (unless the
// provided message is also empty, in which case a MESSAGE_EMPTY will be emitted,
// instead).
Optional bool
// The URL to use for the link preview.
URL string
}
// InputMediaWebPageTypeID is TL type id of InputMediaWebPage.
const InputMediaWebPageTypeID = 0xc21b8849
// construct implements constructor of InputMediaClass.
func (i InputMediaWebPage) construct() InputMediaClass { return &i }
// Ensuring interfaces in compile-time for InputMediaWebPage.
var (
_ bin.Encoder = &InputMediaWebPage{}
_ bin.Decoder = &InputMediaWebPage{}
_ bin.BareEncoder = &InputMediaWebPage{}
_ bin.BareDecoder = &InputMediaWebPage{}
_ InputMediaClass = &InputMediaWebPage{}
)
func (i *InputMediaWebPage) Zero() bool {
if i == nil {
return true
}
if !(i.Flags.Zero()) {
return false
}
if !(i.ForceLargeMedia == false) {
return false
}
if !(i.ForceSmallMedia == false) {
return false
}
if !(i.Optional == false) {
return false
}
if !(i.URL == "") {
return false
}
return true
}
// String implements fmt.Stringer.
func (i *InputMediaWebPage) String() string {
if i == nil {
return "InputMediaWebPage(nil)"
}
type Alias InputMediaWebPage
return fmt.Sprintf("InputMediaWebPage%+v", Alias(*i))
}
// FillFrom fills InputMediaWebPage from given interface.
func (i *InputMediaWebPage) FillFrom(from interface {
GetForceLargeMedia() (value bool)
GetForceSmallMedia() (value bool)
GetOptional() (value bool)
GetURL() (value string)
}) {
i.ForceLargeMedia = from.GetForceLargeMedia()
i.ForceSmallMedia = from.GetForceSmallMedia()
i.Optional = from.GetOptional()
i.URL = from.GetURL()
}
// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*InputMediaWebPage) TypeID() uint32 {
return InputMediaWebPageTypeID
}
// TypeName returns name of type in TL schema.
func (*InputMediaWebPage) TypeName() string {
return "inputMediaWebPage"
}
// TypeInfo returns info about TL type.
func (i *InputMediaWebPage) TypeInfo() tdp.Type {
typ := tdp.Type{
Name: "inputMediaWebPage",
ID: InputMediaWebPageTypeID,
}
if i == nil {
typ.Null = true
return typ
}
typ.Fields = []tdp.Field{
{
Name: "ForceLargeMedia",
SchemaName: "force_large_media",
Null: !i.Flags.Has(0),
},
{
Name: "ForceSmallMedia",
SchemaName: "force_small_media",
Null: !i.Flags.Has(1),
},
{
Name: "Optional",
SchemaName: "optional",
Null: !i.Flags.Has(2),
},
{
Name: "URL",
SchemaName: "url",
},
}
return typ
}
// SetFlags sets flags for non-zero fields.
func (i *InputMediaWebPage) SetFlags() {
if !(i.ForceLargeMedia == false) {
i.Flags.Set(0)
}
if !(i.ForceSmallMedia == false) {
i.Flags.Set(1)
}
if !(i.Optional == false) {
i.Flags.Set(2)
}
}
// Encode implements bin.Encoder.
func (i *InputMediaWebPage) Encode(b *bin.Buffer) error {
if i == nil {
return fmt.Errorf("can't encode inputMediaWebPage#c21b8849 as nil")
}
b.PutID(InputMediaWebPageTypeID)
return i.EncodeBare(b)
}
// EncodeBare implements bin.BareEncoder.
func (i *InputMediaWebPage) EncodeBare(b *bin.Buffer) error {
if i == nil {
return fmt.Errorf("can't encode inputMediaWebPage#c21b8849 as nil")
}
i.SetFlags()
if err := i.Flags.Encode(b); err != nil {
return fmt.Errorf("unable to encode inputMediaWebPage#c21b8849: field flags: %w", err)
}
b.PutString(i.URL)
return nil
}
// Decode implements bin.Decoder.
func (i *InputMediaWebPage) Decode(b *bin.Buffer) error {
if i == nil {
return fmt.Errorf("can't decode inputMediaWebPage#c21b8849 to nil")
}
if err := b.ConsumeID(InputMediaWebPageTypeID); err != nil {
return fmt.Errorf("unable to decode inputMediaWebPage#c21b8849: %w", err)
}
return i.DecodeBare(b)
}
// DecodeBare implements bin.BareDecoder.
func (i *InputMediaWebPage) DecodeBare(b *bin.Buffer) error {
if i == nil {
return fmt.Errorf("can't decode inputMediaWebPage#c21b8849 to nil")
}
{
if err := i.Flags.Decode(b); err != nil {
return fmt.Errorf("unable to decode inputMediaWebPage#c21b8849: field flags: %w", err)
}
}
i.ForceLargeMedia = i.Flags.Has(0)
i.ForceSmallMedia = i.Flags.Has(1)
i.Optional = i.Flags.Has(2)
{
value, err := b.String()
if err != nil {
return fmt.Errorf("unable to decode inputMediaWebPage#c21b8849: field url: %w", err)
}
i.URL = value
}
return nil
}
// SetForceLargeMedia sets value of ForceLargeMedia conditional field.
func (i *InputMediaWebPage) SetForceLargeMedia(value bool) {
if value {
i.Flags.Set(0)
i.ForceLargeMedia = true
} else {
i.Flags.Unset(0)
i.ForceLargeMedia = false
}
}
// GetForceLargeMedia returns value of ForceLargeMedia conditional field.
func (i *InputMediaWebPage) GetForceLargeMedia() (value bool) {
if i == nil {
return
}
return i.Flags.Has(0)
}
// SetForceSmallMedia sets value of ForceSmallMedia conditional field.
func (i *InputMediaWebPage) SetForceSmallMedia(value bool) {
if value {
i.Flags.Set(1)
i.ForceSmallMedia = true
} else {
i.Flags.Unset(1)
i.ForceSmallMedia = false
}
}
// GetForceSmallMedia returns value of ForceSmallMedia conditional field.
func (i *InputMediaWebPage) GetForceSmallMedia() (value bool) {
if i == nil {
return
}
return i.Flags.Has(1)
}
// SetOptional sets value of Optional conditional field.
func (i *InputMediaWebPage) SetOptional(value bool) {
if value {
i.Flags.Set(2)
i.Optional = true
} else {
i.Flags.Unset(2)
i.Optional = false
}
}
// GetOptional returns value of Optional conditional field.
func (i *InputMediaWebPage) GetOptional() (value bool) {
if i == nil {
return
}
return i.Flags.Has(2)
}
// GetURL returns value of URL field.
func (i *InputMediaWebPage) GetURL() (value string) {
if i == nil {
return
}
return i.URL
}
// InputMediaPaidMedia represents TL type `inputMediaPaidMedia#c4103386`.
// Paid media, see here »¹ for more info.
//
// Links:
// 1. https://core.telegram.org/api/paid-media
//
// See https://core.telegram.org/constructor/inputMediaPaidMedia for reference.
type InputMediaPaidMedia struct {
// Flags, see TL conditional fields¹
//
// Links:
// 1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
Flags bin.Fields
// The price of the media in Telegram Stars¹.
//
// Links:
// 1) https://core.telegram.org/api/stars
StarsAmount int64
// Photos or videos.
ExtendedMedia []InputMediaClass
// Bots only, specifies a custom payload that will then be passed in
// updateBotPurchasedPaidMedia¹ when a payment is made (this field will not be visible
// to the user)
//
// Links:
// 1) https://core.telegram.org/constructor/updateBotPurchasedPaidMedia
//
// Use SetPayload and GetPayload helpers.
Payload string
}
// InputMediaPaidMediaTypeID is TL type id of InputMediaPaidMedia.
const InputMediaPaidMediaTypeID = 0xc4103386
// construct implements constructor of InputMediaClass.
func (i InputMediaPaidMedia) construct() InputMediaClass { return &i }
// Ensuring interfaces in compile-time for InputMediaPaidMedia.
var (
_ bin.Encoder = &InputMediaPaidMedia{}
_ bin.Decoder = &InputMediaPaidMedia{}
_ bin.BareEncoder = &InputMediaPaidMedia{}
_ bin.BareDecoder = &InputMediaPaidMedia{}
_ InputMediaClass = &InputMediaPaidMedia{}
)
func (i *InputMediaPaidMedia) Zero() bool {
if i == nil {
return true
}
if !(i.Flags.Zero()) {
return false
}
if !(i.StarsAmount == 0) {
return false
}
if !(i.ExtendedMedia == nil) {
return false
}
if !(i.Payload == "") {
return false
}
return true
}
// String implements fmt.Stringer.
func (i *InputMediaPaidMedia) String() string {
if i == nil {
return "InputMediaPaidMedia(nil)"
}
type Alias InputMediaPaidMedia
return fmt.Sprintf("InputMediaPaidMedia%+v", Alias(*i))
}
// FillFrom fills InputMediaPaidMedia from given interface.
func (i *InputMediaPaidMedia) FillFrom(from interface {
GetStarsAmount() (value int64)
GetExtendedMedia() (value []InputMediaClass)
GetPayload() (value string, ok bool)
}) {
i.StarsAmount = from.GetStarsAmount()
i.ExtendedMedia = from.GetExtendedMedia()
if val, ok := from.GetPayload(); ok {
i.Payload = val
}
}
// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*InputMediaPaidMedia) TypeID() uint32 {
return InputMediaPaidMediaTypeID
}
// TypeName returns name of type in TL schema.
func (*InputMediaPaidMedia) TypeName() string {
return "inputMediaPaidMedia"
}
// TypeInfo returns info about TL type.
func (i *InputMediaPaidMedia) TypeInfo() tdp.Type {
typ := tdp.Type{
Name: "inputMediaPaidMedia",
ID: InputMediaPaidMediaTypeID,
}
if i == nil {
typ.Null = true
return typ
}
typ.Fields = []tdp.Field{
{
Name: "StarsAmount",
SchemaName: "stars_amount",
},
{
Name: "ExtendedMedia",
SchemaName: "extended_media",
},
{
Name: "Payload",
SchemaName: "payload",
Null: !i.Flags.Has(0),
},
}
return typ
}
// SetFlags sets flags for non-zero fields.
func (i *InputMediaPaidMedia) SetFlags() {
if !(i.Payload == "") {
i.Flags.Set(0)
}
}
// Encode implements bin.Encoder.
func (i *InputMediaPaidMedia) Encode(b *bin.Buffer) error {
if i == nil {
return fmt.Errorf("can't encode inputMediaPaidMedia#c4103386 as nil")
}
b.PutID(InputMediaPaidMediaTypeID)
return i.EncodeBare(b)
}
// EncodeBare implements bin.BareEncoder.
func (i *InputMediaPaidMedia) EncodeBare(b *bin.Buffer) error {
if i == nil {
return fmt.Errorf("can't encode inputMediaPaidMedia#c4103386 as nil")
}
i.SetFlags()
if err := i.Flags.Encode(b); err != nil {
return fmt.Errorf("unable to encode inputMediaPaidMedia#c4103386: field flags: %w", err)
}
b.PutLong(i.StarsAmount)
b.PutVectorHeader(len(i.ExtendedMedia))
for idx, v := range i.ExtendedMedia {
if v == nil {
return fmt.Errorf("unable to encode inputMediaPaidMedia#c4103386: field extended_media element with index %d is nil", idx)
}
if err := v.Encode(b); err != nil {
return fmt.Errorf("unable to encode inputMediaPaidMedia#c4103386: field extended_media element with index %d: %w", idx, err)
}
}
if i.Flags.Has(0) {
b.PutString(i.Payload)
}
return nil
}
// Decode implements bin.Decoder.
func (i *InputMediaPaidMedia) Decode(b *bin.Buffer) error {
if i == nil {
return fmt.Errorf("can't decode inputMediaPaidMedia#c4103386 to nil")
}
if err := b.ConsumeID(InputMediaPaidMediaTypeID); err != nil {
return fmt.Errorf("unable to decode inputMediaPaidMedia#c4103386: %w", err)
}
return i.DecodeBare(b)
}
// DecodeBare implements bin.BareDecoder.
func (i *InputMediaPaidMedia) DecodeBare(b *bin.Buffer) error {
if i == nil {
return fmt.Errorf("can't decode inputMediaPaidMedia#c4103386 to nil")
}
{
if err := i.Flags.Decode(b); err != nil {
return fmt.Errorf("unable to decode inputMediaPaidMedia#c4103386: field flags: %w", err)
}
}
{
value, err := b.Long()
if err != nil {
return fmt.Errorf("unable to decode inputMediaPaidMedia#c4103386: field stars_amount: %w", err)
}
i.StarsAmount = value
}
{
headerLen, err := b.VectorHeader()
if err != nil {
return fmt.Errorf("unable to decode inputMediaPaidMedia#c4103386: field extended_media: %w", err)
}
if headerLen > 0 {
i.ExtendedMedia = make([]InputMediaClass, 0, headerLen%bin.PreallocateLimit)
}
for idx := 0; idx < headerLen; idx++ {
value, err := DecodeInputMedia(b)
if err != nil {
return fmt.Errorf("unable to decode inputMediaPaidMedia#c4103386: field extended_media: %w", err)
}
i.ExtendedMedia = append(i.ExtendedMedia, value)
}
}
if i.Flags.Has(0) {
value, err := b.String()
if err != nil {
return fmt.Errorf("unable to decode inputMediaPaidMedia#c4103386: field payload: %w", err)
}
i.Payload = value
}
return nil
}
// GetStarsAmount returns value of StarsAmount field.
func (i *InputMediaPaidMedia) GetStarsAmount() (value int64) {
if i == nil {
return
}
return i.StarsAmount
}
// GetExtendedMedia returns value of ExtendedMedia field.
func (i *InputMediaPaidMedia) GetExtendedMedia() (value []InputMediaClass) {
if i == nil {
return
}
return i.ExtendedMedia
}
// SetPayload sets value of Payload conditional field.
func (i *InputMediaPaidMedia) SetPayload(value string) {
i.Flags.Set(0)
i.Payload = value
}
// GetPayload returns value of Payload conditional field and
// boolean which is true if field was set.
func (i *InputMediaPaidMedia) GetPayload() (value string, ok bool) {
if i == nil {
return
}
if !i.Flags.Has(0) {
return value, false
}
return i.Payload, true
}
// MapExtendedMedia returns field ExtendedMedia wrapped in InputMediaClassArray helper.
func (i *InputMediaPaidMedia) MapExtendedMedia() (value InputMediaClassArray) {
return InputMediaClassArray(i.ExtendedMedia)
}
// InputMediaClassName is schema name of InputMediaClass.
const InputMediaClassName = "InputMedia"
// InputMediaClass represents InputMedia generic type.
//
// See https://core.telegram.org/type/InputMedia for reference.
//
// Example:
//
// g, err := tg.DecodeInputMedia(buf)
// if err != nil {
// panic(err)
// }
// switch v := g.(type) {
// case *tg.InputMediaEmpty: // inputMediaEmpty#9664f57f
// case *tg.InputMediaUploadedPhoto: // inputMediaUploadedPhoto#1e287d04
// case *tg.InputMediaPhoto: // inputMediaPhoto#b3ba0635
// case *tg.InputMediaGeoPoint: // inputMediaGeoPoint#f9c44144
// case *tg.InputMediaContact: // inputMediaContact#f8ab7dfb
// case *tg.InputMediaUploadedDocument: // inputMediaUploadedDocument#37c9330
// case *tg.InputMediaDocument: // inputMediaDocument#a8763ab5
// case *tg.InputMediaVenue: // inputMediaVenue#c13d1c11
// case *tg.InputMediaPhotoExternal: // inputMediaPhotoExternal#e5bbfe1a
// case *tg.InputMediaDocumentExternal: // inputMediaDocumentExternal#779600f9
// case *tg.InputMediaGame: // inputMediaGame#d33f43f3
// case *tg.InputMediaInvoice: // inputMediaInvoice#405fef0d
// case *tg.InputMediaGeoLive: // inputMediaGeoLive#971fa843
// case *tg.InputMediaPoll: // inputMediaPoll#f94e5f1
// case *tg.InputMediaDice: // inputMediaDice#e66fbf7b
// case *tg.InputMediaStory: // inputMediaStory#89fdd778
// case *tg.InputMediaWebPage: // inputMediaWebPage#c21b8849
// case *tg.InputMediaPaidMedia: // inputMediaPaidMedia#c4103386
// default: panic(v)
// }
type InputMediaClass interface {
bin.Encoder
bin.Decoder
bin.BareEncoder
bin.BareDecoder
construct() InputMediaClass
// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
TypeID() uint32
// TypeName returns name of type in TL schema.
TypeName() string
// String implements fmt.Stringer.
String() string
// Zero returns true if current object has a zero value.
Zero() bool
}
// DecodeInputMedia implements binary de-serialization for InputMediaClass.
func DecodeInputMedia(buf *bin.Buffer) (InputMediaClass, error) {
id, err := buf.PeekID()
if err != nil {
return nil, err
}
switch id {
case InputMediaEmptyTypeID:
// Decoding inputMediaEmpty#9664f57f.
v := InputMediaEmpty{}
if err := v.Decode(buf); err != nil {
return nil, fmt.Errorf("unable to decode InputMediaClass: %w", err)
}
return &v, nil
case InputMediaUploadedPhotoTypeID:
// Decoding inputMediaUploadedPhoto#1e287d04.
v := InputMediaUploadedPhoto{}
if err := v.Decode(buf); err != nil {
return nil, fmt.Errorf("unable to decode InputMediaClass: %w", err)
}
return &v, nil
case InputMediaPhotoTypeID:
// Decoding inputMediaPhoto#b3ba0635.
v := InputMediaPhoto{}
if err := v.Decode(buf); err != nil {
return nil, fmt.Errorf("unable to decode InputMediaClass: %w", err)
}
return &v, nil
case InputMediaGeoPointTypeID:
// Decoding inputMediaGeoPoint#f9c44144.
v := InputMediaGeoPoint{}
if err := v.Decode(buf); err != nil {
return nil, fmt.Errorf("unable to decode InputMediaClass: %w", err)
}
return &v, nil
case InputMediaContactTypeID:
// Decoding inputMediaContact#f8ab7dfb.
v := InputMediaContact{}
if err := v.Decode(buf); err != nil {
return nil, fmt.Errorf("unable to decode InputMediaClass: %w", err)
}
return &v, nil
case InputMediaUploadedDocumentTypeID:
// Decoding inputMediaUploadedDocument#37c9330.
v := InputMediaUploadedDocument{}
if err := v.Decode(buf); err != nil {
return nil, fmt.Errorf("unable to decode InputMediaClass: %w", err)
}
return &v, nil
case InputMediaDocumentTypeID:
// Decoding inputMediaDocument#a8763ab5.
v := InputMediaDocument{}
if err := v.Decode(buf); err != nil {
return nil, fmt.Errorf("unable to decode InputMediaClass: %w", err)
}
return &v, nil
case InputMediaVenueTypeID:
// Decoding inputMediaVenue#c13d1c11.
v := InputMediaVenue{}
if err := v.Decode(buf); err != nil {
return nil, fmt.Errorf("unable to decode InputMediaClass: %w", err)
}
return &v, nil
case InputMediaPhotoExternalTypeID:
// Decoding inputMediaPhotoExternal#e5bbfe1a.
v := InputMediaPhotoExternal{}
if err := v.Decode(buf); err != nil {
return nil, fmt.Errorf("unable to decode InputMediaClass: %w", err)
}
return &v, nil
case InputMediaDocumentExternalTypeID:
// Decoding inputMediaDocumentExternal#779600f9.
v := InputMediaDocumentExternal{}
if err := v.Decode(buf); err != nil {
return nil, fmt.Errorf("unable to decode InputMediaClass: %w", err)
}
return &v, nil
case InputMediaGameTypeID:
// Decoding inputMediaGame#d33f43f3.
v := InputMediaGame{}
if err := v.Decode(buf); err != nil {
return nil, fmt.Errorf("unable to decode InputMediaClass: %w", err)
}
return &v, nil
case InputMediaInvoiceTypeID:
// Decoding inputMediaInvoice#405fef0d.
v := InputMediaInvoice{}
if err := v.Decode(buf); err != nil {
return nil, fmt.Errorf("unable to decode InputMediaClass: %w", err)
}
return &v, nil
case InputMediaGeoLiveTypeID:
// Decoding inputMediaGeoLive#971fa843.
v := InputMediaGeoLive{}
if err := v.Decode(buf); err != nil {
return nil, fmt.Errorf("unable to decode InputMediaClass: %w", err)
}
return &v, nil
case InputMediaPollTypeID:
// Decoding inputMediaPoll#f94e5f1.
v := InputMediaPoll{}
if err := v.Decode(buf); err != nil {
return nil, fmt.Errorf("unable to decode InputMediaClass: %w", err)
}
return &v, nil
case InputMediaDiceTypeID:
// Decoding inputMediaDice#e66fbf7b.
v := InputMediaDice{}
if err := v.Decode(buf); err != nil {
return nil, fmt.Errorf("unable to decode InputMediaClass: %w", err)
}
return &v, nil
case InputMediaStoryTypeID:
// Decoding inputMediaStory#89fdd778.
v := InputMediaStory{}
if err := v.Decode(buf); err != nil {
return nil, fmt.Errorf("unable to decode InputMediaClass: %w", err)
}
return &v, nil
case InputMediaWebPageTypeID:
// Decoding inputMediaWebPage#c21b8849.
v := InputMediaWebPage{}
if err := v.Decode(buf); err != nil {
return nil, fmt.Errorf("unable to decode InputMediaClass: %w", err)
}
return &v, nil
case InputMediaPaidMediaTypeID:
// Decoding inputMediaPaidMedia#c4103386.
v := InputMediaPaidMedia{}
if err := v.Decode(buf); err != nil {
return nil, fmt.Errorf("unable to decode InputMediaClass: %w", err)
}
return &v, nil
default:
return nil, fmt.Errorf("unable to decode InputMediaClass: %w", bin.NewUnexpectedID(id))
}
}
// InputMedia boxes the InputMediaClass providing a helper.
type InputMediaBox struct {
InputMedia InputMediaClass
}
// Decode implements bin.Decoder for InputMediaBox.
func (b *InputMediaBox) Decode(buf *bin.Buffer) error {
if b == nil {
return fmt.Errorf("unable to decode InputMediaBox to nil")
}
v, err := DecodeInputMedia(buf)
if err != nil {
return fmt.Errorf("unable to decode boxed value: %w", err)
}
b.InputMedia = v
return nil
}
// Encode implements bin.Encode for InputMediaBox.
func (b *InputMediaBox) Encode(buf *bin.Buffer) error {
if b == nil || b.InputMedia == nil {
return fmt.Errorf("unable to encode InputMediaClass as nil")
}
return b.InputMedia.Encode(buf)
}