// 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{} ) // InputBotInlineResult represents TL type `inputBotInlineResult#88bf9319`. // An inline bot result // // See https://core.telegram.org/constructor/inputBotInlineResult for reference. type InputBotInlineResult struct { // Flags, see TL conditional fields¹ // // Links: // 1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields Flags bin.Fields // ID of result ID string // Result type (see bot API docs¹) // // Links: // 1) https://core.telegram.org/bots/api#inlinequeryresult Type string // Result title // // Use SetTitle and GetTitle helpers. Title string // Result description // // Use SetDescription and GetDescription helpers. Description string // URL of result // // Use SetURL and GetURL helpers. URL string // Thumbnail for result // // Use SetThumb and GetThumb helpers. Thumb InputWebDocument // Result contents // // Use SetContent and GetContent helpers. Content InputWebDocument // Message to send when the result is selected SendMessage InputBotInlineMessageClass } // InputBotInlineResultTypeID is TL type id of InputBotInlineResult. const InputBotInlineResultTypeID = 0x88bf9319 // construct implements constructor of InputBotInlineResultClass. func (i InputBotInlineResult) construct() InputBotInlineResultClass { return &i } // Ensuring interfaces in compile-time for InputBotInlineResult. var ( _ bin.Encoder = &InputBotInlineResult{} _ bin.Decoder = &InputBotInlineResult{} _ bin.BareEncoder = &InputBotInlineResult{} _ bin.BareDecoder = &InputBotInlineResult{} _ InputBotInlineResultClass = &InputBotInlineResult{} ) func (i *InputBotInlineResult) Zero() bool { if i == nil { return true } if !(i.Flags.Zero()) { return false } if !(i.ID == "") { return false } if !(i.Type == "") { return false } if !(i.Title == "") { return false } if !(i.Description == "") { return false } if !(i.URL == "") { return false } if !(i.Thumb.Zero()) { return false } if !(i.Content.Zero()) { return false } if !(i.SendMessage == nil) { return false } return true } // String implements fmt.Stringer. func (i *InputBotInlineResult) String() string { if i == nil { return "InputBotInlineResult(nil)" } type Alias InputBotInlineResult return fmt.Sprintf("InputBotInlineResult%+v", Alias(*i)) } // FillFrom fills InputBotInlineResult from given interface. func (i *InputBotInlineResult) FillFrom(from interface { GetID() (value string) GetType() (value string) GetTitle() (value string, ok bool) GetDescription() (value string, ok bool) GetURL() (value string, ok bool) GetThumb() (value InputWebDocument, ok bool) GetContent() (value InputWebDocument, ok bool) GetSendMessage() (value InputBotInlineMessageClass) }) { i.ID = from.GetID() i.Type = from.GetType() if val, ok := from.GetTitle(); ok { i.Title = val } if val, ok := from.GetDescription(); ok { i.Description = val } if val, ok := from.GetURL(); ok { i.URL = val } if val, ok := from.GetThumb(); ok { i.Thumb = val } if val, ok := from.GetContent(); ok { i.Content = val } i.SendMessage = from.GetSendMessage() } // TypeID returns type id in TL schema. // // See https://core.telegram.org/mtproto/TL-tl#remarks. func (*InputBotInlineResult) TypeID() uint32 { return InputBotInlineResultTypeID } // TypeName returns name of type in TL schema. func (*InputBotInlineResult) TypeName() string { return "inputBotInlineResult" } // TypeInfo returns info about TL type. func (i *InputBotInlineResult) TypeInfo() tdp.Type { typ := tdp.Type{ Name: "inputBotInlineResult", ID: InputBotInlineResultTypeID, } if i == nil { typ.Null = true return typ } typ.Fields = []tdp.Field{ { Name: "ID", SchemaName: "id", }, { Name: "Type", SchemaName: "type", }, { Name: "Title", SchemaName: "title", Null: !i.Flags.Has(1), }, { Name: "Description", SchemaName: "description", Null: !i.Flags.Has(2), }, { Name: "URL", SchemaName: "url", Null: !i.Flags.Has(3), }, { Name: "Thumb", SchemaName: "thumb", Null: !i.Flags.Has(4), }, { Name: "Content", SchemaName: "content", Null: !i.Flags.Has(5), }, { Name: "SendMessage", SchemaName: "send_message", }, } return typ } // SetFlags sets flags for non-zero fields. func (i *InputBotInlineResult) SetFlags() { if !(i.Title == "") { i.Flags.Set(1) } if !(i.Description == "") { i.Flags.Set(2) } if !(i.URL == "") { i.Flags.Set(3) } if !(i.Thumb.Zero()) { i.Flags.Set(4) } if !(i.Content.Zero()) { i.Flags.Set(5) } } // Encode implements bin.Encoder. func (i *InputBotInlineResult) Encode(b *bin.Buffer) error { if i == nil { return fmt.Errorf("can't encode inputBotInlineResult#88bf9319 as nil") } b.PutID(InputBotInlineResultTypeID) return i.EncodeBare(b) } // EncodeBare implements bin.BareEncoder. func (i *InputBotInlineResult) EncodeBare(b *bin.Buffer) error { if i == nil { return fmt.Errorf("can't encode inputBotInlineResult#88bf9319 as nil") } i.SetFlags() if err := i.Flags.Encode(b); err != nil { return fmt.Errorf("unable to encode inputBotInlineResult#88bf9319: field flags: %w", err) } b.PutString(i.ID) b.PutString(i.Type) if i.Flags.Has(1) { b.PutString(i.Title) } if i.Flags.Has(2) { b.PutString(i.Description) } if i.Flags.Has(3) { b.PutString(i.URL) } if i.Flags.Has(4) { if err := i.Thumb.Encode(b); err != nil { return fmt.Errorf("unable to encode inputBotInlineResult#88bf9319: field thumb: %w", err) } } if i.Flags.Has(5) { if err := i.Content.Encode(b); err != nil { return fmt.Errorf("unable to encode inputBotInlineResult#88bf9319: field content: %w", err) } } if i.SendMessage == nil { return fmt.Errorf("unable to encode inputBotInlineResult#88bf9319: field send_message is nil") } if err := i.SendMessage.Encode(b); err != nil { return fmt.Errorf("unable to encode inputBotInlineResult#88bf9319: field send_message: %w", err) } return nil } // Decode implements bin.Decoder. func (i *InputBotInlineResult) Decode(b *bin.Buffer) error { if i == nil { return fmt.Errorf("can't decode inputBotInlineResult#88bf9319 to nil") } if err := b.ConsumeID(InputBotInlineResultTypeID); err != nil { return fmt.Errorf("unable to decode inputBotInlineResult#88bf9319: %w", err) } return i.DecodeBare(b) } // DecodeBare implements bin.BareDecoder. func (i *InputBotInlineResult) DecodeBare(b *bin.Buffer) error { if i == nil { return fmt.Errorf("can't decode inputBotInlineResult#88bf9319 to nil") } { if err := i.Flags.Decode(b); err != nil { return fmt.Errorf("unable to decode inputBotInlineResult#88bf9319: field flags: %w", err) } } { value, err := b.String() if err != nil { return fmt.Errorf("unable to decode inputBotInlineResult#88bf9319: field id: %w", err) } i.ID = value } { value, err := b.String() if err != nil { return fmt.Errorf("unable to decode inputBotInlineResult#88bf9319: field type: %w", err) } i.Type = value } if i.Flags.Has(1) { value, err := b.String() if err != nil { return fmt.Errorf("unable to decode inputBotInlineResult#88bf9319: field title: %w", err) } i.Title = value } if i.Flags.Has(2) { value, err := b.String() if err != nil { return fmt.Errorf("unable to decode inputBotInlineResult#88bf9319: field description: %w", err) } i.Description = value } if i.Flags.Has(3) { value, err := b.String() if err != nil { return fmt.Errorf("unable to decode inputBotInlineResult#88bf9319: field url: %w", err) } i.URL = value } if i.Flags.Has(4) { if err := i.Thumb.Decode(b); err != nil { return fmt.Errorf("unable to decode inputBotInlineResult#88bf9319: field thumb: %w", err) } } if i.Flags.Has(5) { if err := i.Content.Decode(b); err != nil { return fmt.Errorf("unable to decode inputBotInlineResult#88bf9319: field content: %w", err) } } { value, err := DecodeInputBotInlineMessage(b) if err != nil { return fmt.Errorf("unable to decode inputBotInlineResult#88bf9319: field send_message: %w", err) } i.SendMessage = value } return nil } // GetID returns value of ID field. func (i *InputBotInlineResult) GetID() (value string) { if i == nil { return } return i.ID } // GetType returns value of Type field. func (i *InputBotInlineResult) GetType() (value string) { if i == nil { return } return i.Type } // SetTitle sets value of Title conditional field. func (i *InputBotInlineResult) SetTitle(value string) { i.Flags.Set(1) i.Title = value } // GetTitle returns value of Title conditional field and // boolean which is true if field was set. func (i *InputBotInlineResult) GetTitle() (value string, ok bool) { if i == nil { return } if !i.Flags.Has(1) { return value, false } return i.Title, true } // SetDescription sets value of Description conditional field. func (i *InputBotInlineResult) SetDescription(value string) { i.Flags.Set(2) i.Description = value } // GetDescription returns value of Description conditional field and // boolean which is true if field was set. func (i *InputBotInlineResult) GetDescription() (value string, ok bool) { if i == nil { return } if !i.Flags.Has(2) { return value, false } return i.Description, true } // SetURL sets value of URL conditional field. func (i *InputBotInlineResult) SetURL(value string) { i.Flags.Set(3) i.URL = value } // GetURL returns value of URL conditional field and // boolean which is true if field was set. func (i *InputBotInlineResult) GetURL() (value string, ok bool) { if i == nil { return } if !i.Flags.Has(3) { return value, false } return i.URL, true } // SetThumb sets value of Thumb conditional field. func (i *InputBotInlineResult) SetThumb(value InputWebDocument) { i.Flags.Set(4) i.Thumb = value } // GetThumb returns value of Thumb conditional field and // boolean which is true if field was set. func (i *InputBotInlineResult) GetThumb() (value InputWebDocument, ok bool) { if i == nil { return } if !i.Flags.Has(4) { return value, false } return i.Thumb, true } // SetContent sets value of Content conditional field. func (i *InputBotInlineResult) SetContent(value InputWebDocument) { i.Flags.Set(5) i.Content = value } // GetContent returns value of Content conditional field and // boolean which is true if field was set. func (i *InputBotInlineResult) GetContent() (value InputWebDocument, ok bool) { if i == nil { return } if !i.Flags.Has(5) { return value, false } return i.Content, true } // GetSendMessage returns value of SendMessage field. func (i *InputBotInlineResult) GetSendMessage() (value InputBotInlineMessageClass) { if i == nil { return } return i.SendMessage } // InputBotInlineResultPhoto represents TL type `inputBotInlineResultPhoto#a8d864a7`. // Photo // // See https://core.telegram.org/constructor/inputBotInlineResultPhoto for reference. type InputBotInlineResultPhoto struct { // Result ID ID string // Result type (see bot API docs¹) // // Links: // 1) https://core.telegram.org/bots/api#inlinequeryresult Type string // Photo to send Photo InputPhotoClass // Message to send when the result is selected SendMessage InputBotInlineMessageClass } // InputBotInlineResultPhotoTypeID is TL type id of InputBotInlineResultPhoto. const InputBotInlineResultPhotoTypeID = 0xa8d864a7 // construct implements constructor of InputBotInlineResultClass. func (i InputBotInlineResultPhoto) construct() InputBotInlineResultClass { return &i } // Ensuring interfaces in compile-time for InputBotInlineResultPhoto. var ( _ bin.Encoder = &InputBotInlineResultPhoto{} _ bin.Decoder = &InputBotInlineResultPhoto{} _ bin.BareEncoder = &InputBotInlineResultPhoto{} _ bin.BareDecoder = &InputBotInlineResultPhoto{} _ InputBotInlineResultClass = &InputBotInlineResultPhoto{} ) func (i *InputBotInlineResultPhoto) Zero() bool { if i == nil { return true } if !(i.ID == "") { return false } if !(i.Type == "") { return false } if !(i.Photo == nil) { return false } if !(i.SendMessage == nil) { return false } return true } // String implements fmt.Stringer. func (i *InputBotInlineResultPhoto) String() string { if i == nil { return "InputBotInlineResultPhoto(nil)" } type Alias InputBotInlineResultPhoto return fmt.Sprintf("InputBotInlineResultPhoto%+v", Alias(*i)) } // FillFrom fills InputBotInlineResultPhoto from given interface. func (i *InputBotInlineResultPhoto) FillFrom(from interface { GetID() (value string) GetType() (value string) GetPhoto() (value InputPhotoClass) GetSendMessage() (value InputBotInlineMessageClass) }) { i.ID = from.GetID() i.Type = from.GetType() i.Photo = from.GetPhoto() i.SendMessage = from.GetSendMessage() } // TypeID returns type id in TL schema. // // See https://core.telegram.org/mtproto/TL-tl#remarks. func (*InputBotInlineResultPhoto) TypeID() uint32 { return InputBotInlineResultPhotoTypeID } // TypeName returns name of type in TL schema. func (*InputBotInlineResultPhoto) TypeName() string { return "inputBotInlineResultPhoto" } // TypeInfo returns info about TL type. func (i *InputBotInlineResultPhoto) TypeInfo() tdp.Type { typ := tdp.Type{ Name: "inputBotInlineResultPhoto", ID: InputBotInlineResultPhotoTypeID, } if i == nil { typ.Null = true return typ } typ.Fields = []tdp.Field{ { Name: "ID", SchemaName: "id", }, { Name: "Type", SchemaName: "type", }, { Name: "Photo", SchemaName: "photo", }, { Name: "SendMessage", SchemaName: "send_message", }, } return typ } // Encode implements bin.Encoder. func (i *InputBotInlineResultPhoto) Encode(b *bin.Buffer) error { if i == nil { return fmt.Errorf("can't encode inputBotInlineResultPhoto#a8d864a7 as nil") } b.PutID(InputBotInlineResultPhotoTypeID) return i.EncodeBare(b) } // EncodeBare implements bin.BareEncoder. func (i *InputBotInlineResultPhoto) EncodeBare(b *bin.Buffer) error { if i == nil { return fmt.Errorf("can't encode inputBotInlineResultPhoto#a8d864a7 as nil") } b.PutString(i.ID) b.PutString(i.Type) if i.Photo == nil { return fmt.Errorf("unable to encode inputBotInlineResultPhoto#a8d864a7: field photo is nil") } if err := i.Photo.Encode(b); err != nil { return fmt.Errorf("unable to encode inputBotInlineResultPhoto#a8d864a7: field photo: %w", err) } if i.SendMessage == nil { return fmt.Errorf("unable to encode inputBotInlineResultPhoto#a8d864a7: field send_message is nil") } if err := i.SendMessage.Encode(b); err != nil { return fmt.Errorf("unable to encode inputBotInlineResultPhoto#a8d864a7: field send_message: %w", err) } return nil } // Decode implements bin.Decoder. func (i *InputBotInlineResultPhoto) Decode(b *bin.Buffer) error { if i == nil { return fmt.Errorf("can't decode inputBotInlineResultPhoto#a8d864a7 to nil") } if err := b.ConsumeID(InputBotInlineResultPhotoTypeID); err != nil { return fmt.Errorf("unable to decode inputBotInlineResultPhoto#a8d864a7: %w", err) } return i.DecodeBare(b) } // DecodeBare implements bin.BareDecoder. func (i *InputBotInlineResultPhoto) DecodeBare(b *bin.Buffer) error { if i == nil { return fmt.Errorf("can't decode inputBotInlineResultPhoto#a8d864a7 to nil") } { value, err := b.String() if err != nil { return fmt.Errorf("unable to decode inputBotInlineResultPhoto#a8d864a7: field id: %w", err) } i.ID = value } { value, err := b.String() if err != nil { return fmt.Errorf("unable to decode inputBotInlineResultPhoto#a8d864a7: field type: %w", err) } i.Type = value } { value, err := DecodeInputPhoto(b) if err != nil { return fmt.Errorf("unable to decode inputBotInlineResultPhoto#a8d864a7: field photo: %w", err) } i.Photo = value } { value, err := DecodeInputBotInlineMessage(b) if err != nil { return fmt.Errorf("unable to decode inputBotInlineResultPhoto#a8d864a7: field send_message: %w", err) } i.SendMessage = value } return nil } // GetID returns value of ID field. func (i *InputBotInlineResultPhoto) GetID() (value string) { if i == nil { return } return i.ID } // GetType returns value of Type field. func (i *InputBotInlineResultPhoto) GetType() (value string) { if i == nil { return } return i.Type } // GetPhoto returns value of Photo field. func (i *InputBotInlineResultPhoto) GetPhoto() (value InputPhotoClass) { if i == nil { return } return i.Photo } // GetSendMessage returns value of SendMessage field. func (i *InputBotInlineResultPhoto) GetSendMessage() (value InputBotInlineMessageClass) { if i == nil { return } return i.SendMessage } // InputBotInlineResultDocument represents TL type `inputBotInlineResultDocument#fff8fdc4`. // Document (media of any type except for photos) // // See https://core.telegram.org/constructor/inputBotInlineResultDocument for reference. type InputBotInlineResultDocument struct { // Flags, see TL conditional fields¹ // // Links: // 1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields Flags bin.Fields // Result ID ID string // Result type (see bot API docs¹) // // Links: // 1) https://core.telegram.org/bots/api#inlinequeryresult Type string // Result title // // Use SetTitle and GetTitle helpers. Title string // Result description // // Use SetDescription and GetDescription helpers. Description string // Document to send Document InputDocumentClass // Message to send when the result is selected SendMessage InputBotInlineMessageClass } // InputBotInlineResultDocumentTypeID is TL type id of InputBotInlineResultDocument. const InputBotInlineResultDocumentTypeID = 0xfff8fdc4 // construct implements constructor of InputBotInlineResultClass. func (i InputBotInlineResultDocument) construct() InputBotInlineResultClass { return &i } // Ensuring interfaces in compile-time for InputBotInlineResultDocument. var ( _ bin.Encoder = &InputBotInlineResultDocument{} _ bin.Decoder = &InputBotInlineResultDocument{} _ bin.BareEncoder = &InputBotInlineResultDocument{} _ bin.BareDecoder = &InputBotInlineResultDocument{} _ InputBotInlineResultClass = &InputBotInlineResultDocument{} ) func (i *InputBotInlineResultDocument) Zero() bool { if i == nil { return true } if !(i.Flags.Zero()) { return false } if !(i.ID == "") { return false } if !(i.Type == "") { return false } if !(i.Title == "") { return false } if !(i.Description == "") { return false } if !(i.Document == nil) { return false } if !(i.SendMessage == nil) { return false } return true } // String implements fmt.Stringer. func (i *InputBotInlineResultDocument) String() string { if i == nil { return "InputBotInlineResultDocument(nil)" } type Alias InputBotInlineResultDocument return fmt.Sprintf("InputBotInlineResultDocument%+v", Alias(*i)) } // FillFrom fills InputBotInlineResultDocument from given interface. func (i *InputBotInlineResultDocument) FillFrom(from interface { GetID() (value string) GetType() (value string) GetTitle() (value string, ok bool) GetDescription() (value string, ok bool) GetDocument() (value InputDocumentClass) GetSendMessage() (value InputBotInlineMessageClass) }) { i.ID = from.GetID() i.Type = from.GetType() if val, ok := from.GetTitle(); ok { i.Title = val } if val, ok := from.GetDescription(); ok { i.Description = val } i.Document = from.GetDocument() i.SendMessage = from.GetSendMessage() } // TypeID returns type id in TL schema. // // See https://core.telegram.org/mtproto/TL-tl#remarks. func (*InputBotInlineResultDocument) TypeID() uint32 { return InputBotInlineResultDocumentTypeID } // TypeName returns name of type in TL schema. func (*InputBotInlineResultDocument) TypeName() string { return "inputBotInlineResultDocument" } // TypeInfo returns info about TL type. func (i *InputBotInlineResultDocument) TypeInfo() tdp.Type { typ := tdp.Type{ Name: "inputBotInlineResultDocument", ID: InputBotInlineResultDocumentTypeID, } if i == nil { typ.Null = true return typ } typ.Fields = []tdp.Field{ { Name: "ID", SchemaName: "id", }, { Name: "Type", SchemaName: "type", }, { Name: "Title", SchemaName: "title", Null: !i.Flags.Has(1), }, { Name: "Description", SchemaName: "description", Null: !i.Flags.Has(2), }, { Name: "Document", SchemaName: "document", }, { Name: "SendMessage", SchemaName: "send_message", }, } return typ } // SetFlags sets flags for non-zero fields. func (i *InputBotInlineResultDocument) SetFlags() { if !(i.Title == "") { i.Flags.Set(1) } if !(i.Description == "") { i.Flags.Set(2) } } // Encode implements bin.Encoder. func (i *InputBotInlineResultDocument) Encode(b *bin.Buffer) error { if i == nil { return fmt.Errorf("can't encode inputBotInlineResultDocument#fff8fdc4 as nil") } b.PutID(InputBotInlineResultDocumentTypeID) return i.EncodeBare(b) } // EncodeBare implements bin.BareEncoder. func (i *InputBotInlineResultDocument) EncodeBare(b *bin.Buffer) error { if i == nil { return fmt.Errorf("can't encode inputBotInlineResultDocument#fff8fdc4 as nil") } i.SetFlags() if err := i.Flags.Encode(b); err != nil { return fmt.Errorf("unable to encode inputBotInlineResultDocument#fff8fdc4: field flags: %w", err) } b.PutString(i.ID) b.PutString(i.Type) if i.Flags.Has(1) { b.PutString(i.Title) } if i.Flags.Has(2) { b.PutString(i.Description) } if i.Document == nil { return fmt.Errorf("unable to encode inputBotInlineResultDocument#fff8fdc4: field document is nil") } if err := i.Document.Encode(b); err != nil { return fmt.Errorf("unable to encode inputBotInlineResultDocument#fff8fdc4: field document: %w", err) } if i.SendMessage == nil { return fmt.Errorf("unable to encode inputBotInlineResultDocument#fff8fdc4: field send_message is nil") } if err := i.SendMessage.Encode(b); err != nil { return fmt.Errorf("unable to encode inputBotInlineResultDocument#fff8fdc4: field send_message: %w", err) } return nil } // Decode implements bin.Decoder. func (i *InputBotInlineResultDocument) Decode(b *bin.Buffer) error { if i == nil { return fmt.Errorf("can't decode inputBotInlineResultDocument#fff8fdc4 to nil") } if err := b.ConsumeID(InputBotInlineResultDocumentTypeID); err != nil { return fmt.Errorf("unable to decode inputBotInlineResultDocument#fff8fdc4: %w", err) } return i.DecodeBare(b) } // DecodeBare implements bin.BareDecoder. func (i *InputBotInlineResultDocument) DecodeBare(b *bin.Buffer) error { if i == nil { return fmt.Errorf("can't decode inputBotInlineResultDocument#fff8fdc4 to nil") } { if err := i.Flags.Decode(b); err != nil { return fmt.Errorf("unable to decode inputBotInlineResultDocument#fff8fdc4: field flags: %w", err) } } { value, err := b.String() if err != nil { return fmt.Errorf("unable to decode inputBotInlineResultDocument#fff8fdc4: field id: %w", err) } i.ID = value } { value, err := b.String() if err != nil { return fmt.Errorf("unable to decode inputBotInlineResultDocument#fff8fdc4: field type: %w", err) } i.Type = value } if i.Flags.Has(1) { value, err := b.String() if err != nil { return fmt.Errorf("unable to decode inputBotInlineResultDocument#fff8fdc4: field title: %w", err) } i.Title = value } if i.Flags.Has(2) { value, err := b.String() if err != nil { return fmt.Errorf("unable to decode inputBotInlineResultDocument#fff8fdc4: field description: %w", err) } i.Description = value } { value, err := DecodeInputDocument(b) if err != nil { return fmt.Errorf("unable to decode inputBotInlineResultDocument#fff8fdc4: field document: %w", err) } i.Document = value } { value, err := DecodeInputBotInlineMessage(b) if err != nil { return fmt.Errorf("unable to decode inputBotInlineResultDocument#fff8fdc4: field send_message: %w", err) } i.SendMessage = value } return nil } // GetID returns value of ID field. func (i *InputBotInlineResultDocument) GetID() (value string) { if i == nil { return } return i.ID } // GetType returns value of Type field. func (i *InputBotInlineResultDocument) GetType() (value string) { if i == nil { return } return i.Type } // SetTitle sets value of Title conditional field. func (i *InputBotInlineResultDocument) SetTitle(value string) { i.Flags.Set(1) i.Title = value } // GetTitle returns value of Title conditional field and // boolean which is true if field was set. func (i *InputBotInlineResultDocument) GetTitle() (value string, ok bool) { if i == nil { return } if !i.Flags.Has(1) { return value, false } return i.Title, true } // SetDescription sets value of Description conditional field. func (i *InputBotInlineResultDocument) SetDescription(value string) { i.Flags.Set(2) i.Description = value } // GetDescription returns value of Description conditional field and // boolean which is true if field was set. func (i *InputBotInlineResultDocument) GetDescription() (value string, ok bool) { if i == nil { return } if !i.Flags.Has(2) { return value, false } return i.Description, true } // GetDocument returns value of Document field. func (i *InputBotInlineResultDocument) GetDocument() (value InputDocumentClass) { if i == nil { return } return i.Document } // GetSendMessage returns value of SendMessage field. func (i *InputBotInlineResultDocument) GetSendMessage() (value InputBotInlineMessageClass) { if i == nil { return } return i.SendMessage } // InputBotInlineResultGame represents TL type `inputBotInlineResultGame#4fa417f2`. // Game // // See https://core.telegram.org/constructor/inputBotInlineResultGame for reference. type InputBotInlineResultGame struct { // Result ID ID string // Game short name ShortName string // Message to send when the result is selected SendMessage InputBotInlineMessageClass } // InputBotInlineResultGameTypeID is TL type id of InputBotInlineResultGame. const InputBotInlineResultGameTypeID = 0x4fa417f2 // construct implements constructor of InputBotInlineResultClass. func (i InputBotInlineResultGame) construct() InputBotInlineResultClass { return &i } // Ensuring interfaces in compile-time for InputBotInlineResultGame. var ( _ bin.Encoder = &InputBotInlineResultGame{} _ bin.Decoder = &InputBotInlineResultGame{} _ bin.BareEncoder = &InputBotInlineResultGame{} _ bin.BareDecoder = &InputBotInlineResultGame{} _ InputBotInlineResultClass = &InputBotInlineResultGame{} ) func (i *InputBotInlineResultGame) Zero() bool { if i == nil { return true } if !(i.ID == "") { return false } if !(i.ShortName == "") { return false } if !(i.SendMessage == nil) { return false } return true } // String implements fmt.Stringer. func (i *InputBotInlineResultGame) String() string { if i == nil { return "InputBotInlineResultGame(nil)" } type Alias InputBotInlineResultGame return fmt.Sprintf("InputBotInlineResultGame%+v", Alias(*i)) } // FillFrom fills InputBotInlineResultGame from given interface. func (i *InputBotInlineResultGame) FillFrom(from interface { GetID() (value string) GetShortName() (value string) GetSendMessage() (value InputBotInlineMessageClass) }) { i.ID = from.GetID() i.ShortName = from.GetShortName() i.SendMessage = from.GetSendMessage() } // TypeID returns type id in TL schema. // // See https://core.telegram.org/mtproto/TL-tl#remarks. func (*InputBotInlineResultGame) TypeID() uint32 { return InputBotInlineResultGameTypeID } // TypeName returns name of type in TL schema. func (*InputBotInlineResultGame) TypeName() string { return "inputBotInlineResultGame" } // TypeInfo returns info about TL type. func (i *InputBotInlineResultGame) TypeInfo() tdp.Type { typ := tdp.Type{ Name: "inputBotInlineResultGame", ID: InputBotInlineResultGameTypeID, } if i == nil { typ.Null = true return typ } typ.Fields = []tdp.Field{ { Name: "ID", SchemaName: "id", }, { Name: "ShortName", SchemaName: "short_name", }, { Name: "SendMessage", SchemaName: "send_message", }, } return typ } // Encode implements bin.Encoder. func (i *InputBotInlineResultGame) Encode(b *bin.Buffer) error { if i == nil { return fmt.Errorf("can't encode inputBotInlineResultGame#4fa417f2 as nil") } b.PutID(InputBotInlineResultGameTypeID) return i.EncodeBare(b) } // EncodeBare implements bin.BareEncoder. func (i *InputBotInlineResultGame) EncodeBare(b *bin.Buffer) error { if i == nil { return fmt.Errorf("can't encode inputBotInlineResultGame#4fa417f2 as nil") } b.PutString(i.ID) b.PutString(i.ShortName) if i.SendMessage == nil { return fmt.Errorf("unable to encode inputBotInlineResultGame#4fa417f2: field send_message is nil") } if err := i.SendMessage.Encode(b); err != nil { return fmt.Errorf("unable to encode inputBotInlineResultGame#4fa417f2: field send_message: %w", err) } return nil } // Decode implements bin.Decoder. func (i *InputBotInlineResultGame) Decode(b *bin.Buffer) error { if i == nil { return fmt.Errorf("can't decode inputBotInlineResultGame#4fa417f2 to nil") } if err := b.ConsumeID(InputBotInlineResultGameTypeID); err != nil { return fmt.Errorf("unable to decode inputBotInlineResultGame#4fa417f2: %w", err) } return i.DecodeBare(b) } // DecodeBare implements bin.BareDecoder. func (i *InputBotInlineResultGame) DecodeBare(b *bin.Buffer) error { if i == nil { return fmt.Errorf("can't decode inputBotInlineResultGame#4fa417f2 to nil") } { value, err := b.String() if err != nil { return fmt.Errorf("unable to decode inputBotInlineResultGame#4fa417f2: field id: %w", err) } i.ID = value } { value, err := b.String() if err != nil { return fmt.Errorf("unable to decode inputBotInlineResultGame#4fa417f2: field short_name: %w", err) } i.ShortName = value } { value, err := DecodeInputBotInlineMessage(b) if err != nil { return fmt.Errorf("unable to decode inputBotInlineResultGame#4fa417f2: field send_message: %w", err) } i.SendMessage = value } return nil } // GetID returns value of ID field. func (i *InputBotInlineResultGame) GetID() (value string) { if i == nil { return } return i.ID } // GetShortName returns value of ShortName field. func (i *InputBotInlineResultGame) GetShortName() (value string) { if i == nil { return } return i.ShortName } // GetSendMessage returns value of SendMessage field. func (i *InputBotInlineResultGame) GetSendMessage() (value InputBotInlineMessageClass) { if i == nil { return } return i.SendMessage } // InputBotInlineResultClassName is schema name of InputBotInlineResultClass. const InputBotInlineResultClassName = "InputBotInlineResult" // InputBotInlineResultClass represents InputBotInlineResult generic type. // // See https://core.telegram.org/type/InputBotInlineResult for reference. // // Example: // // g, err := tg.DecodeInputBotInlineResult(buf) // if err != nil { // panic(err) // } // switch v := g.(type) { // case *tg.InputBotInlineResult: // inputBotInlineResult#88bf9319 // case *tg.InputBotInlineResultPhoto: // inputBotInlineResultPhoto#a8d864a7 // case *tg.InputBotInlineResultDocument: // inputBotInlineResultDocument#fff8fdc4 // case *tg.InputBotInlineResultGame: // inputBotInlineResultGame#4fa417f2 // default: panic(v) // } type InputBotInlineResultClass interface { bin.Encoder bin.Decoder bin.BareEncoder bin.BareDecoder construct() InputBotInlineResultClass // 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 // ID of result GetID() (value string) // Message to send when the result is selected GetSendMessage() (value InputBotInlineMessageClass) } // DecodeInputBotInlineResult implements binary de-serialization for InputBotInlineResultClass. func DecodeInputBotInlineResult(buf *bin.Buffer) (InputBotInlineResultClass, error) { id, err := buf.PeekID() if err != nil { return nil, err } switch id { case InputBotInlineResultTypeID: // Decoding inputBotInlineResult#88bf9319. v := InputBotInlineResult{} if err := v.Decode(buf); err != nil { return nil, fmt.Errorf("unable to decode InputBotInlineResultClass: %w", err) } return &v, nil case InputBotInlineResultPhotoTypeID: // Decoding inputBotInlineResultPhoto#a8d864a7. v := InputBotInlineResultPhoto{} if err := v.Decode(buf); err != nil { return nil, fmt.Errorf("unable to decode InputBotInlineResultClass: %w", err) } return &v, nil case InputBotInlineResultDocumentTypeID: // Decoding inputBotInlineResultDocument#fff8fdc4. v := InputBotInlineResultDocument{} if err := v.Decode(buf); err != nil { return nil, fmt.Errorf("unable to decode InputBotInlineResultClass: %w", err) } return &v, nil case InputBotInlineResultGameTypeID: // Decoding inputBotInlineResultGame#4fa417f2. v := InputBotInlineResultGame{} if err := v.Decode(buf); err != nil { return nil, fmt.Errorf("unable to decode InputBotInlineResultClass: %w", err) } return &v, nil default: return nil, fmt.Errorf("unable to decode InputBotInlineResultClass: %w", bin.NewUnexpectedID(id)) } } // InputBotInlineResult boxes the InputBotInlineResultClass providing a helper. type InputBotInlineResultBox struct { InputBotInlineResult InputBotInlineResultClass } // Decode implements bin.Decoder for InputBotInlineResultBox. func (b *InputBotInlineResultBox) Decode(buf *bin.Buffer) error { if b == nil { return fmt.Errorf("unable to decode InputBotInlineResultBox to nil") } v, err := DecodeInputBotInlineResult(buf) if err != nil { return fmt.Errorf("unable to decode boxed value: %w", err) } b.InputBotInlineResult = v return nil } // Encode implements bin.Encode for InputBotInlineResultBox. func (b *InputBotInlineResultBox) Encode(buf *bin.Buffer) error { if b == nil || b.InputBotInlineResult == nil { return fmt.Errorf("unable to encode InputBotInlineResultClass as nil") } return b.InputBotInlineResult.Encode(buf) }