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 StarGiftAuctionRound struct {
Num int
Duration int
}
const StarGiftAuctionRoundTypeID = 0x3aae0528
func (s StarGiftAuctionRound ) construct () StarGiftAuctionRoundClass { return &s }
var (
_ bin .Encoder = &StarGiftAuctionRound {}
_ bin .Decoder = &StarGiftAuctionRound {}
_ bin .BareEncoder = &StarGiftAuctionRound {}
_ bin .BareDecoder = &StarGiftAuctionRound {}
_ StarGiftAuctionRoundClass = &StarGiftAuctionRound {}
)
func (s *StarGiftAuctionRound ) Zero () bool {
if s == nil {
return true
}
if !(s .Num == 0 ) {
return false
}
if !(s .Duration == 0 ) {
return false
}
return true
}
func (s *StarGiftAuctionRound ) String () string {
if s == nil {
return "StarGiftAuctionRound(nil)"
}
type Alias StarGiftAuctionRound
return fmt .Sprintf ("StarGiftAuctionRound%+v" , Alias (*s ))
}
func (s *StarGiftAuctionRound ) FillFrom (from interface {
GetNum () (value int )
GetDuration () (value int )
}) {
s .Num = from .GetNum ()
s .Duration = from .GetDuration ()
}
func (*StarGiftAuctionRound ) TypeID () uint32 {
return StarGiftAuctionRoundTypeID
}
func (*StarGiftAuctionRound ) TypeName () string {
return "starGiftAuctionRound"
}
func (s *StarGiftAuctionRound ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "starGiftAuctionRound" ,
ID : StarGiftAuctionRoundTypeID ,
}
if s == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Num" ,
SchemaName : "num" ,
},
{
Name : "Duration" ,
SchemaName : "duration" ,
},
}
return typ
}
func (s *StarGiftAuctionRound ) Encode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode starGiftAuctionRound#3aae0528 as nil" )
}
b .PutID (StarGiftAuctionRoundTypeID )
return s .EncodeBare (b )
}
func (s *StarGiftAuctionRound ) EncodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode starGiftAuctionRound#3aae0528 as nil" )
}
b .PutInt (s .Num )
b .PutInt (s .Duration )
return nil
}
func (s *StarGiftAuctionRound ) Decode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode starGiftAuctionRound#3aae0528 to nil" )
}
if err := b .ConsumeID (StarGiftAuctionRoundTypeID ); err != nil {
return fmt .Errorf ("unable to decode starGiftAuctionRound#3aae0528: %w" , err )
}
return s .DecodeBare (b )
}
func (s *StarGiftAuctionRound ) DecodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode starGiftAuctionRound#3aae0528 to nil" )
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode starGiftAuctionRound#3aae0528: field num: %w" , err )
}
s .Num = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode starGiftAuctionRound#3aae0528: field duration: %w" , err )
}
s .Duration = value
}
return nil
}
func (s *StarGiftAuctionRound ) GetNum () (value int ) {
if s == nil {
return
}
return s .Num
}
func (s *StarGiftAuctionRound ) GetDuration () (value int ) {
if s == nil {
return
}
return s .Duration
}
type StarGiftAuctionRoundExtendable struct {
Num int
Duration int
ExtendTop int
ExtendWindow int
}
const StarGiftAuctionRoundExtendableTypeID = 0xaa021e5
func (s StarGiftAuctionRoundExtendable ) construct () StarGiftAuctionRoundClass { return &s }
var (
_ bin .Encoder = &StarGiftAuctionRoundExtendable {}
_ bin .Decoder = &StarGiftAuctionRoundExtendable {}
_ bin .BareEncoder = &StarGiftAuctionRoundExtendable {}
_ bin .BareDecoder = &StarGiftAuctionRoundExtendable {}
_ StarGiftAuctionRoundClass = &StarGiftAuctionRoundExtendable {}
)
func (s *StarGiftAuctionRoundExtendable ) Zero () bool {
if s == nil {
return true
}
if !(s .Num == 0 ) {
return false
}
if !(s .Duration == 0 ) {
return false
}
if !(s .ExtendTop == 0 ) {
return false
}
if !(s .ExtendWindow == 0 ) {
return false
}
return true
}
func (s *StarGiftAuctionRoundExtendable ) String () string {
if s == nil {
return "StarGiftAuctionRoundExtendable(nil)"
}
type Alias StarGiftAuctionRoundExtendable
return fmt .Sprintf ("StarGiftAuctionRoundExtendable%+v" , Alias (*s ))
}
func (s *StarGiftAuctionRoundExtendable ) FillFrom (from interface {
GetNum () (value int )
GetDuration () (value int )
GetExtendTop () (value int )
GetExtendWindow () (value int )
}) {
s .Num = from .GetNum ()
s .Duration = from .GetDuration ()
s .ExtendTop = from .GetExtendTop ()
s .ExtendWindow = from .GetExtendWindow ()
}
func (*StarGiftAuctionRoundExtendable ) TypeID () uint32 {
return StarGiftAuctionRoundExtendableTypeID
}
func (*StarGiftAuctionRoundExtendable ) TypeName () string {
return "starGiftAuctionRoundExtendable"
}
func (s *StarGiftAuctionRoundExtendable ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "starGiftAuctionRoundExtendable" ,
ID : StarGiftAuctionRoundExtendableTypeID ,
}
if s == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Num" ,
SchemaName : "num" ,
},
{
Name : "Duration" ,
SchemaName : "duration" ,
},
{
Name : "ExtendTop" ,
SchemaName : "extend_top" ,
},
{
Name : "ExtendWindow" ,
SchemaName : "extend_window" ,
},
}
return typ
}
func (s *StarGiftAuctionRoundExtendable ) Encode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode starGiftAuctionRoundExtendable#aa021e5 as nil" )
}
b .PutID (StarGiftAuctionRoundExtendableTypeID )
return s .EncodeBare (b )
}
func (s *StarGiftAuctionRoundExtendable ) EncodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode starGiftAuctionRoundExtendable#aa021e5 as nil" )
}
b .PutInt (s .Num )
b .PutInt (s .Duration )
b .PutInt (s .ExtendTop )
b .PutInt (s .ExtendWindow )
return nil
}
func (s *StarGiftAuctionRoundExtendable ) Decode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode starGiftAuctionRoundExtendable#aa021e5 to nil" )
}
if err := b .ConsumeID (StarGiftAuctionRoundExtendableTypeID ); err != nil {
return fmt .Errorf ("unable to decode starGiftAuctionRoundExtendable#aa021e5: %w" , err )
}
return s .DecodeBare (b )
}
func (s *StarGiftAuctionRoundExtendable ) DecodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode starGiftAuctionRoundExtendable#aa021e5 to nil" )
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode starGiftAuctionRoundExtendable#aa021e5: field num: %w" , err )
}
s .Num = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode starGiftAuctionRoundExtendable#aa021e5: field duration: %w" , err )
}
s .Duration = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode starGiftAuctionRoundExtendable#aa021e5: field extend_top: %w" , err )
}
s .ExtendTop = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode starGiftAuctionRoundExtendable#aa021e5: field extend_window: %w" , err )
}
s .ExtendWindow = value
}
return nil
}
func (s *StarGiftAuctionRoundExtendable ) GetNum () (value int ) {
if s == nil {
return
}
return s .Num
}
func (s *StarGiftAuctionRoundExtendable ) GetDuration () (value int ) {
if s == nil {
return
}
return s .Duration
}
func (s *StarGiftAuctionRoundExtendable ) GetExtendTop () (value int ) {
if s == nil {
return
}
return s .ExtendTop
}
func (s *StarGiftAuctionRoundExtendable ) GetExtendWindow () (value int ) {
if s == nil {
return
}
return s .ExtendWindow
}
const StarGiftAuctionRoundClassName = "StarGiftAuctionRound"
type StarGiftAuctionRoundClass interface {
bin .Encoder
bin .Decoder
bin .BareEncoder
bin .BareDecoder
construct () StarGiftAuctionRoundClass
TypeID () uint32
TypeName () string
String () string
Zero () bool
GetNum () (value int )
GetDuration () (value int )
}
func DecodeStarGiftAuctionRound (buf *bin .Buffer ) (StarGiftAuctionRoundClass , error ) {
id , err := buf .PeekID ()
if err != nil {
return nil , err
}
switch id {
case StarGiftAuctionRoundTypeID :
v := StarGiftAuctionRound {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode StarGiftAuctionRoundClass: %w" , err )
}
return &v , nil
case StarGiftAuctionRoundExtendableTypeID :
v := StarGiftAuctionRoundExtendable {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode StarGiftAuctionRoundClass: %w" , err )
}
return &v , nil
default :
return nil , fmt .Errorf ("unable to decode StarGiftAuctionRoundClass: %w" , bin .NewUnexpectedID (id ))
}
}
type StarGiftAuctionRoundBox struct {
StarGiftAuctionRound StarGiftAuctionRoundClass
}
func (b *StarGiftAuctionRoundBox ) Decode (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("unable to decode StarGiftAuctionRoundBox to nil" )
}
v , err := DecodeStarGiftAuctionRound (buf )
if err != nil {
return fmt .Errorf ("unable to decode boxed value: %w" , err )
}
b .StarGiftAuctionRound = v
return nil
}
func (b *StarGiftAuctionRoundBox ) Encode (buf *bin .Buffer ) error {
if b == nil || b .StarGiftAuctionRound == nil {
return fmt .Errorf ("unable to encode StarGiftAuctionRoundClass as nil" )
}
return b .StarGiftAuctionRound .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 .