package tg
import (
"context"
"errors"
"fmt"
"sort"
"strings"
"go.uber.org/multierr"
"github.com/gotd/td/bin"
"github.com/gotd/td/tdjson"
"github.com/gotd/td/tdp"
"github.com/gotd/td/tgerr"
)
var (
_ = bin .Buffer {}
_ = context .Background ()
_ = fmt .Stringer (nil )
_ = strings .Builder {}
_ = errors .Is
_ = multierr .AppendInto
_ = sort .Ints
_ = tdp .Format
_ = tgerr .Error {}
_ = tdjson .Encoder {}
)
type StarGiftAttributeModel struct {
Flags bin .Fields
Crafted bool
Name string
Document DocumentClass
Rarity StarGiftAttributeRarityClass
}
const StarGiftAttributeModelTypeID = 0x565251e2
func (s StarGiftAttributeModel ) construct () StarGiftAttributeClass { return &s }
var (
_ bin .Encoder = &StarGiftAttributeModel {}
_ bin .Decoder = &StarGiftAttributeModel {}
_ bin .BareEncoder = &StarGiftAttributeModel {}
_ bin .BareDecoder = &StarGiftAttributeModel {}
_ StarGiftAttributeClass = &StarGiftAttributeModel {}
)
func (s *StarGiftAttributeModel ) Zero () bool {
if s == nil {
return true
}
if !(s .Flags .Zero ()) {
return false
}
if !(s .Crafted == false ) {
return false
}
if !(s .Name == "" ) {
return false
}
if !(s .Document == nil ) {
return false
}
if !(s .Rarity == nil ) {
return false
}
return true
}
func (s *StarGiftAttributeModel ) String () string {
if s == nil {
return "StarGiftAttributeModel(nil)"
}
type Alias StarGiftAttributeModel
return fmt .Sprintf ("StarGiftAttributeModel%+v" , Alias (*s ))
}
func (s *StarGiftAttributeModel ) FillFrom (from interface {
GetCrafted () (value bool )
GetName () (value string )
GetDocument () (value DocumentClass )
GetRarity () (value StarGiftAttributeRarityClass )
}) {
s .Crafted = from .GetCrafted ()
s .Name = from .GetName ()
s .Document = from .GetDocument ()
s .Rarity = from .GetRarity ()
}
func (*StarGiftAttributeModel ) TypeID () uint32 {
return StarGiftAttributeModelTypeID
}
func (*StarGiftAttributeModel ) TypeName () string {
return "starGiftAttributeModel"
}
func (s *StarGiftAttributeModel ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "starGiftAttributeModel" ,
ID : StarGiftAttributeModelTypeID ,
}
if s == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Crafted" ,
SchemaName : "crafted" ,
Null : !s .Flags .Has (0 ),
},
{
Name : "Name" ,
SchemaName : "name" ,
},
{
Name : "Document" ,
SchemaName : "document" ,
},
{
Name : "Rarity" ,
SchemaName : "rarity" ,
},
}
return typ
}
func (s *StarGiftAttributeModel ) SetFlags () {
if !(s .Crafted == false ) {
s .Flags .Set (0 )
}
}
func (s *StarGiftAttributeModel ) Encode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode starGiftAttributeModel#565251e2 as nil" )
}
b .PutID (StarGiftAttributeModelTypeID )
return s .EncodeBare (b )
}
func (s *StarGiftAttributeModel ) EncodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode starGiftAttributeModel#565251e2 as nil" )
}
s .SetFlags ()
if err := s .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode starGiftAttributeModel#565251e2: field flags: %w" , err )
}
b .PutString (s .Name )
if s .Document == nil {
return fmt .Errorf ("unable to encode starGiftAttributeModel#565251e2: field document is nil" )
}
if err := s .Document .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode starGiftAttributeModel#565251e2: field document: %w" , err )
}
if s .Rarity == nil {
return fmt .Errorf ("unable to encode starGiftAttributeModel#565251e2: field rarity is nil" )
}
if err := s .Rarity .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode starGiftAttributeModel#565251e2: field rarity: %w" , err )
}
return nil
}
func (s *StarGiftAttributeModel ) Decode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode starGiftAttributeModel#565251e2 to nil" )
}
if err := b .ConsumeID (StarGiftAttributeModelTypeID ); err != nil {
return fmt .Errorf ("unable to decode starGiftAttributeModel#565251e2: %w" , err )
}
return s .DecodeBare (b )
}
func (s *StarGiftAttributeModel ) DecodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode starGiftAttributeModel#565251e2 to nil" )
}
{
if err := s .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode starGiftAttributeModel#565251e2: field flags: %w" , err )
}
}
s .Crafted = s .Flags .Has (0 )
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode starGiftAttributeModel#565251e2: field name: %w" , err )
}
s .Name = value
}
{
value , err := DecodeDocument (b )
if err != nil {
return fmt .Errorf ("unable to decode starGiftAttributeModel#565251e2: field document: %w" , err )
}
s .Document = value
}
{
value , err := DecodeStarGiftAttributeRarity (b )
if err != nil {
return fmt .Errorf ("unable to decode starGiftAttributeModel#565251e2: field rarity: %w" , err )
}
s .Rarity = value
}
return nil
}
func (s *StarGiftAttributeModel ) SetCrafted (value bool ) {
if value {
s .Flags .Set (0 )
s .Crafted = true
} else {
s .Flags .Unset (0 )
s .Crafted = false
}
}
func (s *StarGiftAttributeModel ) GetCrafted () (value bool ) {
if s == nil {
return
}
return s .Flags .Has (0 )
}
func (s *StarGiftAttributeModel ) GetName () (value string ) {
if s == nil {
return
}
return s .Name
}
func (s *StarGiftAttributeModel ) GetDocument () (value DocumentClass ) {
if s == nil {
return
}
return s .Document
}
func (s *StarGiftAttributeModel ) GetRarity () (value StarGiftAttributeRarityClass ) {
if s == nil {
return
}
return s .Rarity
}
type StarGiftAttributePattern struct {
Name string
Document DocumentClass
Rarity StarGiftAttributeRarityClass
}
const StarGiftAttributePatternTypeID = 0x4e7085ea
func (s StarGiftAttributePattern ) construct () StarGiftAttributeClass { return &s }
var (
_ bin .Encoder = &StarGiftAttributePattern {}
_ bin .Decoder = &StarGiftAttributePattern {}
_ bin .BareEncoder = &StarGiftAttributePattern {}
_ bin .BareDecoder = &StarGiftAttributePattern {}
_ StarGiftAttributeClass = &StarGiftAttributePattern {}
)
func (s *StarGiftAttributePattern ) Zero () bool {
if s == nil {
return true
}
if !(s .Name == "" ) {
return false
}
if !(s .Document == nil ) {
return false
}
if !(s .Rarity == nil ) {
return false
}
return true
}
func (s *StarGiftAttributePattern ) String () string {
if s == nil {
return "StarGiftAttributePattern(nil)"
}
type Alias StarGiftAttributePattern
return fmt .Sprintf ("StarGiftAttributePattern%+v" , Alias (*s ))
}
func (s *StarGiftAttributePattern ) FillFrom (from interface {
GetName () (value string )
GetDocument () (value DocumentClass )
GetRarity () (value StarGiftAttributeRarityClass )
}) {
s .Name = from .GetName ()
s .Document = from .GetDocument ()
s .Rarity = from .GetRarity ()
}
func (*StarGiftAttributePattern ) TypeID () uint32 {
return StarGiftAttributePatternTypeID
}
func (*StarGiftAttributePattern ) TypeName () string {
return "starGiftAttributePattern"
}
func (s *StarGiftAttributePattern ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "starGiftAttributePattern" ,
ID : StarGiftAttributePatternTypeID ,
}
if s == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Name" ,
SchemaName : "name" ,
},
{
Name : "Document" ,
SchemaName : "document" ,
},
{
Name : "Rarity" ,
SchemaName : "rarity" ,
},
}
return typ
}
func (s *StarGiftAttributePattern ) Encode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode starGiftAttributePattern#4e7085ea as nil" )
}
b .PutID (StarGiftAttributePatternTypeID )
return s .EncodeBare (b )
}
func (s *StarGiftAttributePattern ) EncodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode starGiftAttributePattern#4e7085ea as nil" )
}
b .PutString (s .Name )
if s .Document == nil {
return fmt .Errorf ("unable to encode starGiftAttributePattern#4e7085ea: field document is nil" )
}
if err := s .Document .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode starGiftAttributePattern#4e7085ea: field document: %w" , err )
}
if s .Rarity == nil {
return fmt .Errorf ("unable to encode starGiftAttributePattern#4e7085ea: field rarity is nil" )
}
if err := s .Rarity .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode starGiftAttributePattern#4e7085ea: field rarity: %w" , err )
}
return nil
}
func (s *StarGiftAttributePattern ) Decode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode starGiftAttributePattern#4e7085ea to nil" )
}
if err := b .ConsumeID (StarGiftAttributePatternTypeID ); err != nil {
return fmt .Errorf ("unable to decode starGiftAttributePattern#4e7085ea: %w" , err )
}
return s .DecodeBare (b )
}
func (s *StarGiftAttributePattern ) DecodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode starGiftAttributePattern#4e7085ea to nil" )
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode starGiftAttributePattern#4e7085ea: field name: %w" , err )
}
s .Name = value
}
{
value , err := DecodeDocument (b )
if err != nil {
return fmt .Errorf ("unable to decode starGiftAttributePattern#4e7085ea: field document: %w" , err )
}
s .Document = value
}
{
value , err := DecodeStarGiftAttributeRarity (b )
if err != nil {
return fmt .Errorf ("unable to decode starGiftAttributePattern#4e7085ea: field rarity: %w" , err )
}
s .Rarity = value
}
return nil
}
func (s *StarGiftAttributePattern ) GetName () (value string ) {
if s == nil {
return
}
return s .Name
}
func (s *StarGiftAttributePattern ) GetDocument () (value DocumentClass ) {
if s == nil {
return
}
return s .Document
}
func (s *StarGiftAttributePattern ) GetRarity () (value StarGiftAttributeRarityClass ) {
if s == nil {
return
}
return s .Rarity
}
type StarGiftAttributeBackdrop struct {
Name string
BackdropID int
CenterColor int
EdgeColor int
PatternColor int
TextColor int
Rarity StarGiftAttributeRarityClass
}
const StarGiftAttributeBackdropTypeID = 0x9f2504e4
func (s StarGiftAttributeBackdrop ) construct () StarGiftAttributeClass { return &s }
var (
_ bin .Encoder = &StarGiftAttributeBackdrop {}
_ bin .Decoder = &StarGiftAttributeBackdrop {}
_ bin .BareEncoder = &StarGiftAttributeBackdrop {}
_ bin .BareDecoder = &StarGiftAttributeBackdrop {}
_ StarGiftAttributeClass = &StarGiftAttributeBackdrop {}
)
func (s *StarGiftAttributeBackdrop ) Zero () bool {
if s == nil {
return true
}
if !(s .Name == "" ) {
return false
}
if !(s .BackdropID == 0 ) {
return false
}
if !(s .CenterColor == 0 ) {
return false
}
if !(s .EdgeColor == 0 ) {
return false
}
if !(s .PatternColor == 0 ) {
return false
}
if !(s .TextColor == 0 ) {
return false
}
if !(s .Rarity == nil ) {
return false
}
return true
}
func (s *StarGiftAttributeBackdrop ) String () string {
if s == nil {
return "StarGiftAttributeBackdrop(nil)"
}
type Alias StarGiftAttributeBackdrop
return fmt .Sprintf ("StarGiftAttributeBackdrop%+v" , Alias (*s ))
}
func (s *StarGiftAttributeBackdrop ) FillFrom (from interface {
GetName () (value string )
GetBackdropID () (value int )
GetCenterColor () (value int )
GetEdgeColor () (value int )
GetPatternColor () (value int )
GetTextColor () (value int )
GetRarity () (value StarGiftAttributeRarityClass )
}) {
s .Name = from .GetName ()
s .BackdropID = from .GetBackdropID ()
s .CenterColor = from .GetCenterColor ()
s .EdgeColor = from .GetEdgeColor ()
s .PatternColor = from .GetPatternColor ()
s .TextColor = from .GetTextColor ()
s .Rarity = from .GetRarity ()
}
func (*StarGiftAttributeBackdrop ) TypeID () uint32 {
return StarGiftAttributeBackdropTypeID
}
func (*StarGiftAttributeBackdrop ) TypeName () string {
return "starGiftAttributeBackdrop"
}
func (s *StarGiftAttributeBackdrop ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "starGiftAttributeBackdrop" ,
ID : StarGiftAttributeBackdropTypeID ,
}
if s == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Name" ,
SchemaName : "name" ,
},
{
Name : "BackdropID" ,
SchemaName : "backdrop_id" ,
},
{
Name : "CenterColor" ,
SchemaName : "center_color" ,
},
{
Name : "EdgeColor" ,
SchemaName : "edge_color" ,
},
{
Name : "PatternColor" ,
SchemaName : "pattern_color" ,
},
{
Name : "TextColor" ,
SchemaName : "text_color" ,
},
{
Name : "Rarity" ,
SchemaName : "rarity" ,
},
}
return typ
}
func (s *StarGiftAttributeBackdrop ) Encode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode starGiftAttributeBackdrop#9f2504e4 as nil" )
}
b .PutID (StarGiftAttributeBackdropTypeID )
return s .EncodeBare (b )
}
func (s *StarGiftAttributeBackdrop ) EncodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode starGiftAttributeBackdrop#9f2504e4 as nil" )
}
b .PutString (s .Name )
b .PutInt (s .BackdropID )
b .PutInt (s .CenterColor )
b .PutInt (s .EdgeColor )
b .PutInt (s .PatternColor )
b .PutInt (s .TextColor )
if s .Rarity == nil {
return fmt .Errorf ("unable to encode starGiftAttributeBackdrop#9f2504e4: field rarity is nil" )
}
if err := s .Rarity .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode starGiftAttributeBackdrop#9f2504e4: field rarity: %w" , err )
}
return nil
}
func (s *StarGiftAttributeBackdrop ) Decode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode starGiftAttributeBackdrop#9f2504e4 to nil" )
}
if err := b .ConsumeID (StarGiftAttributeBackdropTypeID ); err != nil {
return fmt .Errorf ("unable to decode starGiftAttributeBackdrop#9f2504e4: %w" , err )
}
return s .DecodeBare (b )
}
func (s *StarGiftAttributeBackdrop ) DecodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode starGiftAttributeBackdrop#9f2504e4 to nil" )
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode starGiftAttributeBackdrop#9f2504e4: field name: %w" , err )
}
s .Name = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode starGiftAttributeBackdrop#9f2504e4: field backdrop_id: %w" , err )
}
s .BackdropID = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode starGiftAttributeBackdrop#9f2504e4: field center_color: %w" , err )
}
s .CenterColor = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode starGiftAttributeBackdrop#9f2504e4: field edge_color: %w" , err )
}
s .EdgeColor = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode starGiftAttributeBackdrop#9f2504e4: field pattern_color: %w" , err )
}
s .PatternColor = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode starGiftAttributeBackdrop#9f2504e4: field text_color: %w" , err )
}
s .TextColor = value
}
{
value , err := DecodeStarGiftAttributeRarity (b )
if err != nil {
return fmt .Errorf ("unable to decode starGiftAttributeBackdrop#9f2504e4: field rarity: %w" , err )
}
s .Rarity = value
}
return nil
}
func (s *StarGiftAttributeBackdrop ) GetName () (value string ) {
if s == nil {
return
}
return s .Name
}
func (s *StarGiftAttributeBackdrop ) GetBackdropID () (value int ) {
if s == nil {
return
}
return s .BackdropID
}
func (s *StarGiftAttributeBackdrop ) GetCenterColor () (value int ) {
if s == nil {
return
}
return s .CenterColor
}
func (s *StarGiftAttributeBackdrop ) GetEdgeColor () (value int ) {
if s == nil {
return
}
return s .EdgeColor
}
func (s *StarGiftAttributeBackdrop ) GetPatternColor () (value int ) {
if s == nil {
return
}
return s .PatternColor
}
func (s *StarGiftAttributeBackdrop ) GetTextColor () (value int ) {
if s == nil {
return
}
return s .TextColor
}
func (s *StarGiftAttributeBackdrop ) GetRarity () (value StarGiftAttributeRarityClass ) {
if s == nil {
return
}
return s .Rarity
}
type StarGiftAttributeOriginalDetails struct {
Flags bin .Fields
SenderID PeerClass
RecipientID PeerClass
Date int
Message TextWithEntities
}
const StarGiftAttributeOriginalDetailsTypeID = 0xe0bff26c
func (s StarGiftAttributeOriginalDetails ) construct () StarGiftAttributeClass { return &s }
var (
_ bin .Encoder = &StarGiftAttributeOriginalDetails {}
_ bin .Decoder = &StarGiftAttributeOriginalDetails {}
_ bin .BareEncoder = &StarGiftAttributeOriginalDetails {}
_ bin .BareDecoder = &StarGiftAttributeOriginalDetails {}
_ StarGiftAttributeClass = &StarGiftAttributeOriginalDetails {}
)
func (s *StarGiftAttributeOriginalDetails ) Zero () bool {
if s == nil {
return true
}
if !(s .Flags .Zero ()) {
return false
}
if !(s .SenderID == nil ) {
return false
}
if !(s .RecipientID == nil ) {
return false
}
if !(s .Date == 0 ) {
return false
}
if !(s .Message .Zero ()) {
return false
}
return true
}
func (s *StarGiftAttributeOriginalDetails ) String () string {
if s == nil {
return "StarGiftAttributeOriginalDetails(nil)"
}
type Alias StarGiftAttributeOriginalDetails
return fmt .Sprintf ("StarGiftAttributeOriginalDetails%+v" , Alias (*s ))
}
func (s *StarGiftAttributeOriginalDetails ) FillFrom (from interface {
GetSenderID () (value PeerClass , ok bool )
GetRecipientID () (value PeerClass )
GetDate () (value int )
GetMessage () (value TextWithEntities , ok bool )
}) {
if val , ok := from .GetSenderID (); ok {
s .SenderID = val
}
s .RecipientID = from .GetRecipientID ()
s .Date = from .GetDate ()
if val , ok := from .GetMessage (); ok {
s .Message = val
}
}
func (*StarGiftAttributeOriginalDetails ) TypeID () uint32 {
return StarGiftAttributeOriginalDetailsTypeID
}
func (*StarGiftAttributeOriginalDetails ) TypeName () string {
return "starGiftAttributeOriginalDetails"
}
func (s *StarGiftAttributeOriginalDetails ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "starGiftAttributeOriginalDetails" ,
ID : StarGiftAttributeOriginalDetailsTypeID ,
}
if s == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "SenderID" ,
SchemaName : "sender_id" ,
Null : !s .Flags .Has (0 ),
},
{
Name : "RecipientID" ,
SchemaName : "recipient_id" ,
},
{
Name : "Date" ,
SchemaName : "date" ,
},
{
Name : "Message" ,
SchemaName : "message" ,
Null : !s .Flags .Has (1 ),
},
}
return typ
}
func (s *StarGiftAttributeOriginalDetails ) SetFlags () {
if !(s .SenderID == nil ) {
s .Flags .Set (0 )
}
if !(s .Message .Zero ()) {
s .Flags .Set (1 )
}
}
func (s *StarGiftAttributeOriginalDetails ) Encode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode starGiftAttributeOriginalDetails#e0bff26c as nil" )
}
b .PutID (StarGiftAttributeOriginalDetailsTypeID )
return s .EncodeBare (b )
}
func (s *StarGiftAttributeOriginalDetails ) EncodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode starGiftAttributeOriginalDetails#e0bff26c as nil" )
}
s .SetFlags ()
if err := s .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode starGiftAttributeOriginalDetails#e0bff26c: field flags: %w" , err )
}
if s .Flags .Has (0 ) {
if s .SenderID == nil {
return fmt .Errorf ("unable to encode starGiftAttributeOriginalDetails#e0bff26c: field sender_id is nil" )
}
if err := s .SenderID .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode starGiftAttributeOriginalDetails#e0bff26c: field sender_id: %w" , err )
}
}
if s .RecipientID == nil {
return fmt .Errorf ("unable to encode starGiftAttributeOriginalDetails#e0bff26c: field recipient_id is nil" )
}
if err := s .RecipientID .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode starGiftAttributeOriginalDetails#e0bff26c: field recipient_id: %w" , err )
}
b .PutInt (s .Date )
if s .Flags .Has (1 ) {
if err := s .Message .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode starGiftAttributeOriginalDetails#e0bff26c: field message: %w" , err )
}
}
return nil
}
func (s *StarGiftAttributeOriginalDetails ) Decode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode starGiftAttributeOriginalDetails#e0bff26c to nil" )
}
if err := b .ConsumeID (StarGiftAttributeOriginalDetailsTypeID ); err != nil {
return fmt .Errorf ("unable to decode starGiftAttributeOriginalDetails#e0bff26c: %w" , err )
}
return s .DecodeBare (b )
}
func (s *StarGiftAttributeOriginalDetails ) DecodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode starGiftAttributeOriginalDetails#e0bff26c to nil" )
}
{
if err := s .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode starGiftAttributeOriginalDetails#e0bff26c: field flags: %w" , err )
}
}
if s .Flags .Has (0 ) {
value , err := DecodePeer (b )
if err != nil {
return fmt .Errorf ("unable to decode starGiftAttributeOriginalDetails#e0bff26c: field sender_id: %w" , err )
}
s .SenderID = value
}
{
value , err := DecodePeer (b )
if err != nil {
return fmt .Errorf ("unable to decode starGiftAttributeOriginalDetails#e0bff26c: field recipient_id: %w" , err )
}
s .RecipientID = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode starGiftAttributeOriginalDetails#e0bff26c: field date: %w" , err )
}
s .Date = value
}
if s .Flags .Has (1 ) {
if err := s .Message .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode starGiftAttributeOriginalDetails#e0bff26c: field message: %w" , err )
}
}
return nil
}
func (s *StarGiftAttributeOriginalDetails ) SetSenderID (value PeerClass ) {
s .Flags .Set (0 )
s .SenderID = value
}
func (s *StarGiftAttributeOriginalDetails ) GetSenderID () (value PeerClass , ok bool ) {
if s == nil {
return
}
if !s .Flags .Has (0 ) {
return value , false
}
return s .SenderID , true
}
func (s *StarGiftAttributeOriginalDetails ) GetRecipientID () (value PeerClass ) {
if s == nil {
return
}
return s .RecipientID
}
func (s *StarGiftAttributeOriginalDetails ) GetDate () (value int ) {
if s == nil {
return
}
return s .Date
}
func (s *StarGiftAttributeOriginalDetails ) SetMessage (value TextWithEntities ) {
s .Flags .Set (1 )
s .Message = value
}
func (s *StarGiftAttributeOriginalDetails ) GetMessage () (value TextWithEntities , ok bool ) {
if s == nil {
return
}
if !s .Flags .Has (1 ) {
return value , false
}
return s .Message , true
}
const StarGiftAttributeClassName = "StarGiftAttribute"
type StarGiftAttributeClass interface {
bin .Encoder
bin .Decoder
bin .BareEncoder
bin .BareDecoder
construct () StarGiftAttributeClass
TypeID () uint32
TypeName () string
String () string
Zero () bool
}
func DecodeStarGiftAttribute (buf *bin .Buffer ) (StarGiftAttributeClass , error ) {
id , err := buf .PeekID ()
if err != nil {
return nil , err
}
switch id {
case StarGiftAttributeModelTypeID :
v := StarGiftAttributeModel {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode StarGiftAttributeClass: %w" , err )
}
return &v , nil
case StarGiftAttributePatternTypeID :
v := StarGiftAttributePattern {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode StarGiftAttributeClass: %w" , err )
}
return &v , nil
case StarGiftAttributeBackdropTypeID :
v := StarGiftAttributeBackdrop {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode StarGiftAttributeClass: %w" , err )
}
return &v , nil
case StarGiftAttributeOriginalDetailsTypeID :
v := StarGiftAttributeOriginalDetails {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode StarGiftAttributeClass: %w" , err )
}
return &v , nil
default :
return nil , fmt .Errorf ("unable to decode StarGiftAttributeClass: %w" , bin .NewUnexpectedID (id ))
}
}
type StarGiftAttributeBox struct {
StarGiftAttribute StarGiftAttributeClass
}
func (b *StarGiftAttributeBox ) Decode (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("unable to decode StarGiftAttributeBox to nil" )
}
v , err := DecodeStarGiftAttribute (buf )
if err != nil {
return fmt .Errorf ("unable to decode boxed value: %w" , err )
}
b .StarGiftAttribute = v
return nil
}
func (b *StarGiftAttributeBox ) Encode (buf *bin .Buffer ) error {
if b == nil || b .StarGiftAttribute == nil {
return fmt .Errorf ("unable to encode StarGiftAttributeClass as nil" )
}
return b .StarGiftAttribute .Encode (buf )
}
The pages are generated with Golds v0.8.4 . (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu .
PR and bug reports are welcome and can be submitted to the issue list .
Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds .